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(); }
/// <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(); } } }
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(); } } }
private void OnResetDatabase() { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(927)); // Warning dlgYesNo.SetLine(1, GUILocalizeStrings.Get(300026)); //Are you sure... dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { string database = Config.GetFile(Config.Dir.Database, "PictureDatabase.db3"); if (File.Exists(database)) { PictureDatabase.Dispose(); try { File.Delete(database); } catch (Exception ex) { Log.Error("GUISettingsPictures: OnResetDatabase {0}", ex.Message); } finally { PictureDatabase.ReOpen(); } } } } }
/// <summary> /// Get WifiRemote representation of the yesno dialog /// </summary> /// <returns>WifiRemote Dialog Instance</returns> public static MpDialogYesNo GetDialogYesNo() { GUIDialogYesNo menu = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); MpDialogYesNo okDialog = new MpDialogYesNo(menu); return(okDialog); }
public void RSSDownload(RSSItem item) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); dlg.SetHeading("Download this torrent?"); dlg.SetLine(1, item.Title); dlg.DoModal(GUIWindowManager.ActiveWindow); if (!dlg.IsConfirmed) { return; } TorrentLabel label = DialogAskLabel.Ask(); if (label != null) { bool ok = TorrentEngine.Instance().StartDownloading(item.Link, label.Name, true, "", "0", "", ""); if (!ok) { GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); notify.Reset(); notify.SetHeading("Failed!"); notify.SetText("Unable to start download."); notify.DoModal(GUIWindowManager.ActiveWindow); } } }
private static bool PromptStopRecording(int IdSchedule) { bool confirmed = false; bool isRec = TvDatabase.Schedule.IsScheduleRecording(IdSchedule); if (isRec) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { Log.Error("TVProgramInfo.DeleteRecordingPrompt: ERROR no GUIDialogYesNo found !!!!!!!!!!"); } else { dlgYesNo.SetHeading(1449); // stop recording dlgYesNo.SetLine(1, 1450); // are you sure to stop recording? string recordingTitle = GetRecordingTitle(IdSchedule); dlgYesNo.SetLine(2, recordingTitle); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); confirmed = dlgYesNo.IsConfirmed; } } else { confirmed = true; } return(confirmed); }
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); }
/// <summary> /// Show a yes/no dialog and if the user accepts, show a select dialog. After that, send the result to the sender. /// </summary> /// <param name="dialogId">Id of dialog</param> /// <param name="title">Dialog title</param> /// <param name="text">Dialog text</param> /// <param name="options">Options for the user to choose from</param> /// <param name="socketServer">Server</param> /// <param name="sender">Sender of the request</param> internal static void ShowYesNoThenSelectDialog(string dialogId, string title, string text, List <string> options, SocketServer socketServer, Deusty.Net.AsyncSocket sender) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); MessageDialogResult result = new MessageDialogResult(); result.DialogId = dialogId; result.YesNoResult = false; if (dlg != null) { dlg.Reset(); dlg.SetHeading(title); dlg.SetLine(1, text); dlg.DoModal(GUIWindowManager.ActiveWindow); } if (dlg.IsConfirmed && options != null && options.Count > 0) { if (options.Count == 1) { //only one option, no need to show select dialog result.SelectedOption = options[0]; result.YesNoResult = true; } else { //multiple options available, show select menu to user GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlgMenu != null) { dlgMenu.Reset(); dlgMenu.SetHeading(title); if (options != null) { foreach (string o in options) { dlgMenu.Add(o); } } //dlg.SetLine(1, text); dlgMenu.DoModal(GUIWindowManager.ActiveWindow); if (dlgMenu.SelectedId != -1) { result.YesNoResult = true; result.SelectedOption = dlgMenu.SelectedLabelText; } } } } socketServer.SendMessageToClient(result, sender); }
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); }
public MpDialogYesNo(MediaPortal.Dialogs.GUIDialogYesNo menu) : base(menu) { this.dialogMenu = menu; this.DialogType = menu.GetModuleName(); this.DialogId = menu.GetID; this.AvailableActions.Add("yes"); this.AvailableActions.Add("no"); this.AvailableActions.Add("cancel"); GetHeading(menu, 1); GetText(menu, 2, 3, 4, 5); }
/// <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 !"); } }
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); }
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); }
public bool OnResetFolderSettings() { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { return(false); } dlgYesNo.SetHeading(2149); dlgYesNo.SetLine(1, 2148); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); return(dlgYesNo.IsConfirmed); }
public static bool DialogConfirm(string msg) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlg == null) { return(false); } dlg.Reset(); dlg.SetHeading("Confirm"); dlg.SetLine(2, msg); dlg.DoModal(GUIWindowManager.ActiveWindow); return(dlg.IsConfirmed); }
private void OnDeleteItem(GUIListItem item) { if (item.IsRemote) { return; } IMDBMovie movie = item.AlbumInfoTag as IMDBMovie; if (movie == null) { return; } if (movie.ID < 0) { return; } GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { return; } dlgYesNo.SetHeading(GUILocalizeStrings.Get(925)); dlgYesNo.SetLine(1, movie.Title); dlgYesNo.SetLine(2, string.Empty); dlgYesNo.SetLine(3, string.Empty); dlgYesNo.DoModal(GetID); if (!dlgYesNo.IsConfirmed) { return; } DoDeleteItem(item); currentSelectedItem = facadeLayout.SelectedListItemIndex; if (currentSelectedItem > 0) { currentSelectedItem--; } LoadDirectory(currentFolder); if (currentSelectedItem >= 0) { GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem); } }
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); }
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); }
/// <summary> /// Show a yes no dialog in MediaPortal and send the result to the sender /// </summary> /// <param name="dialogId">Id of dialog</param> /// <param name="title">Dialog title</param> /// <param name="text">Dialog text</param> /// <param name="socketServer">Server</param> /// <param name="sender">Sender of the request</param> internal static void ShowYesNoDialog(string dialogId, string title, string text, SocketServer socketServer, Deusty.Net.AsyncSocket sender) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlg != null) { dlg.Reset(); dlg.SetHeading(title); dlg.SetLine(1, text); dlg.DoModal(GUIWindowManager.ActiveWindow); MessageDialogResult result = new MessageDialogResult(); result.YesNoResult = dlg.IsConfirmed; result.DialogId = dialogId; socketServer.SendMessageToClient(result, sender); } }
/// <summary> /// Deletes an item from the gui list /// </summary> /// <param name="item">item to delete</param> private void OnDeleteItem(GUIListItem item) { if (item.IsRemote) { return; } if (!_mDirectory.RequestPin(item.Path)) { return; } string movieFileName = Path.GetFileName(item.Path); string movieTitle = movieFileName; // delete single file GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { return; } dlgYesNo.SetHeading(GUILocalizeStrings.Get(925)); dlgYesNo.SetLine(1, movieTitle); dlgYesNo.SetLine(2, String.Empty); dlgYesNo.SetLine(3, String.Empty); dlgYesNo.DoModal(GetID); if (!dlgYesNo.IsConfirmed) { return; } DoDeleteItem(item); int currentSelectedItem = facadeView.SelectedListItemIndex; if (currentSelectedItem > 0) { currentSelectedItem--; } LoadDirectory(_virtualPath); if (currentSelectedItem >= 0) { GUIControl.SelectItemControl(GetID, facadeView.GetID, currentSelectedItem); } }
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(); } } }
private static bool SetupConfirmDelRecDialogue() { bool confirmed = false; GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { Log.Error("TVProgramInfo.DeleteRecordingPrompt: ERROR no GUIDialogYesNo found !!!!!!!!!!"); } else { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, GUILocalizeStrings.Get(730)); //This schedule is recording. If you delete dlgYesNo.SetLine(2, GUILocalizeStrings.Get(731)); //the schedule then the recording is stopped. dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); confirmed = dlgYesNo.IsConfirmed; } return(confirmed); }
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); }
private void OnClick(int iItem) { m_iSelectedItem = GetSelectedItemNo(); GUIListItem item = GetItem(iItem); if (item == null) { return; } if (item.IsFolder) { if (item.Label == "..") { if (selectedItem != null) { selectedItem = null; } LoadDirectory(); return; } if (selectedItem == null) { selectedItem = item; } LoadDirectory(); return; } Schedule schedule = item.TVTag as Schedule; if (schedule == null) { return; } if (schedule.ScheduleType == (int)ScheduleRecordingType.Once) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, schedule.ReferencedChannel().DisplayName); dlgYesNo.SetLine(2, schedule.ProgramName); dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { if (schedule.ScheduleType == (int)ScheduleRecordingType.Once) { schedule.Delete(); selectedItem = null; } } } } else // advanced recording { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(schedule.ProgramName); dlg.AddLocalizedString(981); //Delete this recording dlg.AddLocalizedString(982); //Delete series recording dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 981: //delete specific series CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, schedule.IdChannel, schedule.StartTime); canceledSchedule.Persist(); selectedItem = null; TvServer server = new TvServer(); server.OnNewSchedule(); break; case 982: //Delete entire recording schedule.Delete(); selectedItem = null; break; } } } LoadDirectory(); }
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(); } } } }
public bool GetDialogInfo(GUIWindow.Window dialogWindow, ref string DialogTitle, ref string DialogHighlightedItem) { GUIListControl control = null; bool focus = false; switch (dialogWindow) { case GUIWindow.Window.WINDOW_DIALOG_YES_NO: case GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO: { GUIDialogYesNo window = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj16 in window.controlList) { if (obj16.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label3 = obj16 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label3.Label != string.Empty) { DialogTitle = label3.Label; } } else if (label3.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label3.Label; } } if (obj16.GetType() == typeof(GUILabelControl)) { GUILabelControl control14 = obj16 as GUILabelControl; if (DialogTitle == string.Empty) { if (control14.Label != string.Empty) { DialogTitle = control14.Label; } } else if (control14.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control14.Label; } } if (obj16.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control15 = obj16 as GUIButtonControl; if (!control15.Focus) { continue; } DialogHighlightedItem = control15.Description; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_PROGRESS: { GUIDialogProgress progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj6 in progress.controlList) { if (obj6.GetType() == typeof(GUILabelControl)) { GUILabelControl control6 = obj6 as GUILabelControl; if (control6.GetID == 1) { DialogTitle = control6.Label; } } } foreach (object obj7 in progress.controlList) { if (obj7.GetType() == typeof(GUIProgressControl)) { GUIProgressControl control7 = obj7 as GUIProgressControl; DialogHighlightedItem = "Progress: " + control7.Percentage.ToString() + "%"; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_SELECT: { GUIDialogSelect select = (GUIDialogSelect)GUIWindowManager.GetWindow((int)dialogWindow); control = null; focus = false; foreach (object obj9 in select.controlList) { if (obj9.GetType() == typeof(GUIListControl)) { control = obj9 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string strLabel = string.Empty; string str5 = string.Empty; string strThumb = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref strLabel, ref str5, ref strThumb, ref strIndex); DialogHighlightedItem = strLabel; } else { foreach (object obj10 in select.controlList) { if (obj10.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control10 = obj10 as GUIButtonControl; if (control10.Focus) { DialogHighlightedItem = control10.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_OK: { GUIDialogOK gok = (GUIDialogOK)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj5 in gok.controlList) { if (obj5.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control4 = obj5 as GUIButtonControl; if (control4.Focus) { DialogHighlightedItem = control4.Description; Settings.Instance.LogInfo( "MiniDisplay.GetDialogInfo(): found WINDOW_DIALOG_OK buttoncontrol ID = {0} Label = \"{1}\" Desc = \"{2}\"", control4.GetID, control4.Label, control4.Description); } } if (obj5.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label = obj5 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label.Label != string.Empty) { DialogTitle = label.Label; } } else if (label.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label.Label; } } if (obj5.GetType() == typeof(GUILabelControl)) { GUILabelControl control5 = obj5 as GUILabelControl; if (DialogTitle == string.Empty) { if (control5.Label != string.Empty) { DialogTitle = control5.Label; } continue; } if (control5.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control5.Label; } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_SELECT2: { GUIDialogSelect2 select2 = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)dialogWindow); control = null; focus = false; foreach (object obj11 in select2.controlList) { if (obj11.GetType() == typeof(GUIListControl)) { control = obj11 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str7 = string.Empty; string str8 = string.Empty; string str9 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str7, ref str8, ref str9, ref strIndex); DialogHighlightedItem = str7; } else { foreach (object obj12 in select2.controlList) { if (obj12.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control11 = obj12 as GUIButtonControl; if (control11.Focus) { DialogHighlightedItem = control11.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_MENU: { GUIDialogMenu menu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj13 in menu.controlList) { if (obj13.GetType() == typeof(GUILabelControl)) { GUILabelControl control12 = obj13 as GUILabelControl; if (!control12.Label.Trim().ToLowerInvariant().Equals("menu")) { DialogTitle = control12.Label; } } } control = null; focus = false; foreach (object obj14 in menu.controlList) { if (obj14.GetType() == typeof(GUIListControl)) { control = obj14 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str10 = string.Empty; string str11 = string.Empty; string str12 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str10, ref str11, ref str12, ref strIndex); DialogHighlightedItem = str10; } else { foreach (object obj15 in menu.controlList) { if (obj15.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control13 = obj15 as GUIButtonControl; if (control13.Focus) { DialogHighlightedItem = control13.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_RATING: { GUIDialogSetRating rating = (GUIDialogSetRating)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj8 in rating.controlList) { if (obj8.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label2 = obj8 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label2.Label != string.Empty) { DialogTitle = label2.Label; } } else if (label2.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label2.Label; } } if (obj8.GetType() == typeof(GUILabelControl)) { GUILabelControl control8 = obj8 as GUILabelControl; if (DialogTitle == string.Empty) { if (control8.Label != string.Empty) { DialogTitle = control8.Label; } } else if (control8.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control8.Label; } } if (obj8.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control9 = obj8 as GUIButtonControl; if (!control9.Focus) { continue; } DialogHighlightedItem = control9.Description; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT: { GUIDialogMenuBottomRight right = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj2 in right.controlList) { if (obj2.GetType() == typeof(GUILabelControl)) { GUILabelControl control2 = obj2 as GUILabelControl; if (!control2.Label.Trim().ToLowerInvariant().Equals("menu") && (control2.Label != string.Empty)) { if (DialogTitle == string.Empty) { DialogTitle = control2.Label; } else { DialogTitle = DialogTitle + " - " + control2.Label; } } } } control = null; focus = false; foreach (object obj3 in right.controlList) { if (obj3.GetType() == typeof(GUIListControl)) { control = obj3 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str = string.Empty; string str2 = string.Empty; string str3 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str, ref str2, ref str3, ref strIndex); DialogHighlightedItem = str; } else { foreach (object obj4 in right.controlList) { if (obj4.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control3 = obj4 as GUIButtonControl; if (control3.Focus) { DialogHighlightedItem = control3.Description; } } } } return(true); } } return(false); }
private void OnClick(int iItem) { m_iSelectedItem = GetSelectedItemNo(); GUIListItem item = GetItem(iItem); if (item == null) { return; } Schedule rec = (Schedule)item.TVTag; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(rec.ProgramName); if (rec.Series == false) { dlg.AddLocalizedString(618); //delete } else { dlg.AddLocalizedString(981); //Delete this recording dlg.AddLocalizedString(982); //Delete series recording dlg.AddLocalizedString(888); //Episodes management } VirtualCard card; TvServer server = new TvServer(); if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { dlg.AddLocalizedString(979); //Play recording from beginning dlg.AddLocalizedString(980); //Play recording from live point } else { IList <TuningDetail> details = Channel.Retrieve(rec.IdChannel).ReferringTuningDetail(); foreach (TuningDetail detail in details) { if (detail.ChannelType == 0) { dlg.AddLocalizedString(882); //Quality settings break; } } } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 888: ////Episodes management OnSetEpisodesToKeep(rec); break; case 882: OnSetQuality(rec); break; case 981: //Delete this recording only { if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, GUILocalizeStrings.Get(730)); //This schedule is recording. If you delete dlgYesNo.SetLine(2, GUILocalizeStrings.Get(731)); //the schedule then the recording is stopped. dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { server.StopRecordingSchedule(rec.IdSchedule); CanceledSchedule schedule = new CanceledSchedule(rec.IdSchedule, rec.IdChannel, rec.StartTime); rec.Persist(); server.OnNewSchedule(); } } } else { server.StopRecordingSchedule(rec.IdSchedule); CanceledSchedule schedule = new CanceledSchedule(rec.IdSchedule, rec.IdChannel, rec.StartTime); rec.Persist(); server.OnNewSchedule(); } LoadDirectory(); } break; case 982: //Delete series recording goto case 618; case 618: // delete entire recording { if (server.IsRecordingSchedule(rec.IdSchedule, out card)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(653)); //Delete this recording? dlgYesNo.SetLine(1, GUILocalizeStrings.Get(730)); //This schedule is recording. If you delete dlgYesNo.SetLine(2, GUILocalizeStrings.Get(731)); //the schedule then the recording is stopped. dlgYesNo.SetLine(3, GUILocalizeStrings.Get(732)); //are you sure dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { server.StopRecordingSchedule(rec.IdSchedule); rec.Delete(); server.OnNewSchedule(); } } } else { rec.Delete(); server.OnNewSchedule(); } LoadDirectory(); } break; case 979: // Play recording from beginning if (g_Player.Playing && g_Player.IsTVRecording) { g_Player.Stop(true); } //TVHome.IsTVOn = true; TVHome.ViewChannel(rec.ReferencedChannel()); g_Player.SeekAbsolute(0); if (TVHome.Card.IsTimeShifting) { g_Player.ShowFullScreenWindow(); return; } break; case 980: // Play recording from live point //TVHome.IsTVOn = true; TVHome.ViewChannel(rec.ReferencedChannel()); if (TVHome.Card.IsTimeShifting) { if (g_Player.Playing) { g_Player.SeekAsolutePercentage(99); } g_Player.ShowFullScreenWindow(); return; } break; } while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0) { m_iSelectedItem--; } GUIControl.SelectItemControl(GetID, listPriorities.GetID, m_iSelectedItem); }
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); } }