TraktPlugin.GUI.GUIPopularMovies.OnClicked C# (CSharp) Méthode

OnClicked() protected méthode

protected OnClicked ( int controlId, GUIControl control, MediaPortal.GUI.Library.Action actionType ) : void
controlId int
control MediaPortal.GUI.Library.GUIControl
actionType MediaPortal.GUI.Library.Action
Résultat void
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // wait for any background action to finish
            if (GUIBackgroundTask.Instance.IsBusy) return;

            switch (controlId)
            {
                // Facade
                case (50):
                    if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                    {
                        var item = Facade.SelectedListItem as GUIMovieListItem;
                        if (item == null) return;

                        if (!item.IsFolder)
                        {
                            CheckAndPlayMovie(true);
                        }
                        else
                        {
                            if (item.IsPrevPageItem)
                                CurrentPage--;
                            else
                                CurrentPage++;

                            if (CurrentPage == 1)
                                PreviousSelectedIndex = 0;
                            else
                                PreviousSelectedIndex = 1;

                            // load next / previous page
                            LoadPopularMovies(CurrentPage);
                        }
                    }
                    break;

                // Layout Button
                case (2):
                    CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                    break;

                // Sort Button
                case (8):
                    var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByPopularMovies);
                    if (newSortBy != null)
                    {
                        if (newSortBy.Field != TraktSettings.SortByPopularMovies.Field)
                        {
                            TraktSettings.SortByPopularMovies = newSortBy;
                            PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                            UpdateButtonState();
                            LoadPopularMovies(CurrentPage);
                        }
                    }
                    break;

                // Hide Watched
                case (9):
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    TraktSettings.PopularMoviesHideWatched = !TraktSettings.PopularMoviesHideWatched;
                    UpdateButtonState();
                    LoadPopularMovies(CurrentPage);
                    break;

                // Hide Watchlisted
                case (10):
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    TraktSettings.PopularMoviesHideWatchlisted = !TraktSettings.PopularMoviesHideWatchlisted;
                    UpdateButtonState();
                    LoadPopularMovies(CurrentPage);
                    break;

                // Hide Collected
                case (11):
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    TraktSettings.PopularMoviesHideCollected = !TraktSettings.PopularMoviesHideCollected;
                    UpdateButtonState();
                    LoadPopularMovies(CurrentPage);
                    break;

                // Hide Rated
                case (12):
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    TraktSettings.PopularMoviesHideRated = !TraktSettings.PopularMoviesHideRated;
                    UpdateButtonState();
                    LoadPopularMovies(CurrentPage);
                    break;

                default:
                    break;
            }
            base.OnClicked(controlId, control, actionType);
        }