예제 #1
0
        private void OnRestoreDefaults()
        {
            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            if (dlgYesNo != null)
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(927);
                dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.RestoreDefaults));
                dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                dlgYesNo.SetLine(3, string.Empty);
                dlgYesNo.SetDefaultToYes(false);
                dlgYesNo.DoModal(GetID);

                if (dlgYesNo.IsConfirmed)
                {
                    Proxies.ConfigurationService.SetBooleanValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.CreateVideoThumbnails, null).Wait();
                    Proxies.ConfigurationService.SetBooleanValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.AlwaysCreateMetadataFiles, null).Wait();
                    Proxies.ConfigurationService.SetStringValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.PreferredGuideSource, null).Wait();
                    Proxies.ConfigurationService.SetIntValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.PreRecordsSeconds, null).Wait();
                    Proxies.ConfigurationService.SetIntValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.PostRecordsSeconds, null).Wait();
                    Proxies.ConfigurationService.SetStringValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.DefaultKeepUntilMode, null).Wait();
                    Proxies.ConfigurationService.SetIntValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.DefaultKeepUntilValue, null).Wait();
                    Proxies.ConfigurationService.SetIntValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.FreeDiskSpaceInMB, null).Wait();
                    Proxies.ConfigurationService.SetIntValue(ConfigurationModule.Scheduler, ConfigurationKey.Scheduler.MinimumFreeDiskSpaceInMB, null).Wait();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Displays a yes/no dialog with custom labels for the buttons.
        /// This method may become obsolete in the future if media portal adds more dialogs.
        /// </summary>
        /// <returns>True if yes was clicked, False if no was clicked</returns>
        public static bool ShowCustomYesNoDialog(string heading, string lines, string yesLabel, string noLabel, bool defaultYes)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                ShowCustomYesNoDialogDelegate d = ShowCustomYesNoDialog;
                return((bool)GUIGraphicsContext.form.Invoke(d, heading, lines, yesLabel, noLabel, defaultYes));
            }

            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            try
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(heading);
                string[] linesArray = lines.Split(new string[] { "\\n", "\n" }, StringSplitOptions.None);
                if (linesArray.Length > 0)
                {
                    dlgYesNo.SetLine(1, linesArray[0]);
                }
                if (linesArray.Length > 1)
                {
                    dlgYesNo.SetLine(2, linesArray[1]);
                }
                if (linesArray.Length > 2)
                {
                    dlgYesNo.SetLine(3, linesArray[2]);
                }
                if (linesArray.Length > 3)
                {
                    dlgYesNo.SetLine(4, linesArray[3]);
                }
                dlgYesNo.SetDefaultToYes(defaultYes);

                foreach (GUIControl item in dlgYesNo.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 11 && !string.IsNullOrEmpty(yesLabel)) // Yes button
                        {
                            btn.Label = yesLabel;
                        }
                        else if (btn.GetID == 10 && !string.IsNullOrEmpty(noLabel)) // No button
                        {
                            btn.Label = noLabel;
                        }
                    }
                }
                dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                return(dlgYesNo.IsConfirmed);
            }
            finally
            {
                // set the standard yes/no dialog back to it's original state (yes/no buttons)
                if (dlgYesNo != null)
                {
                    dlgYesNo.ClearAll();
                }
            }
        }
예제 #3
0
 private void OnClearRules(bool withDialog)
 {
     if (_categorieArguments.Count > 0 || _channelArguments.Count > 0)
     {
         if (withDialog)
         {
             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.AlsoDeleteChannelAndCategorie));
                 dlgYesNo.SetLine(2, string.Empty);
                 dlgYesNo.SetLine(3, string.Empty);
                 dlgYesNo.SetDefaultToYes(true);
                 dlgYesNo.DoModal(GetID);
                 if (dlgYesNo.IsConfirmed)
                 {
                     _categorieArguments.Clear();
                     _channelArguments.Clear();
                 }
             }
         }
         else
         {
             _categorieArguments.Clear();
             _channelArguments.Clear();
         }
     }
     _rules.Clear();
 }
예제 #4
0
        public bool IsStillListening()
        {
            logger.Debug("Idle Time: " + (DateTime.Now - lastButtonPress) + " / " + Core.MusicBox.User.TimeoutInterval);
            if (DateTime.Now - lastButtonPress < Core.MusicBox.User.TimeoutInterval)
            {
                return(true);
            }

            GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            dialog.Reset();
            dialog.SetHeading("Pandora");
            dialog.SetLine(1, "We pay for each song we play so we try");
            dialog.SetLine(2, "not to play to an empty room.");
            dialog.SetLine(3, " ");
            dialog.SetLine(4, "Are you still listening?");
            dialog.SetDefaultToYes(true);
            dialog.DoModal(GetID);

            if (dialog.IsConfirmed)
            {
                lastButtonPress = DateTime.Now;
                return(true);
            }

            return(false);
        }
예제 #5
0
        private bool AskYesNo(string strHeading, string strLine1, string strLine2, string strLine3, string strLine4, bool defaultYes)
        {
            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);

            dlgYesNo.SetHeading(strHeading);
            dlgYesNo.SetLine(1, strLine1);
            dlgYesNo.SetLine(2, strLine2);
            dlgYesNo.SetLine(3, strLine3);
            dlgYesNo.SetLine(4, strLine4);
            dlgYesNo.SetDefaultToYes(defaultYes);
            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
            return(dlgYesNo.IsConfirmed);
        }
