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(); }
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(); } } }
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> /// 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(); } } }
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); }
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> /// 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); }
/// <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(); } } }
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); }
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 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; } 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); }
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 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); } }
public static void OnRestartMP(int windowId) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { return; } dlgYesNo.SetHeading(927); dlgYesNo.SetLine(1, "Settings changed!"); dlgYesNo.SetLine(2, "Do you want to restart MediaPortal?"); dlgYesNo.DoModal(windowId); if (!dlgYesNo.IsConfirmed) { return; } else { // Will be changed to one liner after SE patch bool hideTaskBar = false; using (MediaPortal.Profile.Settings xmlreader = new MPSettings()) { hideTaskBar = xmlreader.GetValueAsBool("general", "hidetaskbar", false); } if (hideTaskBar) { // only re-show the startbar if MP is the one that has hidden it. Win32API.EnableStartBar(true); Win32API.ShowStartBar(true); } Log.Info("Settings: OnRestart - prepare for restart!"); File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running")); Log.Info("Settings: OnRestart - saving settings..."); Profile.Settings.SaveCache(); DisposeDBs(); VolumeHandler.Dispose(); Log.Info("Main: OnSuspend - Done"); Process restartScript = new Process(); restartScript.EnableRaisingEvents = false; restartScript.StartInfo.WorkingDirectory = Config.GetFolder(Config.Dir.Base); restartScript.StartInfo.FileName = Config.GetFile(Config.Dir.Base, @"restart.vbs"); Log.Debug("Settings: OnRestart - executing script {0}", restartScript.StartInfo.FileName); restartScript.Start(); try { // Maybe the scripting host is not available therefore do not wait infinitely. if (!restartScript.HasExited) { restartScript.WaitForExit(); } } catch (Exception ex) { Log.Error("Settings: OnRestart - WaitForExit: {0}", ex.Message); } } }
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; }; } }
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(); }
/// <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); }