Пример #1
0
 protected bool GetKeyboard(ref string strLine)
 {
     try
     {
         VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
         if (null == keyboard)
         {
             return(false);
         }
         keyboard.Reset();
         keyboard.Text = strLine;
         keyboard.DoModal(GetID);
         if (keyboard.IsConfirmed)
         {
             strLine = keyboard.Text;
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         MPTVSeriesLog.Write(string.Format("Virtual Keyboard error: {0}, stack: {1}", ex.Message, ex.StackTrace));
         return(false);
     }
 }
Пример #2
0
        /// <summary>
        /// Tries to start the playback of an internet stream
        /// </summary>
        /// <returns>true, if successful</returns>
        private static void OnPlayStream()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return;
            }
            keyboard.Reset();
            keyboard.Text = String.Empty;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);
            if (keyboard.IsConfirmed)
            {
                if (!keyboard.Text.Equals(String.Empty))
                {
                    if (g_Player.Playing)
                    {
                        g_Player.Stop();
                    }
                    String url = keyboard.Text + ".mplayer";
                    if (url.StartsWith("rtsp:"))
                    {
                        url = "ZZZZ:" + url.Remove(0, 5);
                    }

                    g_Player.Play(url);
                    if (g_Player.Player != null && g_Player.IsVideo)
                    {
                        GUIGraphicsContext.IsFullScreenVideo = true;
                        GUIWindowManager.ActivateWindow((int)Window.WINDOW_FULLSCREEN_VIDEO);
                    }
                }
            }
            return;
        }
Пример #3
0
        public void StartSearch()
        {
            MyTorrents.Instance().torrentList.Visible = false;
            TorrentEngine.Instance().SearchCompleted += new SearchCompleted(_torrentEngine_SearchCompleted);
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            keyboard.Reset();

            keyboard.Text = SearchString == null ? "" : SearchString;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (!keyboard.IsConfirmed)
            {
                MyTorrents.Instance().torrentList.Visible = true;
                MyTorrents.ListType = "Torrents";
                return;
            }

            SearchString = keyboard.Text;

            GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlgMenu == null)
            {
                return;
            }

            dlgMenu.Reset();

            dlgMenu.SetHeading("Which engine to use?");
            TorrentSearchEngine tse = null;

            try
            {
                tse = new TorrentSearchEngine(Configuration.Instance().Settings["TorrentSearch.Config"] as string);
            }
            catch
            {
                Log.Instance().Print("MyTorrents.xml config file loading failed!");
            }
            foreach (ITorrentSearch engine in tse.Engines)
            {
                GUIListItem listItem = new GUIListItem();
                listItem.Label = engine.Name;
                dlgMenu.Add(listItem);
            }
            dlgMenu.DoModal(GUIWindowManager.ActiveWindow);
            if (dlgMenu.SelectedLabel == -1)
            {
                MyTorrents.Instance().torrentList.Visible = true;
                MyTorrents.ListType = "Torrents";
                return;
            }
            _searchEngine = tse.Engines[dlgMenu.SelectedLabel];
            MyTorrents.Instance().torrentList.Clear();
            MyTorrents.Instance().torrentList.Visible = true;
            MyTorrents.Instance().torrentList.ListItems = SearchResults;

            UpdateSearchResults("Default");//
        }
Пример #4
0
        /// <summary>
        /// Gets the input from the virtual keyboard window.
        /// </summary>
        public static bool GetStringFromKeyboard(ref string strLine, bool isPassword)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                GetStringFromKeyboardDelegate d = GetStringFromKeyboard;
                object[] args   = { strLine, isPassword };
                bool     result = (bool)GUIGraphicsContext.form.Invoke(d, args);
                strLine = (string)args[0];
                return(result);
            }

            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard == null)
            {
                return(false);
            }

            keyboard.Reset();
            keyboard.Text     = strLine;
            keyboard.Password = isPassword;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (keyboard.IsConfirmed)
            {
                strLine = keyboard.Text;
                return(true);
            }

            return(false);
        }
Пример #5
0
 private void OnChangeName()
 {
     if (_upcomingProgram != null)
     {
         Schedule schedule = Proxies.SchedulerService.GetScheduleById(_upcomingProgram.ScheduleId).Result;
         if (schedule == null)
         {
             return;
         }
         string          schedname = schedule.Name;
         VirtualKeyboard keyboard  = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
         if (keyboard != null)
         {
             keyboard.Reset();
             keyboard.IsSearchKeyboard = false;
             keyboard.Text             = schedname ?? String.Empty;
             keyboard.DoModal(GetID);
             if (keyboard.IsConfirmed)
             {
                 schedule.Name = keyboard.Text;
                 Proxies.SchedulerService.SaveSchedule(schedule).Wait();
             }
         }
     }
 }
Пример #6
0
        private void DoSearch()
        {
            string searchString = "";

            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }
            dlg.Reset();
            dlg.SetHeading(Translation.SearchHistory);
            dlg.Add(string.Format("<{0}>", Translation.NewSearch));
            for (int i = _setting.SearchHistory.Count; i > 0; i--)
            {
                dlg.Add(_setting.SearchHistory[i - 1]);
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
            {
                return;
            }

            searchString = dlg.SelectedLabelText;
            if (searchString == string.Format("<{0}>", Translation.NewSearch))
            {
                searchString = "";
            }

            // display an virtual keyboard
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return;
            }
            keyboard.Reset();
            keyboard.Text = searchString;
            keyboard.DoModal(GetWindowId());
            if (keyboard.IsConfirmed)
            {
                // input confirmed -- execute the search
                searchString = keyboard.Text;
            }

            if ("" != searchString)
            {
                grabber.Search(searchString, Translation.Search);
                UpdateList();
                if (_setting.SearchHistory.Contains(searchString.Trim()))
                {
                    _setting.SearchHistory.Remove(searchString.Trim());
                }
                _setting.SearchHistory.Add(searchString.Trim());
                _setting.Save();
            }
        }