예제 #6
0
        /// <summary>
        /// Displays a yes/no dialog with custom labels for the buttons
        /// This method may become obsolete in the future if media portal adds more dialogs
        /// </summary>
        /// <returns>True if yes was clicked, False if no was clicked</returns>
        /// This has been taken (stolen really) from the wonderful MovingPictures Plugin -Anthrax.
        public bool ShowCustomYesNo(int parentWindowID, string heading, string lines, string yesLabel, string noLabel, bool defaultYes)
        {
            GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            try {
                dialog.Reset();
                dialog.SetHeading(heading);
                string[] linesArray = lines.Split(new string[] { "\\n" }, StringSplitOptions.None);
                if (linesArray.Length > 0)
                {
                    dialog.SetLine(1, linesArray[0]);
                }
                if (linesArray.Length > 1)
                {
                    dialog.SetLine(2, linesArray[1]);
                }
                if (linesArray.Length > 2)
                {
                    dialog.SetLine(3, linesArray[2]);
                }
                if (linesArray.Length > 3)
                {
                    dialog.SetLine(4, linesArray[3]);
                }
                dialog.SetDefaultToYes(defaultYes);

                foreach (var item in dialog.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 11 && !String.IsNullOrEmpty(yesLabel)) // Yes button
                        {
                            btn.Label = yesLabel;
                        }
                        else if (btn.GetID == 10 && !String.IsNullOrEmpty(noLabel)) // No button
                        {
                            btn.Label = noLabel;
                        }
                    }
                }
                dialog.DoModal(parentWindowID);
                return(dialog.IsConfirmed);
            } finally {
                // set the standard yes/no dialog back to it's original state (yes/no buttons)
                if (dialog != null)
                {
                    dialog.ClearAll();
                }
            }
        }
        private void SearchVideo(string searchString)
        {
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            query = SetParamToYouTubeQuery(query, false);
            //query.VQ = searchString;
            query.Query   = searchString;
            query.OrderBy = "relevance";

            YouTubeFeed vidr = service.Query(query);

            foreach (AtomLink link in vidr.Links)
            {
                if (link.Rel == "http://schemas.google.com/g/2006#spellcorrection")
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
                    if (null == dlgYesNo)
                    {
                        return;
                    }
                    dlgYesNo.SetHeading("Did you mean ?"); //resume movie?
                    dlgYesNo.SetLine(1, link.Title);
                    dlgYesNo.SetDefaultToYes(true);
                    dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                    if (dlgYesNo.IsConfirmed)
                    {
                        SearchVideo(link.Title);
                        return;
                    }
                }
            }

            if (vidr.Entries.Count > 0)
            {
                SaveListState(true);
                addVideos(vidr, false, query);
                UpdateGui();
                if (_setting.SearchHistory.Contains(searchString.Trim()))
                {
                    _setting.SearchHistory.Remove(searchString.Trim());
                }
                _setting.SearchHistory.Add(searchString.Trim());
            }
            else
            {
                Err_message("No item was found !");
            }
        }
예제 #8
0
        public bool ResumeOrPlay(VM_VideoLocal fileToPlay)
        {
            try
            {
                curEpisode = null;


                if (fileToPlay.IsLocalOrStreaming() == null)
                {
                    Utils.DialogMsg("Error", "File could not be found!");
                    return(false);
                }
                current = fileToPlay;

                BaseConfig.MyAnimeLog.Write("Getting time stopped for : {0}", fileToPlay.FileName);
                BaseConfig.MyAnimeLog.Write("Time stopped for : {0} - {1}", fileToPlay.FileName, fileToPlay.ResumePosition / 1000);


                #region Ask user to Resume
                _timeMovieStopped = (int)(fileToPlay.ResumePosition / 1000);
                if (_timeMovieStopped > 0)
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                    if (null != dlgYesNo)
                    {
                        dlgYesNo.SetHeading(GUILocalizeStrings.Get(900));                         //resume movie?
                        dlgYesNo.SetLine(1, fileToPlay.FileName);
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + MediaPortal.Util.Utils.SecondsToHMSString(TimeSpan.FromMilliseconds(fileToPlay.ResumePosition)));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                        if (!dlgYesNo.IsConfirmed)                         // reset resume data in DB
                        {
                            _timeMovieStopped = 0;
                        }
                    }
                }
                #endregion

                Play(_timeMovieStopped, fileToPlay.DefaultAudioLanguage, fileToPlay.DefaultSubtitleLanguage);
                return(true);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Error inResumeOrPlay : {0}", ex.ToString());
            }
            return(false);
        }
예제 #9
0
        public bool ResumeOrPlay(VideoLocalVM fileToPlay)
        {
            try
            {
                curEpisode = null;

                int timeMovieStopped = 0;
                if (!File.Exists(fileToPlay.FullPath))
                {
                    Utils.DialogMsg("Error", "File could not be found!");
                    return(false);
                }

                BaseConfig.MyAnimeLog.Write("Getting time stopped for : {0}", fileToPlay.FullPath);
                timeMovieStopped = GetTimeStopped(fileToPlay.FullPath);
                BaseConfig.MyAnimeLog.Write("Time stopped for : {0} - {1}", fileToPlay.FullPath, timeMovieStopped);

                curFileName = fileToPlay.FullPath;

                #region Ask user to Resume
                if (timeMovieStopped > 0)
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                    if (null != dlgYesNo)
                    {
                        dlgYesNo.SetHeading(GUILocalizeStrings.Get(900));                         //resume movie?
                        dlgYesNo.SetLine(1, fileToPlay.FileName);
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + MediaPortal.Util.Utils.SecondsToHMSString(timeMovieStopped));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                        if (!dlgYesNo.IsConfirmed)                         // reset resume data in DB
                        {
                            timeMovieStopped = 0;
                        }
                    }
                }
                #endregion

                Play(timeMovieStopped, fileToPlay.DefaultAudioLanguage, fileToPlay.DefaultSubtitleLanguage);
                return(true);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Error inResumeOrPlay : {0}", ex.ToString());
            }
            return(false);
        }
예제 #10
0
        protected override void OnPageDestroy(int new_windowId)
        {
            SaveSettings(false);
            GUIWaitCursor.Hide();

            if (_mpRestartNeeded)
            {
                GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
                if (dlgYesNo != null)
                {
                    dlgYesNo.Reset();
                    dlgYesNo.SetHeading(927);
                    dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.RecommendedToRestartMP));
                    dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.RestartMPNow));
                    dlgYesNo.SetDefaultToYes(true);
                    dlgYesNo.DoModal(GetID);

                    if (dlgYesNo.IsConfirmed)
                    {
                        Utility.RestartMP();
                    }
                }
            }
            else if (_restartPlayerNeeded)
            {
                if (g_Player.Playing && (g_Player.IsTV || g_Player.IsRadio || g_Player.IsTVRecording))
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);
                    if (dlgYesNo != null)
                    {
                        dlgYesNo.Reset();
                        dlgYesNo.SetHeading(927);
                        dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.RecommendedToStopPlayback));
                        dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.StopPlayBackNow));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GetID);

                        if (dlgYesNo.IsConfirmed)
                        {
                            g_Player.Stop();
                        }
                    }
                }
            }
            base.OnPageDestroy(new_windowId);
        }
예제 #11
0
        private bool SelectYesNo(string label)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO);

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

            dlg.SetHeading(196);
            dlg.SetLine(1, label);
            dlg.SetYesLabel(GUILocalizeStrings.Get(186)); //OK
            dlg.SetNoLabel(GUILocalizeStrings.Get(222));  //Cancel
            dlg.SetDefaultToYes(true);
            dlg.DoModal(GUIWindowManager.ActiveWindow);

            return(dlg.IsConfirmed);
        }
예제 #12
0
        private void OnDeleteAllGuideData()
        {
            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            if (dlgYesNo != null)
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(927);
                dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteAllGuideData));
                dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                dlgYesNo.SetLine(3, string.Empty);
                dlgYesNo.SetDefaultToYes(false);
                dlgYesNo.DoModal(GetID);

                if (dlgYesNo.IsConfirmed)
                {
                    Proxies.GuideService.DeleteAllPrograms().Wait();
                }
            }
        }
예제 #13
0
        private bool OnDeleteChannel(Channel channel)
        {
            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            if (dlgYesNo != null)
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(channel.DisplayName);
                dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteChannel));
                dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                dlgYesNo.SetLine(3, string.Empty);
                dlgYesNo.SetDefaultToYes(false);
                dlgYesNo.DoModal(GetID);

                if (dlgYesNo.IsConfirmed)
                {
                    Proxies.SchedulerService.DeleteChannel(channel.ChannelId, true).Wait();
                    return(true);
                }
            }
            return(false);
        }
예제 #14
0
        public bool ResumeOrPlay(DBEpisode episode)
        {
            try
            {
                MPTVSeriesLog.Write("Attempting to play: ", episode[DBEpisode.cFilename].ToString(), MPTVSeriesLog.LogLevel.Debug);
                // don't have this file !
                if (episode[DBEpisode.cFilename].ToString().Length == 0)
                {
                    return(false);
                }

                // check that we are not playing an episode out of episode if unwatched
                // ignore specials as they can be pretty out of wack!
                #region PlayBack Order

                // check sort order so our check is accurate
                var  series       = Helper.getCorrespondingSeries(episode[DBOnlineEpisode.cSeriesID]);
                bool dvdSortOrder = series[DBOnlineSeries.cEpisodeSortOrder] == "DVD";

                string seasonField  = dvdSortOrder ? DBOnlineEpisode.cCombinedSeason : DBOnlineEpisode.cSeasonIndex;
                string episodeField = dvdSortOrder ? DBOnlineEpisode.cCombinedEpisodeNumber : DBOnlineEpisode.cEpisodeIndex;

                if (DBOption.GetOptions(DBOption.cCheckPlayOutOfOrder) && !episode[DBOnlineEpisode.cWatched] && episode[seasonField] > 0 && episode[episodeField] > 1)
                {
                    // first get the next unwatched episode from previously played
                    // we are only interested in current season (could be multi-user watching multiple seasons)
                    // API for GetNextUnwatched is not desirable as that works from Date Watched, we only care about watched here
                    var conditions = new SQLCondition();
                    conditions.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, episode[DBOnlineSeries.cSeriesID], SQLConditionType.Equal);
                    conditions.Add(new DBOnlineEpisode(), seasonField, episode[seasonField], SQLConditionType.Equal);
                    conditions.Add(new DBOnlineEpisode(), episodeField, episode[episodeField], SQLConditionType.LessThan);
                    conditions.Add(new DBOnlineEpisode(), episodeField, 0, SQLConditionType.GreaterThan);
                    var episodes = DBEpisode.Get(conditions, false);

                    if (episodes != null && episodes.Count > 0)
                    {
                        // set logical playback order based on sort order
                        episodes.Sort();

                        // if the previous found episode is not watched then we are playing out of order
                        // if we have a gap in episode collection then assume it has not been watched (this check is needed when user does not download all episode info)
                        if (!episodes.Last()[DBOnlineEpisode.cWatched] || (episode[episodeField] - episodes.Last()[episodeField]) > 1)
                        {
                            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                            dlgYesNo.SetHeading(Translation.Warning);
                            dlgYesNo.SetLine(1, Translation.PlaybackOutOfOrderLine1);
                            dlgYesNo.SetLine(2, string.Format("{0} - {1}x{2}", series.ToString(), episode[seasonField], episode[episodeField] - 1));
                            dlgYesNo.SetLine(3, Translation.PlaybackOutOfOrderLine2);
                            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                            if (!dlgYesNo.IsConfirmed)
                            {
                                return(false);
                            }
                        }
                    }
                }
                #endregion

                m_previousEpisode = m_currentEpisode;
                m_currentEpisode  = episode;
                int timeMovieStopped = m_currentEpisode[DBEpisode.cStopTime];

                // Check if file is an Image e.g. ISO
                string filename = m_currentEpisode[DBEpisode.cFilename];
                m_bIsImageFile = Helper.IsImageFile(filename);

                #region Invoke Before Playback
                // see if we have an invokeOption set up
                string invoke = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlayback);
                if (!string.IsNullOrEmpty(invoke))
                {
                    string invokeArgs = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackArgs);
                    try
                    {
                        // replace any placeholders in the arguments for the script if any have been supplied.
                        if (!string.IsNullOrEmpty(invokeArgs))
                        {
                            invokeArgs = FieldGetter.resolveDynString(invokeArgs, m_currentEpisode, true);
                        }
                        invoke = FieldGetter.resolveDynString(invoke, m_currentEpisode, true);

                        // use ProcessStartInfo instead of Process.Start(string) as latter produces a "cannot find file"
                        // error if you pass in command line arguments.
                        // also allows us to run the script hidden, preventing, for example, a command prompt popping up.
                        ProcessStartInfo psi = new ProcessStartInfo(invoke, invokeArgs);
                        psi.WindowStyle = ProcessWindowStyle.Hidden;
                        Process proc = System.Diagnostics.Process.Start(psi);
                        MPTVSeriesLog.Write(string.Format("Sucessfully Invoked BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs));

                        // if not present in database this evaluates to false. If present and not a valid bool then
                        // it evaluates to true
                        bool waitForExit = (bool)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackWaitForExit);

                        // if true this thread will wait for the external user script to complete before continuing.
                        if (waitForExit)
                        {
                            proc.WaitForExit();
                        }
                    }
                    catch (Exception e)
                    {
                        MPTVSeriesLog.Write(string.Format("Unable to Invoke BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs));
                        MPTVSeriesLog.Write(e.Message);
                    }
                }
                #endregion

                #region Removable Media Handling
                if (!File.Exists(m_currentEpisode[DBEpisode.cFilename]))
                {
                    string episodeVolumeLabel = m_currentEpisode[DBEpisode.cVolumeLabel].ToString();

                    if (string.IsNullOrEmpty(episodeVolumeLabel))
                    {
                        episodeVolumeLabel = LocalParse.getImportPath(m_currentEpisode[DBEpisode.cFilename]);
                    }

                    // ask the user to input cd/dvd, usb disk or confirm network drive is connected
                    GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                    if (null == dlgOK)
                    {
                        return(false);
                    }
                    dlgOK.SetHeading(Translation.insertDisk);
                    dlgOK.SetLine(1, Translation.InsertDiskMessage1);
                    dlgOK.SetLine(2, Translation.InsertDiskMessage2);
                    dlgOK.SetLine(3, Translation.InsertDiskMessage3);
                    dlgOK.SetLine(4, string.Format(Translation.InsertDiskMessage4, episodeVolumeLabel));
                    dlgOK.DoModal(GUIWindowManager.ActiveWindow);

                    if (!File.Exists(m_currentEpisode[DBEpisode.cFilename]))
                    {
                        return(false); // still not found, return to list
                    }
                }
                #endregion

                #region Ask user to Resume

                // skip this if we are using an External Player
                bool bExternalPlayer = m_bIsImageFile ? m_bIsExternalDVDPlayer : m_bIsExternalPlayer;

                if (timeMovieStopped > 0 && !bExternalPlayer)
                {
                    MPTVSeriesLog.Write("Asking user to resume episode from: " + Utils.SecondsToHMSString(timeMovieStopped));
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                    if (null != dlgYesNo)
                    {
                        dlgYesNo.SetHeading(Translation.ResumeEpisode);
                        dlgYesNo.SetLine(1, m_currentEpisode.onlineEpisode.CompleteTitle);
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + Utils.SecondsToHMSString(timeMovieStopped));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                        // reset resume data in DB
                        if (!dlgYesNo.IsConfirmed)
                        {
                            timeMovieStopped = 0;
                            m_currentEpisode[DBEpisode.cStopTime] = timeMovieStopped;
                            m_currentEpisode.Commit();
                            MPTVSeriesLog.Write("User selected to start episode from beginning", MPTVSeriesLog.LogLevel.Debug);
                        }
                        else
                        {
                            MPTVSeriesLog.Write("User selected to resume episode", MPTVSeriesLog.LogLevel.Debug);

                            // dont scrobble first of double episode if resuming past halfway
                            double duration = m_currentEpisode[DBEpisode.cLocalPlaytime];
                        }
                    }
                }

                #endregion

                Play(timeMovieStopped);
                return(true);
            }
            catch (Exception e)
            {
                MPTVSeriesLog.Write("TVSeriesPlugin.VideoHandler.ResumeOrPlay()\r\n" + e.ToString());
                return(false);
            }
        }
