コード例 #1
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            //if (GUIBackgroundTask.Instance.IsBusy) return;
            switch (controlId)
            {
                #region SEARCH LIST CONTROL SELECTED
            case (3):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    GUIListItem item = resultListControl.SelectedListItem as GUIListItem;
#if DEBUG
                    TraktLogger.Info("The button pressed has a tvTAG as: {0}, ad has a string value of: {1}", item.TVTag.GetType(), item.TVTag.ToString());
#endif
                    #region SCROBBLEMOVIE
                    if (item.TVTag is TraktMovieSummary)
                    {
                        // Get movie from traktmoviesummary
                        TraktMovie currentMovieSelected = new TraktMovie
                        {
                            Title = ((TraktMovieSummary)item.TVTag).Title,
                            Year  = ((TraktMovieSummary)item.TVTag).Year,
                            Ids   = ((TraktMovieSummary)item.TVTag).Ids
                        };
                        var data = new TraktScrobbleMovie
                        {
                            Movie      = currentMovieSelected,
                            Progress   = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()),
                            AppDate    = TraktSettings.BuildDate,
                            AppVersion = TraktSettings.Version
                        };
                        EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData((TraktMovieSummary)item.TVTag));
                        EbasicHandler.overrideCurrentProgram((TraktMovieSummary)item.TVTag);
                        EbasicHandler.StartScrobble(data);
                    }
                    #endregion
                    else if (item.TVTag is TraktShowSummary)    //search for seasons
                    {
                        TraktLogger.Info("TraktShowSummary Detected");
                        currentTvShow = (TraktShowSummary)item.TVTag;
                        searchStack.Push(currentSearch);
                        PopulateListControl(EbasicHandler.SearchShowSeasons(((TraktShowSummary)item.TVTag).Ids.Slug), searchlevel++);
                        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null);
                        OnMessage(msg);
                    }
                    else if (item.TVTag is TraktSeasonSummary)     //Episode for episodes
                    {
#if DEBUG
                        TraktLogger.Info("SeasonSummary Detected");
                        TraktLogger.Info("Season '{0}' for show {1} selected. Getting Episodes.", ((TraktSeasonSummary)item.TVTag).Number, currentTvShow.Ids.Slug);
#endif
                        searchStack.Push(currentSearch);
                        PopulateListControl(EbasicHandler.SearchSeasonEpisodes(currentTvShow.Ids.Slug, ((TraktSeasonSummary)item.TVTag).Number.ToString()), searchlevel++);
                        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null);
                        OnMessage(msg);
                    }
                    #region SCROBBLESHOW
                    else if (item.TVTag is TraktEpisodeSummary)    //found!
                    {
                        TraktLogger.Info("EpisodeSummary Detected");
                        var data = new TraktScrobbleEpisode
                        {
                            Show = new TraktShow
                            {
                                Title = currentTvShow.Title,
                                Year  = currentTvShow.Year,
                                Ids   = currentTvShow.Ids
                            },
                            Episode = new TraktEpisode
                            {
                                Season = ((TraktEpisodeSummary)item.TVTag).Season,
                                Number = ((TraktEpisodeSummary)item.TVTag).Number,
                                Title  = ((TraktEpisodeSummary)item.TVTag).Title,
                                Ids    = ((TraktEpisodeSummary)item.TVTag).Ids
                            },
                            Progress   = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()),
                            AppDate    = TraktSettings.BuildDate,
                            AppVersion = TraktSettings.Version
                        };
#if DEBUG
                        TraktLogger.Info(currentTvShow.ToString());
#endif
                        EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData(currentTvShow));
                        EbasicHandler.overrideCurrentProgram(currentTvShow, data.Episode);
                        EbasicHandler.StartScrobble(data);
                    }
                    #endregion

                    else if (item.TVTag.ToString() == "FirstButton")
                    {
                        if ((item.Label).ToString() == "Manual Search")
                        {
                            //popup the input dialog to search. I need to call the full GUI here.
#if DEBUG
                            TraktLogger.Info("Manual search selected");
#endif
                            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                            //keyboard.IsSearchKeyboard = true;
                            keyboard.Reset();
                            keyboard.Text = EbasicHandler.getCurrentProgram().Title;
                            keyboard.DoModal(GUIWindowManager.ActiveWindow);
                            if (keyboard.IsConfirmed)
                            {
                                //PopulateControlWithShows(keyboard.Text);
                                //PopulateListControl(TraktAPI.TraktAPI.SearchShowByName(keyboard.Text));
                                //GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null);
                                //OnMessage(msg);
                                //GUIShowSelectGUI.setCurrentSearch(TraktAPI.TraktAPI.SearchByName(keyboard.Text));
                                //GUIWindowManager.ActivateWindow((int)TraktGUIWindows.EPGShowSelect);
                                GUIShowSelectGUI.callSearchGUI(TraktAPI.TraktAPI.SearchByName(keyboard.Text));
                            }
                        }
                        else     //this handles back button
                        {
                            TraktLogger.Info("BackButtonDetected");
                            PopulateListControl(searchStack.Pop(), searchlevel--);
                            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null);
                            OnMessage(msg);
                        }
                    }
                }
                break;

                #endregion
            default:
                TraktLogger.Info("I don't know what's the object.");
                base.OnClicked(controlId, control, actionType);
                break;
            }
        }