Пример #7
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            if (control == _testConnectionButton)
            {
                TestConnection();
                UpdateButtons();
            }
            else if (control == _serverNameButton)
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (keyboard != null)
                {
                    keyboard.Reset();
                    keyboard.IsSearchKeyboard = false;
                    keyboard.Text             = _serverNameButton.Label ?? "localhost";
                    keyboard.DoModal(GetID);
                    if (keyboard.IsConfirmed)
                    {
                        _serverNameButton.Label = keyboard.Text.Trim();
                    }
                }
            }
            else if (control == _tcpPortButton)
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (keyboard != null)
                {
                    int port = ServerSettings.DefaultTcpPort;
                    keyboard.Reset();
                    keyboard.IsSearchKeyboard = false;
                    keyboard.Text             = _tcpPortButton.Label ?? port.ToString();
                    keyboard.DoModal(GetID);
                    if (keyboard.IsConfirmed)
                    {
                        if (!Int32.TryParse(keyboard.Text, out port))
                        {
                            port = ServerSettings.DefaultTcpPort;
                        }
                        _tcpPortButton.Label = port.ToString();
                    }
                }
            }
            else if (control == _enableWolButton || control == _autoStreamingButton)
            {
                UpdateButtons();
            }

            if (control == _autoStreamingButton || control == _rtspStreamingTVButton ||
                control == _rtspStreamingRecButton || control == _teletextSubtitleButton ||
                control == _dvbSubtitlesButton || control == _preferAC3Button ||
                control == _recordingNotificationButton)
            {
                _restartPlayerNeeded = true;
            }
            base.OnClicked(controlId, control, actionType);
        }
Пример #8
0
        public void SearchContextMenu()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading("Torrent menu");
            dlg.Add("Search again");
            dlg.Add("Sort by >>");
            dlg.Add("Filter results");
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            switch (dlg.SelectedLabelText)
            {
            case "Filter results":
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                keyboard.Reset();
                keyboard.Text = _filter;
                keyboard.DoModal(GUIWindowManager.ActiveWindow);

                if (keyboard.IsConfirmed)
                {
                    _filter = keyboard.Text;
                    UpdateSearchResults();
                }
                break;
            }

            case "Search again":
            {
                StartSearch();
                break;
            }

            case "Sort by >>":
                dlg.Reset();
                dlg.SetHeading("Sort by...");

                foreach (string sortMethod in _searchEngine.SortMethods())
                {
                    dlg.Add(sortMethod);
                }
                dlg.DoModal(GUIWindowManager.ActiveWindow);

                if (dlg.SelectedLabel != -1)
                {
                    UpdateSearchResults(dlg.SelectedLabelText);
                }
                break;
            }
        }
Пример #9
0
        public void SearchSeries()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            keyboard.Reset();
            keyboard.Text = "";
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (!keyboard.IsConfirmed)
            {
                return;
            }

            IList <TraktShow> searchshow = TraktAPI.SearchShows(keyboard.Text).ToList();
            GUIDialogMenu     dialog     = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                return;
            }

            dialog.Reset();
            dialog.SetHeading("Choose TV Series to add");
            foreach (TraktShow ts in searchshow)
            {
                dialog.Add(string.Format("{0} - ({1})", ts.Title, ts.Year));
            }
            dialog.DoModal(GUIWindowManager.ActiveWindow);

            if (dialog.SelectedId != -1)
            {
                TraktShow  t    = searchshow[dialog.SelectedId - 1];
                SeriesItem item = new SeriesItem();
                item.quality           = "720p";
                item.show              = new Series();
                item.show.Name         = t.Title;
                item.show.OriginalName = t.Title;
                item.show.Description  = t.Overview;
                foreach (string genre in t.Genres)
                {
                    item.show.Genres += "|" + genre;
                }
                item.show.Rating = ((double)t.Ratings.Percentage / 10.0).ToString();
                item.show.Poster = t.Images.Banner;
                item.show.ID     = t.Tvdb;
                item.tracker     = "BTN";
                MyTorrents.Instance()._torrentWatchlist._watchItemList.Add(item);
            }
        }
Пример #10
0
        private string GetPlayerName()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return(null);
            }
            keyboard.Reset();
            keyboard.DoModal(GetID);
            if (keyboard.IsConfirmed)
            {
                return(keyboard.Text);
            }
            return("unknown");
        }
Пример #11
0
        private void GetStringFromKeyboard(ref string strLine)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return;
            }
            keyboard.Reset();
            keyboard.Text = strLine;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);
            strLine = string.Empty;
            if (keyboard.IsConfirmed)
            {
                strLine = keyboard.Text;
            }
        }
Пример #12
0
        public static bool GetUserInputString(ref string sString, bool password = false)
        {
            VirtualKeyboard keyBoard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyBoard == null)
            {
                return(false);
            }
            keyBoard.Reset();
            keyBoard.Text     = sString;
            keyBoard.Password = password;
            keyBoard.DoModal(GUIWindowManager.ActiveWindow); // show it...
            if (keyBoard.IsConfirmed)
            {
                sString = keyBoard.Text;
            }
            return(keyBoard.IsConfirmed);
        }
