TraktPlugin.GUI.GUIWatchListMovies.SendWatchListMoviesToFacade C# (CSharp) 메소드

SendWatchListMoviesToFacade() 개인적인 메소드

private SendWatchListMoviesToFacade ( IEnumerable movieWatchlist ) : void
movieWatchlist IEnumerable
리턴 void
        private void SendWatchListMoviesToFacade(IEnumerable<TraktMovieWatchList> movieWatchlist)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (movieWatchlist == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (movieWatchlist.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoMovieWatchList, CurrentUser));
                CurrentUser = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // sort movies
            var sortedList = movieWatchlist.Where(m => !string.IsNullOrEmpty(m.Movie.Title)).ToList();
            sortedList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByWatchListMovies.Field, TraktSettings.SortByWatchListMovies.Direction));

            int itemId = 0;
            var movieImages = new List<GUITmdbImage>();

            // Add each movie
            foreach (var watchlistItem in sortedList)
            {
                // add image for download
                var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = watchlistItem.Movie.Ids.Tmdb } };
                movieImages.Add(images);

                var item = new GUIMovieListItem(watchlistItem.Movie.Title, (int)TraktGUIWindows.WatchedListMovies);

                item.Label2 = watchlistItem.Movie.Year == null ? "----" : watchlistItem.Movie.Year.ToString();
                item.TVTag = watchlistItem;
                item.Movie = watchlistItem.Movie;
                item.Images = images;
                item.ItemId = Int32.MaxValue - itemId;
                item.IsPlayed = watchlistItem.Movie.IsWatched();
                item.IconImage = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= movieWatchlist.Count())
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            else
                Facade.SelectIndex(PreviousSelectedIndex);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", movieWatchlist.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movieWatchlist.Count().ToString(), movieWatchlist.Count() > 1 ? Translation.Movies : Translation.Movie));

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }