/// <summary> /// Displays a notification dialog. /// </summary> public static void ShowNotifyDialog(string heading, string text, string image, string buttonText, int timeout) { if (GUIGraphicsContext.form.InvokeRequired) { ShowNotifyDialogDelegate d = ShowNotifyDialog; GUIGraphicsContext.form.Invoke(d, heading, text, image, buttonText, timeout); return; } GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (pDlgNotify == null) { return; } try { pDlgNotify.Reset(); pDlgNotify.SetHeading(heading); pDlgNotify.SetImage(image); pDlgNotify.SetText(text); if (timeout >= 0) { pDlgNotify.TimeOut = timeout; } foreach (GUIControl item in pDlgNotify.Children) { if (item is GUIButtonControl) { GUIButtonControl btn = (GUIButtonControl)item; if (btn.GetID == 4 && !string.IsNullOrEmpty(buttonText) && !string.IsNullOrEmpty(btn.Label)) { // Only if ID is 4 and we have our custom text and if button already has label (in case the skin "hides" the button by emptying the label) btn.Label = buttonText; } } } pDlgNotify.DoModal(GUIWindowManager.ActiveWindow); } finally { if (pDlgNotify != null) { pDlgNotify.ClearAll(); } } }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { GUIWindowManager.OnResize(); GUIWindowManager.PreInit(); GUIGraphicsContext.Save(); if (m_orgZoomVertical != GUIGraphicsContext.ZoomVertical) // only vertical zoom affects font sizes { GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlgNotify != null) { dlgNotify.Reset(); dlgNotify.ClearAll(); dlgNotify.SetHeading(213); // UI Calibration dlgNotify.SetText(GUILocalizeStrings.Get(2650)); // Reloading fonts, please wait... dlgNotify.TimeOut = 1; dlgNotify.DoModal(GUIWindowManager.ActiveWindow); } GUIFontManager.LoadFonts(Config.GetFile(Config.Dir.Skin, GUIGraphicsContext.Skin, "fonts.xml")); GUIFontManager.InitializeDeviceObjects(); } } break; case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { base.OnMessage(message); m_iSpeed = 1; m_iCountU = 0; m_iCountD = 0; m_iCountL = 0; m_iCountR = 0; m_iMode = 0; m_bModeLocked = true; m_orgZoomVertical = GUIGraphicsContext.ZoomVertical; m_iLogWidth = (int)Math.Round((float)GUIGraphicsContext.Width * (float)GUIGraphicsContext.ZoomHorizontal); m_iLogHeight = (int)Math.Round((float)GUIGraphicsContext.Height * (float)GUIGraphicsContext.ZoomVertical); ClampLogicalScreenSize(); UpdateControlLabel(); return(true); } } return(base.OnMessage(message)); }
/// <summary> /// Pop up a dialog in MediaPortal. /// </summary> /// <param name="heading">Dialog heading text.</param> /// <param name="text">Dialog body text.</param> /// <param name="timeout">Dialog timeout in seconds, zero for no timeout.</param> public static void ShowNotifyDialog(string heading, string text, int timeout) { GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlgNotify == null) { throw new ApplicationException("Failed to create GUIDialogNotify"); } dlgNotify.Reset(); dlgNotify.ClearAll(); dlgNotify.SetHeading(heading); dlgNotify.SetText(text); dlgNotify.TimeOut = timeout; dlgNotify.DoModal(GUIWindowManager.ActiveWindow); }
/// <summary> /// Pop up a dialog in MediaPortal. /// </summary> /// <param name="heading">Dialog heading text.</param> /// <param name="text">Dialog body text.</param> /// <param name="timeout">Dialog timeout in seconds, zero for no timeout.</param> public static void ShowNotifyDialog(string heading, string text, int timeout) { GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlgNotify == null) { throw new InvalidOperationException("Failed to create GUIDialogNotify"); } dlgNotify.Reset(); dlgNotify.ClearAll(); dlgNotify.SetHeading(heading); dlgNotify.SetText(text); dlgNotify.TimeOut = timeout; dlgNotify.DoModal(GUIWindowManager.ActiveWindow); // TODO: Put this on a separate thread to allow caller to continue? }
/// <summary> /// Execute this command. /// </summary> /// <param name="variables">The variable list of the calling code.</param> public override void Execute(VariableList variables) { GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlgNotify == null) { throw new CommandExecutionException("Failed to create GUIDialogNotify"); } string[] processed = ProcessParameters(variables, Parameters); int timeout = int.Parse(processed[2]); dlgNotify.Reset(); dlgNotify.ClearAll(); dlgNotify.SetHeading(processed[0]); dlgNotify.SetText(processed[1]); dlgNotify.TimeOut = timeout; dlgNotify.DoModal(GUIWindowManager.ActiveWindow); }
public static void OnGlobalMessage(GUIMessage message) { switch (message.Message) { /// <summary> /// We need to stop the player if our livestream ends unexpectedly. /// If the stream stopped for a recording, we show it in a message. /// Without this mediaportal can hang,crash (c++ error in tsreader). /// </summary> case GUIMessage.MessageType.GUI_MSG_STOP_SERVER_TIMESHIFTING: { Log.Debug("TvHome: GUI_MSG_STOP_SERVER_TIMESHIFTING, param1 = {0}", message.Param1); if (PluginMain.Navigator.IsLiveStreamOn) { if (message.Param1 == 4321) //fired by eventlistener { LiveStream liveStream = message.Object as LiveStream; LiveStream navigatorLiveStream = PluginMain.Navigator.LiveStream; Channel channel = PluginMain.Navigator.CurrentChannel; if (liveStream != null && channel != null && navigatorLiveStream.TimeshiftFile == liveStream.TimeshiftFile && liveStream.StreamStartedTime == navigatorLiveStream.StreamStartedTime) { if (g_Player.Playing && (g_Player.IsTV || g_Player.IsRadio)) { g_Player.Stop(); Log.Info("TvHome: our live stream seems to be aborted, stop the playback now"); } string text = GUILocalizeStrings.Get(1516); if (message.Label == LiveStreamAbortReason.RecordingStartedOnCard.ToString()) { text = GUILocalizeStrings.Get(1513); } text = text.Replace("\\r", " "); string heading = string.Empty; string tvlogo = string.Empty; using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent()) { if (channel.ChannelType == ChannelType.Television) { heading = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName; //my tv } else { heading = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName; //my radio } tvlogo = Utility.GetLogoImage(channel, SchedulerAgent); } GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (pDlgNotify != null) { pDlgNotify.Reset(); pDlgNotify.ClearAll(); pDlgNotify.SetHeading(heading); if (!string.IsNullOrEmpty(text)) { pDlgNotify.SetText(text); } pDlgNotify.SetImage(tvlogo); pDlgNotify.TimeOut = 5; Utils.PlaySound("notify.wav", false, true); pDlgNotify.DoModal(GUIWindowManager.ActiveWindow); } } } else //fired by mp player { PluginMain.Navigator.AsyncStopLiveStream(); } } } break; case GUIMessage.MessageType.GUI_MSG_NOTIFY_REC: { if (_enableRecNotification) { Log.Debug("TvHome: GUI_MSG_NOTIFY_REC"); string head = string.Empty; string logo = string.Empty; Recording recording = message.Object as Recording; if (message.Param1 == 1) { head = GUILocalizeStrings.Get(1446); } else { head = GUILocalizeStrings.Get(1447); } using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent()) { Channel chan = SchedulerAgent.GetChannelById(recording.ChannelId); logo = Utility.GetLogoImage(chan, SchedulerAgent); } string _text = String.Format("{0} {1}-{2}", recording.Title, recording.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), recording.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIDialogNotify DlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (DlgNotify != null) { DlgNotify.Reset(); DlgNotify.ClearAll(); DlgNotify.SetHeading(head); if (!string.IsNullOrEmpty(_text)) { DlgNotify.SetText(_text); } DlgNotify.SetImage(logo); DlgNotify.TimeOut = 5; if (_playNotifyBeep) { Utils.PlaySound("notify.wav", false, true); } DlgNotify.DoModal(GUIWindowManager.ActiveWindow); } } } break; case GUIMessage.MessageType.GUI_MSG_NOTIFY_TV_PROGRAM: { Log.Debug("TvHome: GUI_MSG_NOTIFY_TV_PROGRAM"); TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO); UpcomingProgram prog = message.Object as UpcomingProgram; if (tvNotifyDlg == null || prog == null) { return; } tvNotifyDlg.Reset(); if (prog.StartTime > DateTime.Now) { int minUntilStart = (prog.StartTime - DateTime.Now).Minutes; if (minUntilStart > 1) { tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1018), minUntilStart)); } else { tvNotifyDlg.SetHeading(1019); // Program is about to begin } } else { tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1206), (DateTime.Now - prog.StartTime).Minutes.ToString())); } string description = GUILocalizeStrings.Get(736); using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent()) { try { if (prog.GuideProgramId.HasValue) { GuideProgram Program = tvGuideAgent.GetProgramById(prog.GuideProgramId.Value); description = Program.CreateCombinedDescription(false); } } catch { } } tvNotifyDlg.SetLine(1, prog.Title); tvNotifyDlg.SetLine(2, description); tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), prog.Channel.DisplayName)); string strLogo = string.Empty; using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent()) { strLogo = Utility.GetLogoImage(prog.Channel, SchedulerAgent); } tvNotifyDlg.SetImage(strLogo); tvNotifyDlg.TimeOut = _notifyTVTimeout; if (_playNotifyBeep) { Utils.PlaySound("notify.wav", false, true); } tvNotifyDlg.SetDefaultToYes(false); tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow); if (tvNotifyDlg.IsConfirmed) { try { if (prog.Channel.ChannelType == ChannelType.Television) { if (g_Player.Playing && g_Player.IsTV && PluginMain.Navigator.IsLiveStreamOn) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TVFULLSCREEN); } else { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TV); } PluginMain.Navigator.ZapToChannel(prog.Channel, false); if (PluginMain.Navigator.CheckChannelChange()) { TvHome.UpdateProgressPercentageBar(true); if (!PluginMain.Navigator.LastChannelChangeFailed) { g_Player.ShowFullScreenWindow(); } } } else { PluginMain.Navigator.ZapToChannel(prog.Channel, false); GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_RADIO); } } catch (Exception e) { Log.Error("TVHome: TVNotification: Error on starting channel {0} after notification: {1} {2} {3}", prog.Channel.DisplayName, e.Message, e.Source, e.StackTrace); } } } break; //this (GUI_MSG_RECORDER_VIEW_CHANNEL) event is used to let other plugins play a recording, //lastMediaHandler does this (with param1 = 5577 for indentification). case GUIMessage.MessageType.GUI_MSG_RECORDER_VIEW_CHANNEL: { if (message.Param1 == 5577) { try { Recording rec = message.Object as Recording; RecordedBase.PlayRecording(rec, message.Param2); } catch { Log.Error("TVHome: GUI_MSG_RECORDER_VIEW_CHANNEL error"); } } } break; } }
private void ChannelTuneFailedNotifyUser(LiveStreamResult result, Channel channel) { string TuningResult = string.Empty; switch (result) { case LiveStreamResult.ChannelTuneFailed: TuningResult = (Utility.GetLocalizedText(TextId.ChannelTuneFailed)); break; case LiveStreamResult.NoFreeCardFound: TuningResult = (Utility.GetLocalizedText(TextId.NoFreeCardFound)); break; case LiveStreamResult.NotSupported: TuningResult = (Utility.GetLocalizedText(TextId.NotSupported)); break; case LiveStreamResult.NoRetunePossible: TuningResult = (Utility.GetLocalizedText(TextId.NoRetunePossible)); break; case LiveStreamResult.IsScrambled: TuningResult = (Utility.GetLocalizedText(TextId.IsScrambled)); break; case LiveStreamResult.UnknownError: TuningResult = (Utility.GetLocalizedText(TextId.UnknownError)); break; } if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN) { // If failed and wasPlaying TV, left screen as it is and show zaposd with error message GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_TV_ERROR_NOTIFY, GUIWindowManager.ActiveWindow, 0, 0, 0, 0, null); msg.SendToTargetWindow = true; msg.Object = TuningResult; // forward error info object msg.TargetWindowId = (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN; GUIGraphicsContext.SendMessage(msg); } else { // if not fulscreen, show notify dialog with the error message string caption = string.Empty; string tvlogo = string.Empty; if (channel != null) { _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = channel; _currentChannel = null; using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent()) { tvlogo = Utility.GetLogoImage(channel, SchedulerAgent); } if (channel.ChannelType == ChannelType.Television) { caption = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName; } else { caption = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName; } } GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (pDlgNotify != null) { pDlgNotify.Reset(); pDlgNotify.ClearAll(); pDlgNotify.SetHeading(caption); if (!string.IsNullOrEmpty(TuningResult)) { pDlgNotify.SetText(TuningResult); } pDlgNotify.SetImage(tvlogo); pDlgNotify.TimeOut = 5; pDlgNotify.DoModal(GUIWindowManager.ActiveWindow); } } }