Пример #13
0
        protected bool GetKeyboard(ref string strLine)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard == null)
            {
                return(false);
            }
            keyboard.Reset();
            keyboard.Text = strLine;
            keyboard.DoModal(GetID);
            if (keyboard.IsConfirmed)
            {
                strLine = keyboard.Text;
                return(true);
            }
            return(false);
        }
Пример #14
0
        private bool GetKeyboard(ref string strLine)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return(false);
            }
            keyboard.IsSearchKeyboard = true;
            keyboard.Reset();
            keyboard.SetLabelAsInitialText(true);
            keyboard.Label = GUILocalizeStrings.Get(408);
            keyboard.DoModal(GUIWindowManager.ActiveWindow);
            if (keyboard.IsConfirmed)
            {
                strLine = keyboard.Text;
                return(true);
            }
            return(false);
        }
Пример #15
0
        /// <summary>
        /// Gets the input from the virtual keyboard window.
        /// </summary>
        public static bool GetStringFromKeyboard(ref string strLine)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard == null)
            {
                return(false);
            }

            keyboard.Reset();
            keyboard.Text = strLine;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (keyboard.IsConfirmed)
            {
                strLine = keyboard.Text;
                return(true);
            }

            return(false);
        }
Пример #16
0
        public string GetKeyBoardInput(string defaultText)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard == null)
            {
                return(String.Empty);
            }
            keyboard.Reset();
            keyboard.IsSearchKeyboard = true;
            keyboard.Text             = defaultText;
            keyboard.DoModal(GUIWindowManager.ActiveWindow);
            if (keyboard.IsConfirmed)
            {
                return(keyboard.Text);
            }
            else
            {
                return(String.Empty);
            }
        }
Пример #17
0
        protected bool GetUserPasswordString(ref string sString)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return(false);
            }

            keyboard.IsSearchKeyboard = true;
            keyboard.Reset();
            keyboard.Password = true;
            keyboard.Text     = sString;
            keyboard.DoModal(GetID); // show it...

            if (keyboard.IsConfirmed)
            {
                sString = keyboard.Text;
            }

            return(keyboard.IsConfirmed);
        }
Пример #18
0
        public static bool DialogText(ref string text, bool password, int windowID)
        {
            VirtualKeyboard keyBoard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyBoard == null)
            {
                return(false);
            }

            keyBoard.Reset();
            keyBoard.IsSearchKeyboard = true;
            keyBoard.Text             = text;
            keyBoard.Password         = password;
            keyBoard.DoModal(windowID);

            if (keyBoard.IsConfirmed)
            {
                text = keyBoard.Text;
                return(true);
            }

            return(false);
        }
Пример #19
0
        private void GetNumberFromKeyboard(ref string strLine)
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);

            if (null == keyboard)
            {
                return;
            }
            keyboard.Reset();
            keyboard.Text = strLine;

            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            if (keyboard.IsConfirmed)
            {
                int number;
                if (Int32.TryParse(keyboard.Text, out number))
                {
                    _iStartUpDelay = number;
                    strLine        = keyboard.Text;
                }
            }
        }
Пример #20
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            if (control == btnSearch)
            {
                if (m_foundGlobalSearch)
                {
                    GUIWindowManager.ActivateWindow(30885); // Check in GlobalSerach source
                }
                else
                {
                    int             activeWindow = (int)GUIWindowManager.ActiveWindow;
                    VirtualKeyboard keyboard     = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                    if (null == keyboard)
                    {
                        return;
                    }
                    keyboard.IsSearchKeyboard = true;
                    keyboard.Text             = string.Empty;
                    keyboard.Reset();
                    //keyBoard.KindOfSearch=(int)MediaPortal.Dialogs.VirtualSearchKeyboard.SearchKinds.SEARCH_STARTS_WITH;
                    keyboard_TextChanged(0, "");
                    keyboard.TextChanged += new VirtualKeyboard.TextChangedEventHandler(keyboard_TextChanged);
                    // add the event handler
                    keyboard.DoModal(activeWindow); // show it...
                    keyboard.TextChanged -= new VirtualKeyboard.TextChangedEventHandler(keyboard_TextChanged);
                    // remove the handler
                }
            }

            if (control == btnPlayCd)
            {
                GUIMusicFiles musicFilesWnd = (GUIMusicFiles)GUIWindowManager.GetWindow((int)Window.WINDOW_MUSIC_FILES);
                musicFilesWnd.PlayCD();
            }

            base.OnClicked(controlId, control, actionType);
        }