예제 #15
0
        public void TorrentsContextMenu(Torrent uTorrent)
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading("Torrent details menu");
            if (uTorrent.Started())
            {
                dlg.Add("Stop");
            }
            else
            {
                dlg.Add("Start");
            }

            if (uTorrent.Paused())
            {
                dlg.Add("Resume");
            }
            else
            {
                dlg.Add("Pause");
            }


            dlg.Add("Remove");
            dlg.Add("Start All");
            dlg.Add("Stop All");
            dlg.Add("Pause All");
            dlg.Add("Resume All");

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            Menu menu = new Menu();

            switch (dlg.SelectedLabelText)
            {
            case "Start":
            {
                TorrentEngine.Instance().TorrentSession.Start(uTorrent.Hash);;
                break;
            };

            case "Stop":
            {
                TorrentEngine.Instance().TorrentSession.Stop(uTorrent.Hash);;
                break;
            };

            case "Resume":
            {
                TorrentEngine.Instance().TorrentSession.Resume(uTorrent.Hash);
                break;
            };

            case "Pause":
            {
                TorrentEngine.Instance().TorrentSession.Pause(uTorrent.Hash);
                break;
            };

            case "Remove":
            {
                GUIDialogYesNo ask = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                ask.Reset();
                ask.SetHeading("Remove also files?");
                ask.SetLine(1, "Files are removed permanently.");
                ask.SetLine(2, "Cannot be undone.");
                ask.SetDefaultToYes(false);
                ask.DoModal(GUIWindowManager.ActiveWindow);

                if (ask.IsConfirmed)
                {
                    TorrentEngine.Instance().TorrentSession.Remove(uTorrent.Hash, true);
                }
                else
                {
                    TorrentEngine.Instance().TorrentSession.Remove(uTorrent.Hash, false);
                }
                break;
            };

            case "Start All":
            {
                TorrentEngine.Instance().TorrentSession.Start(TorrentEngine.Instance().TorrentSession.TorrentsAll);
                break;
            };

            case "Stop All":
            {
                TorrentEngine.Instance().TorrentSession.Stop(TorrentEngine.Instance().TorrentSession.TorrentsAll);
                break;
            };

            case "Pause All":
            {
                TorrentEngine.Instance().TorrentSession.Pause(TorrentEngine.Instance().TorrentSession.TorrentsAll);
                break;
            };

            case "Resume All":
            {
                TorrentEngine.Instance().TorrentSession.Resume(TorrentEngine.Instance().TorrentSession.TorrentsAll);
                break;
            };
            }
        }
예제 #16
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;
            }
        }
