public void SetActiveWindow(GUIWindow.Window _window) { if (base.InvokeRequired) { base.Invoke(new SetActiveWindowDelegate(this.SetActiveWindow), new object[] { _window }); } this.txtActiveWindow.Text = _window.ToString(); }
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); }
//Perform work on render thread private void DoWork() { try { Settings.Instance.LogDebug("MiniDisplay Processing status."); GUIWindow.Window activeWindow = (GUIWindow.Window)GUIWindowManager.ActiveWindow; Settings.Instance.LogDebug("Active window is {0}", activeWindow.ToString()); this.status = Status.Idle; if (g_Player.Player != null) { Settings.Instance.LogDebug("Active player detected"); GUIPropertyManager.SetProperty("#paused", g_Player.Paused ? "true" : string.Empty); if (g_Player.IsDVD) { this.status = Status.PlayingDVD; } else if (g_Player.IsRadio) { this.status = Status.PlayingRadio; } else if (g_Player.IsMusic) { this.status = Status.PlayingMusic; } else if (g_Player.IsTimeShifting) { this.status = Status.Timeshifting; } else if (g_Player.IsTVRecording) { this.status = Status.PlayingRecording; } else if (g_Player.IsTV) { this.status = Status.PlayingTV; } else if (g_Player.IsVideo) { this.status = Status.PlayingVideo; } } else { GUIPropertyManager.SetProperty("#paused", string.Empty); if (this.IsTVWindow((int)activeWindow)) { this.status = Status.PlayingTV; } } bool userIsIdle = true; if ((DateTime.Now - this.lastAction) < new TimeSpan(0, 0, Settings.Instance.IdleTimeout)) { this.status = Status.Action; userIsIdle = false; } if (GUIWindowManager.IsRouted) { string dialogTitle = string.Empty; string dialogHighlightedItem = string.Empty; GUIWindow.Window activeWindowEx = (GUIWindow.Window)GUIWindowManager.ActiveWindowEx; if (this.GetDialogInfo(activeWindowEx, ref dialogTitle, ref dialogHighlightedItem)) { this.status = Status.Dialog; GUIPropertyManager.GetProperty("#currentmodule"); GUIPropertyManager.SetProperty("#DialogLabel", dialogTitle); GUIPropertyManager.SetProperty("#DialogItem", dialogHighlightedItem); Settings.Instance.LogDebug("DIALOG window is {0}: \"{1}\", \"{2}\"", activeWindowEx.ToString(), dialogTitle, dialogHighlightedItem); } } Settings.Instance.LogDebug("Detected status is {0}", status.ToString()); lock (MiniDisplayHelper.StatusMutex) { MiniDisplayHelper.MPStatus.UserIsIdle = userIsIdle; MiniDisplayHelper.MPStatus.CurrentPluginStatus = this.status; if (this.status.Equals(Status.Idle) && !MiniDisplayHelper.MPStatus.MP_Is_Idle) { //Set our idle status to true and mark the time MiniDisplayHelper.MPStatus.MP_Is_Idle = true; MiniDisplayHelper.MPStatus.TimeIdleStateChanged = DateTime.Now; } else if (!this.status.Equals(Status.Idle) && MiniDisplayHelper.MPStatus.MP_Is_Idle) { //Set our idle status to false and mark the time MiniDisplayHelper.MPStatus.MP_Is_Idle = false; MiniDisplayHelper.MPStatus.TimeIdleStateChanged = DateTime.Now; } MiniDisplayHelper.MPStatus.CurrentIconMask = MiniDisplayHelper.SetPluginIcons(); if (this.status.Equals(Status.PlayingDVD)) { MiniDisplayHelper.MPStatus.Media_IsDVD = true; } if (this.status.Equals(Status.PlayingRadio)) { MiniDisplayHelper.MPStatus.Media_IsRadio = true; } if (this.status.Equals(Status.PlayingMusic)) { MiniDisplayHelper.MPStatus.Media_IsMusic = true; } if (this.status.Equals(Status.PlayingRecording)) { MiniDisplayHelper.MPStatus.Media_IsTVRecording = true; } if (this.status.Equals(Status.PlayingTV)) { MiniDisplayHelper.MPStatus.Media_IsTV = true; } if (this.status.Equals(Status.Timeshifting)) { MiniDisplayHelper.MPStatus.Media_IsTVRecording = true; } if (this.status.Equals(Status.PlayingVideo)) { MiniDisplayHelper.MPStatus.Media_IsVideo = true; } MiniDisplayHelper.ShowSystemStatus(ref MiniDisplayHelper.MPStatus); } lock (MiniDisplayHelper.PropertyBrowserMutex) { if (((this.browser != null) && !this.browser.IsDisposed) && MiniDisplayHelper._PropertyBrowserAvailable) { Settings.Instance.LogInfo("MiniDisplayPlugin.DoWork(): Updating PropertyBrowser."); this.browser.SetStatus(this.status); this.browser.SetActiveWindow(activeWindow); } } foreach (Message message in Settings.Instance.Messages) { if (((message.Status == Status.Any) || (message.Status == this.status)) && ((message.Windows.Count == 0) || message.Windows.Contains((int)activeWindow))) { if (!message.Process(this.handler)) { } return; } } } catch (Exception exception) { Log.Error(exception); } }
/// <summary> /// Evaluates the button number, gets its mapping and executes the action /// </summary> /// <param name="btnCode">Button code (ref: XML file)</param> /// <param name="processID">Process-ID for close/kill commands</param> private bool DoMapAction(string btnCode, int processID) { if (!_isLoaded) // No mapping loaded { Log.Info("Map: No button mapping loaded"); return(false); } Mapping map = null; map = GetMapping(btnCode); if (map == null) { return(false); } #if DEBUG Log.Info("{0} / {1} / {2} / {3}", map.Condition, map.ConProperty, map.Command, map.CmdProperty); #endif Action action; if (map.Sound != string.Empty) { Util.Utils.PlaySound(map.Sound, false, true); } if (map.Focus && !GUIGraphicsContext.HasFocus) { GUIGraphicsContext.ResetLastActivity(); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null); //GUIWindowManager.SendThreadMessage(msg); GUIGraphicsContext.SendMessage(msg); return(true); } switch (map.Command) { case "ACTION": // execute Action x Key key = new Key(map.CmdKeyChar, map.CmdKeyCode); #if DEBUG Log.Info("Executing: key {0} / {1} / Action: {2} / {3}", map.CmdKeyChar, map.CmdKeyCode, map.CmdProperty, ((Action.ActionType)Convert.ToInt32(map.CmdProperty)).ToString()); #endif action = new Action(key, (Action.ActionType)Convert.ToInt32(map.CmdProperty), 0, 0); GUIGraphicsContext.OnAction(action); break; case "KEY": // send Key x SendKeys.SendWait(map.CmdProperty); break; case "WINDOW": // activate Window x GUIGraphicsContext.ResetLastActivity(); GUIMessage msg; if ((Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_HOME) || (Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_SECOND_HOME)) { GUIWindow.Window newHome = _basicHome ? GUIWindow.Window.WINDOW_SECOND_HOME : GUIWindow.Window.WINDOW_HOME; // do we prefer to use only one home screen? if (_useOnlyOneHome) { // skip if we are already in there if (GUIWindowManager.ActiveWindow == (int)newHome) { break; } } // we like both else { // if already in one home switch to the other switch (GUIWindowManager.ActiveWindow) { case (int)GUIWindow.Window.WINDOW_HOME: newHome = GUIWindow.Window.WINDOW_SECOND_HOME; break; case (int)GUIWindow.Window.WINDOW_SECOND_HOME: newHome = GUIWindow.Window.WINDOW_HOME; break; } } msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)newHome, 0, null); } else { msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, Convert.ToInt32(map.CmdProperty), 0, null); } GUIWindowManager.SendThreadMessage(msg); break; case "TOGGLE": // toggle Layer 1/2 if (_currentLayer == 1) { _currentLayer = 2; } else { _currentLayer = 1; } break; case "POWER": // power down commands if ((map.CmdProperty == "STANDBY") || (map.CmdProperty == "HIBERNATE")) { GUIGraphicsContext.ResetLastActivity(); } switch (map.CmdProperty) { case "EXIT": action = new Action(Action.ActionType.ACTION_EXIT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "REBOOT": action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "SHUTDOWN": action = new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0); GUIGraphicsContext.OnAction(action); break; case "STANDBY": action = new Action(Action.ActionType.ACTION_SUSPEND, 1, 0); //1 = ignore prompt GUIGraphicsContext.OnAction(action); break; case "HIBERNATE": action = new Action(Action.ActionType.ACTION_HIBERNATE, 1, 0); //1 = ignore prompt GUIGraphicsContext.OnAction(action); break; case "POWEROFF": action = new Action(Action.ActionType.ACTION_POWER_OFF, 1, 0); //1 = ignore prompt GUIGraphicsContext.OnAction(action); break; } break; case "PROCESS": { GUIGraphicsContext.ResetLastActivity(); if (processID > 0) { Process proc = Process.GetProcessById(processID); if (null != proc) { switch (map.CmdProperty) { case "CLOSE": proc.CloseMainWindow(); break; case "KILL": proc.Kill(); break; } } } } break; default: return(false); } return(true); }
/// <summary> /// Execute the given conditional action if needed. /// </summary> /// <param name="aAction">The action we want to conditionally execute.</param> /// <param name="aProcessId">Process-ID for close/kill commands.</param> /// <returns></returns> public bool ExecuteActionIfNeeded(ConditionalAction aAction, int aProcessId = -1) { if (aAction == null) { return(false); } HidListener.LogInfo("Action: {0} / {1} / {2} / {3}", aAction.Condition, aAction.ConProperty, aAction.Command, aAction.CmdProperty); Action action; if (aAction.Sound != string.Empty) { Util.Utils.PlaySound(aAction.Sound, false, true); } if (aAction.Focus && !GUIGraphicsContext.HasFocus) { GUIGraphicsContext.ResetLastActivity(); var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null); //GUIWindowManager.SendThreadMessage(msg); GUIGraphicsContext.SendMessage(msg); return(true); } switch (aAction.Command) { case "ACTION": // execute Action x var key = new Key(aAction.CmdKeyChar, aAction.CmdKeyCode); HidListener.LogInfo("Executing: key {0} / {1} / Action: {2} / {3}", aAction.CmdKeyChar, aAction.CmdKeyCode, aAction.CmdProperty, ((Action.ActionType)Convert.ToInt32(aAction.CmdProperty)).ToString()); action = new Action(key, (Action.ActionType)Convert.ToInt32(aAction.CmdProperty), 0, 0); GUIGraphicsContext.OnAction(action); break; case "KEY": // send Key x SendKeys.SendWait(aAction.CmdProperty); break; case "WINDOW": // activate Window x GUIGraphicsContext.ResetLastActivity(); GUIMessage msg; if ((Convert.ToInt32(aAction.CmdProperty) == (int)GUIWindow.Window.WINDOW_HOME) || (Convert.ToInt32(aAction.CmdProperty) == (int)GUIWindow.Window.WINDOW_SECOND_HOME)) { GUIWindow.Window newHome = _basicHome ? GUIWindow.Window.WINDOW_SECOND_HOME : GUIWindow.Window.WINDOW_HOME; // do we prefer to use only one home screen? if (_useOnlyOneHome) { // skip if we are already in there if (GUIWindowManager.ActiveWindow == (int)newHome) { break; } } // we like both else { // if already in one home switch to the other switch (GUIWindowManager.ActiveWindow) { case (int)GUIWindow.Window.WINDOW_HOME: newHome = GUIWindow.Window.WINDOW_SECOND_HOME; break; case (int)GUIWindow.Window.WINDOW_SECOND_HOME: newHome = GUIWindow.Window.WINDOW_HOME; break; } } msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)newHome, 0, null); } else { msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, Convert.ToInt32(aAction.CmdProperty), 0, null); } GUIWindowManager.SendThreadMessage(msg); break; case "TOGGLE": // toggle Layer 1/2 if (_currentLayer == 1) { _currentLayer = 2; } else { _currentLayer = 1; } break; case "POWER": // power down commands if ((aAction.CmdProperty == "STANDBY") || (aAction.CmdProperty == "HIBERNATE")) { GUIGraphicsContext.ResetLastActivity(); } switch (aAction.CmdProperty) { case "EXIT": action = new Action(Action.ActionType.ACTION_EXIT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "REBOOT": action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "SHUTDOWN": action = new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0); GUIGraphicsContext.OnAction(action); break; case "STANDBY": action = new Action(Action.ActionType.ACTION_SUSPEND, 1, 0); //1 = ignore prompt GUIGraphicsContext.OnAction(action); break; case "HIBERNATE": action = new Action(Action.ActionType.ACTION_HIBERNATE, 1, 0); //1 = ignore prompt GUIGraphicsContext.OnAction(action); break; } break; case "PROCESS": { GUIGraphicsContext.ResetLastActivity(); if (aProcessId > 0) { var proc = Process.GetProcessById(aProcessId); if (null != proc) { switch (aAction.CmdProperty) { case "CLOSE": proc.CloseMainWindow(); break; case "KILL": proc.Kill(); break; } } } } break; default: return(false); } return(true); }