Пример #21
0
        private void CreateNewChannelGroup()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard != null)
            {
                keyboard.Reset();
                keyboard.IsSearchKeyboard = false;
                keyboard.Text             = string.Empty;
                keyboard.DoModal(GetID);
                if (keyboard.IsConfirmed && keyboard.Text != string.Empty)
                {
                    ChannelGroup group = new ChannelGroup()
                    {
                        Sequence       = GetAllChannelGroups().Count,
                        ChannelType    = _currentChannelType,
                        VisibleInGuide = true,
                        GroupName      = keyboard.Text
                    };

                    Proxies.SchedulerService.SaveChannelGroup(group).Wait();
                }
            }
        }
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            if (control == buttonReset)
            {
                labelCurrent.Label = DEFAULT_SETTING;
                SetCheckMarksBasedOnString(DEFAULT_SETTING);
            }
            else if (control == buttonAdd)
            {
                VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                vk.Reset();
                vk.DoModal(GetID);
                string newStep = vk.Text;
                if (newStep == string.Empty || newStep == null)
                {
                    return;
                }
                string error = verifySkipStep(newStep);
                if (error != null)
                {
                    GUIDialogOK errDialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    errDialog.SetHeading(257);
                    errDialog.SetLine(1, error);
                    errDialog.DoModal(GetID);
                }
                else
                {
                    AddStep(Convert.ToInt16(newStep)); // Already verifed, so no numberformatexception can occur
                }
            }
            else if (control == buttonRemove)
            {
                GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT2);
                dlgSel.Reset();

                foreach (string token in labelCurrent.Label.Split(new char[] { ',', ';', ' ' }))
                {
                    if (token == string.Empty)
                    {
                        continue;
                    }
                    dlgSel.Add(token);
                }

                dlgSel.SetHeading(200040); // Remove skip step
                dlgSel.DoModal(GetID);
                if (dlgSel.SelectedLabel != -1)
                {
                    try
                    {
                        RemoveStep(Convert.ToInt16(dlgSel.SelectedLabelText));
                    }
                    catch (Exception)
                    {
                        // Should never happen
                    }
                }
            }
            else if (control is GUICheckMarkControl)
            {
                int stepSize = 5;
                if (control == checkMarkButtonStep1)
                {
                    stepSize = 5;
                }
                else if (control == checkMarkButtonStep2)
                {
                    stepSize = 15;
                }
                else if (control == checkMarkButtonStep3)
                {
                    stepSize = 30;
                }
                else if (control == checkMarkButtonStep4)
                {
                    stepSize = 45;
                }
                else if (control == checkMarkButtonStep5)
                {
                    stepSize = 60;
                }
                else if (control == checkMarkButtonStep6)
                {
                    stepSize = 180;
                }
                else if (control == checkMarkButtonStep7)
                {
                    stepSize = 300;
                }
                else if (control == checkMarkButtonStep8)
                {
                    stepSize = 420;
                }
                else if (control == checkMarkButtonStep9)
                {
                    stepSize = 600;
                }
                else if (control == checkMarkButtonStep10)
                {
                    stepSize = 900;
                }
                else if (control == checkMarkButtonStep11)
                {
                    stepSize = 1800;
                }
                else if (control == checkMarkButtonStep12)
                {
                    stepSize = 2700;
                }
                else if (control == checkMarkButtonStep13)
                {
                    stepSize = 3600;
                }
                else if (control == checkMarkButtonStep14)
                {
                    stepSize = 5400;
                }
                else if (control == checkMarkButtonStep15)
                {
                    stepSize = 7200;
                }
                else if (control == checkMarkButtonStep16)
                {
                    stepSize = 10800;
                }

                if (!((GUICheckMarkControl)control).Selected)
                {
                    RemoveStep(stepSize);
                }
                else
                {
                    AddStep(stepSize);
                }
            }
            base.OnClicked(controlId, control, actionType);
        }
Пример #23
0
        private bool DisplaySearchDialog(MovieMatch selectedFile)
        {
            GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dialog == null)
            {
                logger.Error("Could not create search dialog.");
                return(false);
            }

            int maxid = 0;

            dialog.Reset();
            dialog.SetHeading(Translation.Search);

            int titleId = ++maxid;

            dialog.Add(string.Format("{0}: {1}", Translation.Title, selectedFile.Signature.Title));

            int yearId = ++maxid;

            dialog.Add(string.Format("{0}: {1}", Translation.Year, selectedFile.Signature.Year));

            int imdbId = ++maxid;

            dialog.Add(string.Format("{0}: {1}", Translation.ImdbId, selectedFile.Signature.ImdbId));

            dialog.DoModal(GUIWindowManager.ActiveWindow);

            // user picked nothing, go back to previous dialog
            if (dialog.SelectedId == -1)
            {
                return(false);
            }

            // build and display our virtual keyboard
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            keyboard.Reset();
            keyboard.IsSearchKeyboard = true;

            if (dialog.SelectedId == titleId)
            {
                keyboard.Text = selectedFile.Signature.Title;
            }
            if (dialog.SelectedId == yearId)
            {
                keyboard.Text = (selectedFile.Signature.Year == null) ? "" : selectedFile.Signature.Year.ToString();
            }
            if (dialog.SelectedId == imdbId)
            {
                keyboard.Text = (selectedFile.Signature.ImdbId == null) ? "" : selectedFile.Signature.ImdbId;
            }
            keyboard.DoModal(GUIWindowManager.ActiveWindow);

            // if the user escaped out redisplay the searchdialog
            if (!keyboard.IsConfirmed)
            {
                return(DisplaySearchDialog(selectedFile));
            }

            // user entered something so update the movie signature
            if (dialog.SelectedId == titleId)
            {
                selectedFile.Signature.Title = keyboard.Text;
            }
            if (dialog.SelectedId == yearId)
            {
                selectedFile.Signature.Year = Convert.ToInt32(keyboard.Text);
            }
            if (dialog.SelectedId == imdbId)
            {
                selectedFile.Signature.ImdbId = keyboard.Text;
            }
            MovingPicturesCore.Importer.Reprocess(selectedFile);

            return(true);
        }
        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;
            }
        }
Пример #25
0
        protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

            if (control == _searchButton)
            {
                _selectedTitleIndex   = 0;
                _selectedProgramIndex = 0;

                if (_rules.Count > 0)
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                    if (dlgYesNo != null)
                    {
                        dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention));
                        dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GetID);
                        if (!dlgYesNo.IsConfirmed)
                        {
                            _rules.Clear();
                            if (_viewsList != null && _viewsList.Count > 0)
                            {
                                _viewsList.Clear();
                            }
                        }
                    }
                }

                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (keyboard != null)
                {
                    keyboard.Reset();
                    keyboard.IsSearchKeyboard = true;
                    keyboard.Text             = String.Empty;
                    keyboard.DoModal(GetID);
                    if (keyboard.IsConfirmed)
                    {
                        if (keyboard.Text == string.Empty)
                        {
                            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                            if (dlgOk != null)
                            {
                                dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                                dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText));
                                dlgOk.DoModal(GetID);
                            }
                        }
                        else
                        {
                            switch (_currentSearchMethod)
                            {
                            case SearchInMethod.Title:
                                _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text);
                                break;

                            case SearchInMethod.Description:
                                _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text);
                                break;

                            case SearchInMethod.ProgramInfo:
                                _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text);
                                break;

                            case SearchInMethod.Actor:
                                _rules.Add(ScheduleRuleType.WithActor, keyboard.Text);
                                break;

                            case SearchInMethod.DirectedBy:
                                _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text);
                                break;
                            }
                            ShowSearchResults(string.Empty);
                        }
                    }
                }
            }
            else if (control == _searchMethodButton)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading(467);
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy));

                dlg.SelectedLabel = (int)_currentSearchMethod;
                // show dialog and wait for result
                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                {
                    return;
                }
                _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel);
                UpdateButtonStates();
            }
            else if (control == _selectChannelsButton)
            {
                List <ChannelGroup> groups         = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType));
                ChannelGroup        _selectedGroup = new ChannelGroup();

                if (groups.Count > 0)
                {
                    if (groups.Count > 1)
                    {
                        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg == null)
                        {
                            return;
                        }

                        dlg.Reset();
                        dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup));
                        foreach (ChannelGroup group in groups)
                        {
                            dlg.Add(group.GroupName);
                        }

                        // show dialog and wait for result
                        dlg.DoModal(GetID);
                        if (dlg.SelectedId == -1)
                        {
                            return;
                        }
                        _selectedGroup = groups[dlg.SelectedId - 1];
                    }
                    else
                    {
                        _selectedGroup = groups[0];
                    }

                    List <Channel> channels = new List <Channel>();
                    if (_channelArguments.Count > 0)
                    {
                        List <Channel> channels2 = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                        foreach (Channel channel in channels2)
                        {
                            if (!_channelArguments.Contains(channel.ChannelId))
                            {
                                channels.Add(channel);
                            }
                        }
                    }
                    else
                    {
                        channels = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                    }

                    if (channels.Count > 0)
                    {
                        GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg2 == null)
                        {
                            return;
                        }

                        dlg2.Reset();
                        dlg2.SetHeading(GetChannelArgumentsString(true));
                        foreach (Channel channel in channels)
                        {
                            dlg2.Add(channel.DisplayName);
                        }

                        // show dialog and wait for result
                        dlg2.DoModal(GetID);
                        if (dlg2.SelectedId == -1)
                        {
                            return;
                        }
                        _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId);
                        UpdateButtonStates();
                    }
                    else
                    {
                        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                        if (dlgOk != null)
                        {
                            dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                            dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd));
                            dlgOk.DoModal(GetID);
                        }
                    }
                }
            }
            else if (control == _selectCategoriesButton)
            {
                List <string> categories  = new List <string>();
                string[]      _categories = new string[0];
                _categories = GuideAgent.GetAllCategories();

                foreach (string categorie in _categories)
                {
                    if (!_categorieArguments.Contains(categorie))
                    {
                        categories.Add(categorie);
                    }
                }

                if (categories.Count > 0)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }

                    dlg.Reset();
                    dlg.SetHeading(GetCategorieArgumentString(true));
                    foreach (string categorie in categories)
                    {
                        dlg.Add(categorie);
                    }

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _categorieArguments.Add(dlg.SelectedLabelText);
                    UpdateButtonStates();
                }
                else
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    if (dlgOk != null)
                    {
                        dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                        dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd));
                        dlgOk.DoModal(GetID);
                    }
                }
            }
            else if (control == _clearButton)
            {
                OnClearRules(true);
                ShowSearchResults(string.Empty);
                UpdateButtonStates();
            }
            else if (control == _sortByButton)
            {
                if (_isInSubDirectory)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(495);         //Sort Options
                    dlg.AddLocalizedString(620); //channel
                    dlg.AddLocalizedString(621); //date
                    dlg.AddLocalizedString(268); //title/name

                    // set the focus to currently used sort method
                    dlg.SelectedLabel = (int)_currentSortMethod;

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _currentSortMethod = (SortMethod)dlg.SelectedLabel;
                    OnSort();
                }
            }
            else if (control == _viewsList)
            {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null);
                OnMessage(msg);
                int iItem = (int)msg.Param1;
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    OnSelectItem(iItem);
                }
                if (actionType == Action.ActionType.ACTION_SHOW_INFO)
                {
                    OnShowContextMenu();
                }
            }
        }