예제 #17
0
        /// <summary>
        /// Initiates Playback of m_currentEpisode[DBEpisode.cFilename] and calls Fullscreen Window
        /// </summary>
        /// <param name="timeMovieStopped">Resumepoint of Movie, 0 or negative for Start from Beginning</param>
        /// <param name="audioLanguage">Audio language to be used, use null for system default</param>
        /// <param name="subLanguage">Subtitle language to be used, use null for system default or an empty string for no subs</param>
        ///
        bool Play(int timeMovieStopped, String audioLanguage, String subLanguage)
        {
            bool result = false;

            try
            {
                // sometimes it takes up to 30+ secs to go to fullscreen even though the video is already playing
                // lets force fullscreen here
                // note: MP might still be unresponsive during this time, but at least we are in fullscreen and can see video should this happen
                // I haven't actually found out why it happens, but I strongly believe it has something to do with the video database and the player doing something in the background
                // (why does it do anything with the video database.....i just want it to play a file and do NOTHING else!)

                // TEMPORARY FIX
                // If file isn't local show dialog and return as streaming isn't fully working yet
                if (current.IsLocalOrStreaming() == true)
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                    dlgOk.SetHeading(Translation.FileNotFoundLocally);
                    dlgOk.SetLine(1, Translation.StreamingNotSupported);
                    dlgOk.SetLine(2, current.FileName);

                    if (dlgOk.IsConfirmed)
                    {
                        return(false);
                    }
                    return(false);
                }

                if (current.IsLocalOrStreaming() == true)
                {
                    if (BaseConfig.Settings.AskBeforeStartStreamingPlayback)
                    {
                        GUIDialogYesNo dlgYesNo =
                            (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                        if (null != dlgYesNo)
                        {
                            dlgYesNo.SetHeading(Translation.UseStreaming);
                            dlgYesNo.SetLine(1, Translation.FileNotFoundLocally);
                            dlgYesNo.SetLine(2, current.FileName);
                            dlgYesNo.SetDefaultToYes(true);
                            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);

                            if (!dlgYesNo.IsConfirmed)
                            {
                                return(false);
                            }
                        }
                    }

                    GUIGraphicsContext.IsFullScreenVideo = true;
                    GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);

                    // Start Listening to any External Player Events
                    listenToExternalPlayerEvents = true;
                    CreateSubsOnTempIfNecesary(current.Media);

                    IPlayerFactory prevfactory = g_Player.Factory;
                    g_Player.Factory = PlayerFactory.Instance;

                    timeMovieStopped = 0;

                    //FIX MEDIAPORTAL 1 Bug checking for mediainfo.
                    g_Player._mediaInfo = new MediaInfoWrapper("donoexists");
                    //************************//
                    currentUri       = current.Uri;
                    g_Player.Factory = prevfactory;
                }
                else
                {
                    GUIGraphicsContext.IsFullScreenVideo = true;
                    GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);

                    // Start Listening to any External Player Events
                    listenToExternalPlayerEvents = true;
                    currentUri = current.Uri;
                }

                if (string.IsNullOrEmpty(current.Uri))
                {
                    return(false);
                }

                g_Player.Play(current.Uri, g_Player.MediaType.Video);

                // Stop Listening to any External Player Events
                listenToExternalPlayerEvents = false;

                //set properties
                if (g_Player.Playing)
                {
                    g_Player.Pause();

                    //set audio language
                    if (string.IsNullOrEmpty(audioLanguage))
                    {
                        audioLanguage = DefaultAudioLanguage;
                    }
                    if (audioLanguage != "<file>")
                    {
                        string requestedLanguage = MediaPortal.Util.Utils.TranslateLanguageString(audioLanguage);
                        for (int index = 0; index < g_Player.AudioStreams; index++)
                        {
                            string lang = g_Player.AudioLanguage(index);
                            if (MediaPortal.Util.Utils.TranslateLanguageString(lang)
                                .Equals(requestedLanguage, StringComparison.OrdinalIgnoreCase))
                            {
                                g_Player.Player.CurrentAudioStream = index;
                                break;
                            }
                        }
                    }

                    //set sub language
                    g_Player.Player.EnableSubtitle = true;
                    if (string.IsNullOrEmpty(subLanguage))
                    {
                        subLanguage = DefaultSubtitleLanguage;
                    }
                    if (subLanguage == "<none>")
                    {
                        //no subs
                        g_Player.Player.EnableSubtitle = false;
                    }
                    else if (subLanguage != "<file>")
                    {
                        //selected sub
                        string requestedLanguage = MediaPortal.Util.Utils.TranslateLanguageString(subLanguage);
                        for (int index = 0; index < g_Player.SubtitleStreams; index++)
                        {
                            string lang = g_Player.SubtitleLanguage(index);
                            if (MediaPortal.Util.Utils.TranslateLanguageString(lang)
                                .Equals(requestedLanguage, StringComparison.OrdinalIgnoreCase))
                            {
                                g_Player.Player.CurrentSubtitleStream = index;
                                break;
                            }
                        }
                    }

                    // tell player where to resume
                    if (timeMovieStopped > 0)
                    {
                        g_Player.SeekAbsolute(timeMovieStopped);
                    }

                    if (curEpisode != null)
                    {
                        curEpisode.IncrementEpisodeStats(Shoko.Models.Enums.StatCountType.Played);
                    }

                    g_Player.Pause();

                    traktScrobbleEnabled = true;
                    Thread t = new Thread(TraktScrobbleThread);
                    t.IsBackground = true;
                    t.Start();
                }
            }
            catch (Exception e)
            {
                BaseConfig.MyAnimeLog.Write("Error in VideoHandler.Play: {0}", e);
                result = false;
            }
            return(result);
        }