コード例 #2
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            //if (GUIBackgroundTask.Instance.IsBusy) return;
            switch (controlId)
            {
                #region SEARCH LIST CONTROL SELECTED
            case (873008):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    GUIListItem item = resultListControl.SelectedListItem as GUIListItem;

                    #region SCROBBLEMOVIE
                    if (item.TVTag is TraktMovieSummary)
                    {
                        // Get movie from traktmoviesummary
                        TraktMovie currentMovieSelected = new TraktMovie
                        {
                            Title = ((TraktMovieSummary)item.TVTag).Title,
                            Year  = ((TraktMovieSummary)item.TVTag).Year,
                            Ids   = ((TraktMovieSummary)item.TVTag).Ids
                        };
                        var data = new TraktScrobbleMovie
                        {
                            Movie      = currentMovieSelected,
                            Progress   = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()),
                            AppDate    = TraktSettings.BuildDate,
                            AppVersion = TraktSettings.Version
                        };
                        EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData((TraktMovieSummary)item.TVTag));
                        EbasicHandler.overrideCurrentProgram((TraktMovieSummary)item.TVTag);
                        EbasicHandler.StartScrobble(data);
                        exitGUI();
                    }
                    #endregion
                    #region SCROBBLESHOW
                    else if (item.TVTag is TraktEpisodeSummary)    //found!
                    {
                        TraktLogger.Info("EpisodeSummary Detected");
                        var data = new TraktScrobbleEpisode
                        {
                            Show = new TraktShow
                            {
                                Title = currentTvShow.Title,
                                Year  = currentTvShow.Year,
                                Ids   = currentTvShow.Ids
                            },
                            Episode = new TraktEpisode
                            {
                                Season = ((TraktEpisodeSummary)item.TVTag).Season,
                                Number = ((TraktEpisodeSummary)item.TVTag).Number,
                                Title  = ((TraktEpisodeSummary)item.TVTag).Title,
                                Ids    = ((TraktEpisodeSummary)item.TVTag).Ids
                            },
                            Progress   = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()),
                            AppDate    = TraktSettings.BuildDate,
                            AppVersion = TraktSettings.Version
                        };
                        EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData(currentTvShow));
                        EbasicHandler.overrideCurrentProgram(currentTvShow, data.Episode);
                        EbasicHandler.StartScrobble(data);
                        exitGUI();
                    }
                    #endregion

                    else if (item.TVTag is TraktShowSummary)
                    {
                        TraktLogger.Info("TraktShowSummary Detected");
                        currentTvShow = (TraktShowSummary)item.TVTag;
                        searchStack.Push(currentSearch);
                        PopulateListControl(EbasicHandler.SearchShowSeasons(((TraktShowSummary)item.TVTag).Ids.Slug), searchlevel++);
                    }
                    else if (item.TVTag is TraktSeasonSummary)
                    {
                        searchStack.Push(currentSearch);
                        PopulateListControl(EbasicHandler.SearchSeasonEpisodes(currentTvShow.Ids.Slug, ((TraktSeasonSummary)item.TVTag).Number.ToString()), searchlevel++);
                    }
                    else if (item.TVTag.ToString() == "FirstButton")
                    {
                        if ((item.Label).ToString() == "Manual Search")
                        {
                            //popup the input dialog to search.
                            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                            keyboard.Reset();
                            keyboard.Text = EbasicHandler.getCurrentProgram().Title;
                            keyboard.DoModal(GUIWindowManager.ActiveWindow);
                            if (keyboard.IsConfirmed)
                            {
                                PopulateListControl(TraktAPI.TraktAPI.SearchByName(keyboard.Text, "show,movie", "title"));
                            }
                        }
                        else     //this handles back button
                        {
                            PopulateListControl(searchStack.Pop(), searchlevel--);
                        }
                    }
                }
                break;

                #endregion
            default:
                TraktLogger.Info("I don't know what's the object.");
                base.OnClicked(controlId, control, actionType);
                break;
            }
        }