Пример #26
0
        private void OnGlobalMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_NOTIFY:
                ShowNotify(message.Label, message.Label2, message.Label3);
                break;

            case GUIMessage.MessageType.GUI_MSG_ASKYESNO:
                string Head = "", Line1 = "", Line2 = "", Line3 = "", Line4 = "";
                bool   DefaultYes = false;
                if (message.Param1 != 0)
                {
                    Head = GUILocalizeStrings.Get(message.Param1);
                }
                else if (message.Label != string.Empty)
                {
                    Head = message.Label;
                }
                if (message.Param2 != 0)
                {
                    Line1 = GUILocalizeStrings.Get(message.Param2);
                }
                else if (message.Label2 != string.Empty)
                {
                    Line1 = message.Label2;
                }
                if (message.Param3 != 0)
                {
                    Line2 = GUILocalizeStrings.Get(message.Param3);
                }
                else if (message.Label3 != string.Empty)
                {
                    Line2 = message.Label3;
                }
                if (message.Param4 != 0)
                {
                    Line3 = GUILocalizeStrings.Get(message.Param4);
                }
                else if (message.Label4 != string.Empty)
                {
                    Line3 = message.Label4;
                }
                if (message.Object != null && message.Object is int && (int)message.Object != 0)
                {
                    Line4 = GUILocalizeStrings.Get((int)message.Object);
                }
                else if (message.Object != null && message.Object is string && (string)message.Object != string.Empty)
                {
                    Line4 = (string)message.Object;
                }
                if (message.Object2 != null && message.Object2 is bool)
                {
                    DefaultYes = (bool)message.Object2;
                }
                if (AskYesNo(Head, Line1, Line2, Line3, Line4, DefaultYes))
                {
                    message.Param1 = 1;
                }
                else
                {
                    message.Param1 = 0;
                }
                break;

            case GUIMessage.MessageType.GUI_MSG_SHOW_WARNING:
            {
                string strHead = "", strLine1 = "", strLine2 = "";
                if (message.Param1 != 0)
                {
                    strHead = GUILocalizeStrings.Get(message.Param1);
                }
                else if (message.Label != string.Empty)
                {
                    strHead = message.Label;
                }
                if (message.Param2 != 0)
                {
                    strLine1 = GUILocalizeStrings.Get(message.Param2);
                }
                else if (message.Label2 != string.Empty)
                {
                    strLine2 = message.Label2;
                }
                if (message.Param3 != 0)
                {
                    strLine2 = GUILocalizeStrings.Get(message.Param3);
                }
                else if (message.Label3 != string.Empty)
                {
                    strLine2 = message.Label3;
                }
                ShowInfo(strHead, strLine1, strLine2);
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_GET_STRING:
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                if (null == keyboard)
                {
                    return;
                }
                keyboard.Reset();
                keyboard.Text = message.Label;
                keyboard.DoModal(GUIWindowManager.ActiveWindow);
                if (keyboard.IsConfirmed)
                {
                    message.Label = keyboard.Text;
                }
                else
                {
                    message.Label = "";
                }
                break;

            case GUIMessage.MessageType.GUI_MSG_GET_PASSWORD:
                VirtualKeyboard keyboard2 = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                if (null == keyboard2)
                {
                    return;
                }
                keyboard2.Reset();
                keyboard2.Password = true;
                keyboard2.Text     = message.Label;
                keyboard2.DoModal(GUIWindowManager.ActiveWindow);
                if (keyboard2.IsConfirmed)
                {
                    message.Label = keyboard2.Text;
                }
                else
                {
                    message.Label = "";
                }
                break;

            case GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD:
                using (Profile.Settings xmlreader = new Profile.MPSettings()
                       )
                {
                    if (!xmlreader.GetValueAsBool("general", "hidewrongpin", false))
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo == null)
                        {
                            return;
                        }
                        dlgYesNo.SetHeading(771); // The entered PIN could not be accepted
                        dlgYesNo.SetLine(1, 772); // Do you want to try again?
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GetID);
                        message.Object = dlgYesNo.IsConfirmed;
                    }
                    else
                    {
                        message.Object = false;
                    }
                }
                break;
            }
        }