예제 #18
0
        public bool ResumeOrPlay(VM_AnimeEpisode_User episode)
        {
            try
            {
                // get the list if FileLocal records for this AnimeEpisode
                List <VM_VideoDetailed> fileLocalList = episode.FilesForEpisode;

                if (fileLocalList.Count == 0)
                {
                    return(false);
                }
                VM_VideoDetailed fileToPlay = null;
                if (fileLocalList.Count == 1)
                {
                    fileToPlay = fileLocalList[0];
                }
                else
                {
                    // ask the user which file they want to play
                    IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    dlg.Reset();
                    dlg.SetHeading("Select File");
                    GUIListItem pItem = null;

                    foreach (VM_VideoDetailed fl in fileLocalList)
                    {
                        pItem = new GUIListItem(fl.FileSelectionDisplay);
                        dlg.Add(pItem);
                    }

                    dlg.DoModal(GUIWindowManager.ActiveWindow);

                    if (dlg.SelectedId > 0)
                    {
                        fileToPlay = fileLocalList[dlg.SelectedId - 1];
                    }
                }

                if (fileToPlay == null)
                {
                    return(false);
                }
                previous    = current;
                previousUri = currentUri;
                current     = fileToPlay;
                BaseConfig.MyAnimeLog.Write("Filetoplay: {0}", fileToPlay.FileName);


                if (!fileToPlay.IsLocalOrStreaming() == null)
                {
                    Utils.DialogMsg("Error", "File could not be found!");
                    return(false);
                }
                BaseConfig.MyAnimeLog.Write("Getting time stopped for : {0}", fileToPlay.FileName);
                _timeMovieStopped = (int)(fileToPlay.VideoLocal_ResumePosition / 1000);
                BaseConfig.MyAnimeLog.Write("Time stopped for : {0} - {1}", fileToPlay.FileName, _timeMovieStopped);

                prevEpisode = curEpisode;
                curEpisode  = episode;



                #region Ask user to Resume
                if (_timeMovieStopped > 0)
                {
                    //MPTVSeriesLog.Write("Asking user to resume episode from: " + Utils.SecondsToHMSString(timeMovieStopped));
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                    if (null != dlgYesNo)
                    {
                        dlgYesNo.SetHeading(GUILocalizeStrings.Get(900)); //resume movie?
                        dlgYesNo.SetLine(1, episode.EpisodeName);
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + MediaPortal.Util.Utils.SecondsToHMSString(_timeMovieStopped));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                        if (!dlgYesNo.IsConfirmed) // reset resume data in DB
                        {
                            _timeMovieStopped = 0;
                            //MPTVSeriesLog.Write("User selected to start episode from beginning", MPTVSeriesLog.LogLevel.Debug);
                        }
                    }
                }
                #endregion



                Play(_timeMovieStopped, curEpisode.DefaultAudioLanguage, curEpisode.DefaultSubtitleLanguage);
                return(true);
            }
            catch (Exception e)
            {
                BaseConfig.MyAnimeLog.Write("ResumeOrPlay: {0}", e.ToString());
                return(false);
            }
        }