Пример #27
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // we don't want the user to start another search while one is already active
            if (_workerCompleted == false)
            {
                return;
            }

            // Here we want to open the OSD Keyboard to enter the searchstring
            if (control == buttonSearch)
            {
                // If the search Button was clicked we need to bring up the search keyboard.
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                if (null == keyboard)
                {
                    return;
                }
                string searchterm = string.Empty;
                //keyboard.IsSearchKeyboard = true;
                keyboard.Reset();
                keyboard.Text = "";
                keyboard.DoModal(GetID); // show it...

                Log.Info("Wikipedia: OSD keyboard loaded!");

                // If input is finished, the string is saved to the searchterm var.
                if (keyboard.IsConfirmed)
                {
                    searchterm = keyboard.Text;

                    // If there was a string entered try getting the article.
                    if (searchterm != "")
                    {
                        Log.Info("Wikipedia: Searchterm gotten from OSD keyboard: {0}", searchterm);
                        GetAndDisplayArticle(searchterm);
                    }
                    // Else display an error dialog.
                    else
                    {
                        GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                        dlg.SetHeading(GUILocalizeStrings.Get(257));  // Error
                        dlg.SetLine(1, GUILocalizeStrings.Get(2500)); // No searchterm entered!
                        dlg.SetLine(2, string.Empty);
                        dlg.SetLine(3, GUILocalizeStrings.Get(2501)); // Please enter a valid searchterm!
                        dlg.DoModal(GUIWindowManager.ActiveWindow);
                    }
                }
            }
            // This is the control to select the local Wikipedia site.
            if (control == buttonLocal)
            {
                // Create a new selection dialog.
                GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                if (pDlgOK != null)
                {
                    pDlgOK.Reset();
                    pDlgOK.SetHeading(GUILocalizeStrings.Get(2502)); //Select your local Wikipedia:

                    // Add all the local sites we want to be displayed starting with int 0.
                    Settings langreader = new Settings(Config.GetFile(Config.Dir.Config, "wikipedia.xml"));
                    String   allsites   = langreader.GetValueAsString("Allsites", "sitenames", "");
                    Log.Info("Wikipedia: available sites: " + allsites);
                    String[] siteArray = allsites.Split(',');
                    for (int i = 0; i < siteArray.Length; i++)
                    {
                        int stringno = langreader.GetValueAsInt(siteArray[i], "string", 2006);
                        pDlgOK.Add(GUILocalizeStrings.Get(stringno)); //English, German, French ...
                    }

                    pDlgOK.DoModal(GetID);
                    if (pDlgOK.SelectedLabel >= 0)
                    {
                        SelectLocalWikipedia(pDlgOK.SelectedLabel, siteArray);
                    }
                }
            }
            // The Button holding the Links to other articles
            if (control == buttonLinks)
            {
                if (linkArray.Count > 0)
                {
                    // Create a new selection dialog.
                    GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (pDlgOK != null)
                    {
                        pDlgOK.Reset();
                        pDlgOK.SetHeading(GUILocalizeStrings.Get(2505)); //Links to other articles:

                        // Add all the links from the linkarray.
                        foreach (string link in linkArray)
                        {
                            pDlgOK.Add(link);
                        }
                        pDlgOK.DoModal(GetID);
                        if (pDlgOK.SelectedLabel >= 0)
                        {
                            Log.Info("Wikipedia: new search from the links array: {0}", pDlgOK.SelectedLabelText);
                            GetAndDisplayArticle(pDlgOK.SelectedLabelText);
                        }
                    }
                }
                else
                {
                    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    dlg.SetHeading(GUILocalizeStrings.Get(257));  // Error
                    dlg.SetLine(1, GUILocalizeStrings.Get(2506)); // No Links from this article.
                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
            // The Button containing a list of all images from the article
            if (control == buttonImages)
            {
                if (imagedescArray.Count > 0)
                {
                    // Create a new selection dialog.
                    GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (pDlgOK != null)
                    {
                        pDlgOK.Reset();
                        pDlgOK.SetHeading(GUILocalizeStrings.Get(2507)); //Images from this article

                        // Add all the images from the imagearray.
                        foreach (string image in imagedescArray)
                        {
                            pDlgOK.Add(image);
                        }
                        pDlgOK.DoModal(GetID);
                        if (pDlgOK.SelectedLabel >= 0)
                        {
                            Log.Info("Wikipedia: new search from the image array: {0}", imagedescArray[pDlgOK.SelectedId - 1]);
                            GetAndDisplayImage(imagenameArray[pDlgOK.SelectedId - 1].ToString(),
                                               imagedescArray[pDlgOK.SelectedId - 1].ToString());
                        }
                    }
                }
                else
                {
                    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    dlg.SetHeading(GUILocalizeStrings.Get(257));  // Error
                    dlg.SetLine(1, GUILocalizeStrings.Get(2508)); // No Images referenced in this article.
                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
            // Back to the text button to switch from image view
            if (control == buttonBack)
            {
                if (!txtArticle.IsVisible)
                {
                    GUIControl.ShowControl(GetID, txtArticle.GetID);
                }
                if (imageControl.IsVisible)
                {
                    GUIControl.HideControl(GetID, imageControl.GetID);
                }
                if (!searchtermLabel.IsVisible)
                {
                    GUIControl.ShowControl(GetID, searchtermLabel.GetID);
                }
                if (imagedescLabel.IsVisible)
                {
                    GUIControl.HideControl(GetID, imagedescLabel.GetID);
                }
                if (buttonBack.IsVisible)
                {
                    GUIControl.HideControl(GetID, buttonBack.GetID);
                    GUIControl.FocusControl(GetID, buttonSearch.GetID);
                }
            }
            base.OnClicked(controlId, control, actionType);
        }
        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;
            }
        }
Пример #29
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            if (control == buttonReset)
            {
                labelCurrent.Label = DefaultSetting;
                SetCheckMarksBasedOnString(DefaultSetting);
            }
            else if (control == buttonAdd)
            {
                VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD);
                vk.Reset();
                vk.DoModal(GetID);
                string newStep = vk.Text;

                if (string.IsNullOrEmpty(newStep))
                {
                    return;
                }

                string error = verifySkipStep(newStep);

                if (error != null)
                {
                    GUIDialogOK errDialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    errDialog.SetHeading(257);
                    errDialog.SetLine(1, error);
                    errDialog.DoModal(GetID);
                }
                else
                {
                    AddStep(Convert.ToInt16(newStep)); // Already verifed, so no numberformatexception can occur
                }
            }
            else if (control == buttonRemove)
            {
                GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT2);
                dlgSel.Reset();
                dlgSel.SetHeading(200040); // Remove skip step

                foreach (string token in labelCurrent.Label.Split(new char[] { ',', ';', ' ' }))
                {
                    if (token == string.Empty)
                    {
                        continue;
                    }
                    dlgSel.Add(token);
                }

                dlgSel.DoModal(GetID);
                if (dlgSel.SelectedLabel != -1)
                {
                    try
                    {
                        RemoveStep(Convert.ToInt16(dlgSel.SelectedLabelText));
                    }
                    catch (Exception ex)
                    {
                        // Should never happen
                        Log.Error("should never happen {0}", ex.Message);
                    }
                }
            }
            else if (control is GUICheckMarkControl)
            {
                int stepSize = 5;
                if (control == checkMarkButtonStep1)
                {
                    stepSize = 5;
                }
                else if (control == checkMarkButtonStep2)
                {
                    stepSize = 15;
                }
                else if (control == checkMarkButtonStep3)
                {
                    stepSize = 30;
                }
                else if (control == checkMarkButtonStep4)
                {
                    stepSize = 45;
                }
                else if (control == checkMarkButtonStep5)
                {
                    stepSize = 60;
                }
                else if (control == checkMarkButtonStep6)
                {
                    stepSize = 180;
                }
                else if (control == checkMarkButtonStep7)
                {
                    stepSize = 300;
                }
                else if (control == checkMarkButtonStep8)
                {
                    stepSize = 420;
                }
                else if (control == checkMarkButtonStep9)
                {
                    stepSize = 600;
                }
                else if (control == checkMarkButtonStep10)
                {
                    stepSize = 900;
                }
                else if (control == checkMarkButtonStep11)
                {
                    stepSize = 1800;
                }
                else if (control == checkMarkButtonStep12)
                {
                    stepSize = 2700;
                }
                else if (control == checkMarkButtonStep13)
                {
                    stepSize = 3600;
                }
                else if (control == checkMarkButtonStep14)
                {
                    stepSize = 5400;
                }
                else if (control == checkMarkButtonStep15)
                {
                    stepSize = 7200;
                }
                else if (control == checkMarkButtonStep16)
                {
                    stepSize = 10800;
                }

                if (!((GUICheckMarkControl)control).Selected)
                {
                    RemoveStep(stepSize);
                }
                else
                {
                    AddStep(stepSize);
                }
            }
            if (control == btnTimeoutValue)
            {
                int    number;
                string getNumber = _timeOutValue.ToString();
                GetStringFromKeyboard(ref getNumber, -1);

                if (Int32.TryParse(getNumber, out number))
                {
                    _timeOutValue = number;
                }

                SetProperties();
            }
            if (control == btnSkipValue)
            {
                int    number;
                string getNumber = _skipValue.ToString();
                GetStringFromKeyboard(ref getNumber, -1);

                if (Int32.TryParse(getNumber, out number))
                {
                    _skipValue = number;
                }

                SetProperties();
            }
            if (control == btnRelative)
            {
                if (btnRelative.Selected)
                {
                    btnConstant.Selected = false;
                }
                else
                {
                    btnConstant.Selected = true;
                }
            }
            if (control == btnConstant)
            {
                if (btnConstant.Selected)
                {
                    btnRelative.Selected = false;
                }
                else
                {
                    btnRelative.Selected = true;
                }
            }
            base.OnClicked(controlId, control, actionType);
        }