예제 #19
0
        public bool Scrobble(string filename)
        {
            StopScrobble();
            istStoppingScrobble = false;

            if (!g_Player.IsTV)
            {
                return(false);
            }

            EbasicHandler.setCurrentProgram(GetCurrentProgram());

            if (EbasicHandler.getCurrentProgram() == null)
            {
                return(false);
            }
            EbasicHandler.SetCurrentProgramIsScrobbling(true);

            TVJustTurnedOn = true;
            if (EbasicHandler.getCurrentProgramType() == VideoType.Series)
            {
                TraktLogger.Info("Detected tv show playing on Live TV. Title = '{0}'", EbasicHandler.getCurrentProgram().Title.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie playing on Live TV. Title = '{0}'", EbasicHandler.getCurrentProgram().Title.ToString());
            }

            #region Scrobble Timer

            TraktTimer = new Timer(new TimerCallback((stateInfo) =>
            {
                Thread.CurrentThread.Name = "Scrobble";

                // get the current program airing on tv now
                // this may have changed since last status update on trakt
                EVideoInfo videoInfo = GetCurrentProgram();

                //Reinit all variables
                item     = new TraktEPGCacheRecord();
                response = new TraktScrobbleResponse();

                // I have problems with GUI rendering most of the times. If i set the thread to sleep it really helps with GUI rendering.
                // This might also work well to handle zapping correctly.
                Thread.Sleep((TraktSettings.ETVScrobbleDelay) * 1000);

                try
                {
                    if (videoInfo != null)
                    {
                        // if we are watching something different,
                        // check if we should mark previous as watched
                        //if (!videoInfo.Equals(CurrentProgram))

                        if (!videoInfo.Equals(EbasicHandler.getCurrentProgram()))
                        {
                            TraktLogger.Info("Detected new tv program has started. Previous Program = '{0}', New Program = '{1}'", EbasicHandler.getCurrentProgram().ToString(), videoInfo.ToString());
                            //The new program has changed. I should check if the active window is GUIShowSelect and eventually close it.
                            if (GUIWindowManager.ActiveWindow.Equals((int)TraktGUIWindows.EPGShowSelect))
                            {
                                GUIShowSelectGUI.exitGUI();
                            }
                            if (IsProgramWatched(EbasicHandler.getCurrentProgram()) && EbasicHandler.IsCurrentProgramScrobbling())
                            {
                                TraktLogger.Info("Playback of program on Live TV is considered watched. Title = '{0}'", EbasicHandler.getCurrentProgram().ToString());
                                BasicHandler.StopScrobble(EbasicHandler.getCurrentProgram(), true);
                            }
                            //The programs are different so we should start the whole scrobbling process.
                            //For that we set the new videoInfo scrobbling status to true
                            //later we're checking if videoInfo is scrobbling, and it should be false if we don't set it true here.
                            videoInfo.IsScrobbling = true;
                            //EbasicHandler.SetCurrentProgramIsScrobbling(true);
                        }

                        // continue watching new program
                        // dont try to scrobble if previous attempt failed
                        // If the current program is scrobbling, according to the APIARY there's no need to resend every 15 minutes,
                        // it will expire after runtime has elapsed.

                        if ((videoInfo.IsScrobbling) | (TVJustTurnedOn))
                        {
                            TVJustTurnedOn = false;
                            //Starts the scrobble of the new program because it changed
                            //cache should search here because some shows have no name and could be in cache.

                            #region CACHE CHECK and SCROBBLE from CACHE
                            if (EPGCache.searchOnCache(videoInfo.Title, out item))
                            {
                                if (item.Type.Equals("nullRecord"))
                                {
                                    response.Code        = 901;
                                    response.Description = "Manually set don't scrobble";
                                }
                                else if ((item.Type.Equals("movie")) & (videoInfo.Type == VideoType.Movie))
                                {
                                    EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Movie);
                                    response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                }
                                else if ((item.Type.Equals("show")) & (videoInfo.Type == VideoType.Series))
                                {
                                    EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Show);
                                    response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                }
                                else
                                //The item type is different from the videoinfo type. Cache is authoritative here so overriding videoInfo with the cache.
                                //It's most likely that a show is detected wrong as a movie, because a movie with episode and season number is totally nonsense, but handles both.
                                {
                                    response.Code = 904; //This code will be used later.
                                    if (item.Type.Equals("show"))
                                    {
                                        EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Show);
                                        response.Description = item.Show.Ids.Slug;
                                    }
                                    else
                                    {
                                        EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Movie);
                                    }
                                }
                            }// end cache thingy if it was successful it should be scrobbled.
                            #endregion
                            #region CACHE MATCH UNSUCCESSFUL: TRY RETRIEVE ORIGINAL LANGUAGE AND SCROBBLE
                            else
                            {
                                #region FOUND ORIGINAL LANGUAGE TITLE WITH A SINGLE MATCH
                                // Try first to scrobble without changing anything. This is to avoid problems with shows that uses
                                // real non translated shows. In this case the name of the show usually is enough to succesfully scrobble.
                                if (videoInfo.Type == VideoType.Series)
                                {
                                    response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                }
                                else
                                {
                                    response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                }
                                if (!(response.Code == 0) && EbasicHandler.setOriginalTitle(ref videoInfo))
                                {
                                    if ((videoInfo.Type == VideoType.Series))
                                    {
                                        response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                    }
                                    else
                                    {
                                        response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                    }
                                }
                                #endregion
                                #region NO CACHE, NO ORIGINAL LANGUAGE SINGLE MATCH FOUND everything is very likely to fail.
                                else if (!response.Code.Equals(0))
                                {
                                    response.Code        = 404;
                                    response.Description = "Not Found";
                                }
                                #endregion
                            }
                            #endregion
                            EbasicHandler.setCurrentProgram(videoInfo);
                            if (response.Code.Equals(901))
                            {
                                TraktLogger.Info("Program {0} skipped because manually marked to skip on cache", videoInfo.Title);
                            }
                            else if (response.Code.Equals(0))
                            {
                                if (TraktSettings.AllowPopUPOnSuccessfulScrobbling)
                                {
                                    GUIDialogNotify notification = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                                    notification.Reset();
                                    notification.SetHeading(string.Format("{0} scrobbled!", EbasicHandler.getCurrentProgram().Type.ToString()));
                                    notification.SetText(string.Format("Scrobbling '{0}' as '{1}'", EbasicHandler.getCurrentProgram().getOriginalTitle(), EbasicHandler.getCurrentProgram().Title));
                                    notification.SetImage(Path.Combine(Config.GetFolder(Config.Dir.Skin), string.Format(@"{0}\Media\Logos\trakt.png", Config.SkinName)));
                                    notification.DoModal(GUIWindowManager.ActiveWindow);
                                }
                            }
                            else // the response was bad! Everything gone worse than ever, again open the GUI
                            {
                                GUIDialogYesNo askManualSelection = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                                if (askManualSelection != null)
                                {
                                    askManualSelection.Reset();
                                    askManualSelection.SetHeading("Start manual matching?");
                                    askManualSelection.SetLine(1, string.Format("Cannot find a match for '{0}'", videoInfo.Title));
                                    askManualSelection.SetDefaultToYes(true);
                                    askManualSelection.DoModal(GUIWindowManager.ActiveWindow);
                                    if (askManualSelection.IsConfirmed)
                                    {
                                        if (!istStoppingScrobble) //maybe we can handle this better. If the user stops the program right before this the plugin crashes.
                                        {
                                            EbasicHandler.StartGui(response.Code, item, TraktSettings.GUIAsDialog);
                                        }
                                    }
                                    else
                                    {
                                        // Need to handle cancel button with a null on cache to avoid future scrobbling.
                                        EPGCache.addOnCache(videoInfo.Title);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (NullReferenceException exception)
                {
                    //handle the worst. This usually happens when the user stops the player during a dialog.
                    //We should at least log this in the mediaportal error.
                }
            }), null, 1000, 300000);

            #endregion
            return(true);
        }
예제 #20
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();
                }
            }
        }
예제 #21
0
        private void Onrecord(ScheduleType scheduleType)
        {
            Schedule schedule = null;

            if (_upcomingProgram != null)
            {
                schedule = Proxies.SchedulerService.GetScheduleById(_upcomingProgram.ScheduleId).Result;
            }
            if (_upcomingProgram != null && schedule != null &&
                schedule.ScheduleType == scheduleType)   //delete schedule
            {
                if (_upcomingProgram.IsCancelled)
                {
                    Proxies.SchedulerService.UncancelUpcomingProgram(_upcomingProgram.ScheduleId, _upcomingProgram.GuideProgramId, _upcomingProgram.Channel.ChannelId, _upcomingProgram.StartTime).Wait();
                    try
                    {
                        //refresh _upcomingProgram
                        _upcomingProgram = Proxies.SchedulerService.GetUpcomingPrograms(schedule, true).Result[0];
                    }
                    catch { }
                }
                else
                {
                    if (_upcomingProgram.IsPartOfSeries)
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DeleteEntireSchedule));
                            dlgYesNo.SetLine(1, "\"" + schedule.Name + "\"");
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, String.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                            if (dlgYesNo.IsConfirmed)
                            {
                                Proxies.SchedulerService.DeleteSchedule(schedule.ScheduleId).Wait();
                                _upcomingProgram = null;
                            }
                        }
                    }
                    else
                    {
                        Proxies.SchedulerService.DeleteSchedule(_upcomingProgram.ScheduleId).Wait();
                        _upcomingProgram = null;
                    }
                }
            }
            else//create new schedule
            {
                TimeSpan           duration   = new TimeSpan(Int32.Parse(_spinHoursDuration.GetLabel()), Int32.Parse(_spinMinutesDuration.GetLabel()), 0);
                DateTime           startTime  = new DateTime(Int32.Parse(_spinStartYear.GetLabel()), Int32.Parse(_spinStartMonth.GetLabel()), Int32.Parse(_spinStartDay.GetLabel()), Int32.Parse(_spinStartHour.GetLabel()), Int32.Parse(_spinStartMinute.GetLabel()), 0);
                ScheduleDaysOfWeek daysOfWeek = new ScheduleDaysOfWeek();

                //TODO: What if we have multiple channels with the same name
                Channel channel = Proxies.SchedulerService.GetChannelByDisplayName(_channelType, _spinChannel.GetLabel()).Result;

                Schedule newSchedule = null;
                newSchedule = Proxies.SchedulerService.CreateNewSchedule(_channelType, scheduleType).Result;
                newSchedule.Rules.Add(ScheduleRuleType.Channels, channel.ChannelId);
                newSchedule.Rules.Add(ScheduleRuleType.ManualSchedule, startTime, new ScheduleTime(duration));
                if (!_recordOnce)
                {
                    string days = " ";
                    if (_mondayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Mondays;
                        days      += Utility.GetLocalizedText(TextId.Mon) + ",";
                    }
                    if (_tuesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Tuesdays;
                        days      += Utility.GetLocalizedText(TextId.Tue) + ",";
                    }
                    if (_wednesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Wednesdays;
                        days      += Utility.GetLocalizedText(TextId.Wed) + ",";
                    }
                    if (_thursdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Thursdays;
                        days      += Utility.GetLocalizedText(TextId.Thu) + ",";
                    }
                    if (_fridayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Fridays;
                        days      += Utility.GetLocalizedText(TextId.Fri) + ",";
                    }
                    if (_saturdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Saturdays;
                        days      += Utility.GetLocalizedText(TextId.Sat) + ",";
                    }
                    if (_sundayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Sundays;
                        days      += Utility.GetLocalizedText(TextId.Sun) + ",";
                    }
                    days = days.Remove(days.Length - 1);
                    newSchedule.Rules.Add(ScheduleRuleType.DaysOfWeek, daysOfWeek);
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2:t}-{3:t}", channel.DisplayName, days, startTime, startTime.Add(duration));
                }
                else
                {
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1:g}-{2:t}", channel.DisplayName, startTime, startTime.Add(duration));
                }

                //TODO: try to prevent dublicate manual schedules
                //and find a better way to get the newly created "_schedule" and  "_upcomingProgram"
                if (newSchedule != null)
                {
                    newSchedule.ScheduleType = scheduleType;
                    Proxies.SchedulerService.SaveSchedule(newSchedule).Wait();

                    bool found     = false;
                    var  _programs = Proxies.SchedulerService.GetAllUpcomingPrograms(scheduleType, true).Result;
                    foreach (UpcomingProgram _prog in _programs)
                    {
                        if (_prog.Channel.ChannelId == channel.ChannelId &&
                            _prog.Duration == duration &&
                            !found)
                        {
                            Schedule _schedule = Proxies.SchedulerService.GetScheduleById(_prog.ScheduleId).Result;
                            if (_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule) != null)
                            {
                                if (_schedule.Name == newSchedule.Name)
                                {
                                    if (_recordOnce &&
                                        _prog.StartTime == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found            = true;
                                    }
                                    else if (!_recordOnce && _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek) != null &&
                                             _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek).Arguments[0].ToString() == daysOfWeek.ToString() &&
                                             Convert.ToDateTime(_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule).Arguments[0]) == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found            = true;
                                    }
                                    Update(_schedule);
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        GUIWindowManager.ShowPreviousWindow();
                    }
                }
            }
        }
예제 #22
0
        protected override void OnShowContextMenu()
        {
            int         iItem = GetSelectedItemNo();
            GUIListItem pItem = GetItem(iItem);

            if (pItem == null)
            {
                return;
            }
            if (pItem.IsFolder)
            {
                ScheduleSummary schedule = pItem.TVTag as ScheduleSummary;
                if (schedule != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(schedule.Name ?? string.Empty);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    if (schedule.IsActive)
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisSchedule));
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.UnCancelThisSchedule));
                    }

                    dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                    dlg.DoModal(GetID);

                    Schedule _sched = Proxies.SchedulerService.GetScheduleById(schedule.ScheduleId).Result;
                    switch (dlg.SelectedLabel)
                    {
                    case 0:
                        if (_sched != null)
                        {
                            var programs = Proxies.SchedulerService.GetUpcomingPrograms(_sched, true).Result;
                            if (programs != null && programs.Count > 0)
                            {
                                OnEditSchedule(programs[0]);
                            }
                        }
                        break;

                    case 1:
                        if (_sched != null)
                        {
                            if (_sched.IsActive)
                            {
                                _sched.IsActive = false;
                                Proxies.SchedulerService.SaveSchedule(_sched).Wait();
                            }
                            else
                            {
                                _sched.IsActive = true;
                                Proxies.SchedulerService.SaveSchedule(_sched).Wait();
                            }
                        }
                        break;

                    case 2:
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.Reset();
                            dlgYesNo.SetHeading(schedule.Name);
                            dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, string.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GetID);

                            if (dlgYesNo.IsConfirmed)
                            {
                                Proxies.SchedulerService.DeleteSchedule(schedule.ScheduleId).Wait();
                                _selectedSchedule = null;
                            }
                        }
                    }
                    break;
                    }
                    m_iSelectedItem = GetSelectedItemNo();
                    LoadUpcomingPrograms(null);
                }
            }
            else
            {
                UpcomingProgram upcoming = pItem.TVTag as UpcomingProgram;
                if (upcoming != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(upcoming.Title);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    dlg.Add(Utility.GetLocalizedText(TextId.Priority));
                    if (upcoming.IsCancelled)
                    {
                        if (upcoming.CancellationReason == UpcomingCancellationReason.Manual)
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.UncancelThisShow));
                        }
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow));
                    }
                    dlg.DoModal(GetID);

                    switch (dlg.SelectedLabel)
                    {
                    case 0:     // settings/information
                        OnEditSchedule(upcoming);
                        break;

                    case 1:     // Priority
                        OnChangePriority(upcoming);
                        break;

                    case 2:     // (Un)Cancel
                        if (upcoming.IsCancelled)
                        {
                            Proxies.SchedulerService.UncancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait();
                        }
                        else
                        {
                            Proxies.SchedulerService.CancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait();
                        }
                        m_iSelectedItem = GetSelectedItemNo();
                        LoadUpcomingPrograms(null);
                        break;
                    }
                }
            }
        }