Пример #30
0
        public void ContextMenu(object info)
        {
            WatchItem     watch = info as WatchItem;
            GUIDialogMenu dlg   = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }


            dlg.Reset();
            dlg.SetHeading("Torrent watchlist");
            dlg.Add("Add Series");
            dlg.Add("Search Series");
            dlg.Add("Add Movie");
            dlg.Add("Add custom");
            dlg.Add("Manual Search");
            dlg.Add("Remove selected");
            dlg.Add("Clear list");
            dlg.Add("Force RSS update");
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            switch (dlg.SelectedLabelText)
            {
            case "Add Series":
            {
                AddSeries();
                MyTorrents.Instance().ShowTorrentWatch();
                break;
            }

            case "Search Series":
            {
                SearchSeries();
            }
            break;

            case "Add Movie":
                break;

            case "Manual Search":
                MyTorrents.Instance()._torrentWatchlist.SearchTorrent();
                break;

            case "Add custom":
            {
                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                keyboard.Reset();
                keyboard.Text = "";
                keyboard.DoModal(GUIWindowManager.ActiveWindow);

                if (!keyboard.IsConfirmed)
                {
                    return;
                }

                watch            = new WatchItem();
                watch.SearchTerm = keyboard.Text;

                TorrentLabel label = DialogAskLabel.Ask();
                if (label != null)
                {
                    watch.Label = label.Name;
                    MyTorrents.Instance()._torrentWatchlist.AddWatch(watch);
                    Log.Instance().Print(String.Format("Watch [{0}] added.", watch.SearchTerm));
                }
                break;
            }

            case "Clear list":
            {
                MyTorrents.Instance()._torrentWatchlist.Clear();
                break;
            }

            case "Remove selected":
            {
                MyTorrents.Instance()._torrentWatchlist.RemoveWatch(watch);
                // torrentList.RemoveItem(torrentList.SelectedListItemIndex);
                break;
            }

            case "Force RSS update":
            {
                RSSChannelManager.Instance().UpdateChannels(true);
                break;
            }
            }

            MyTorrents.Instance().ShowTorrentWatch();
        }