예제 #1
0
        /// <summary>
        /// Execute this command.
        /// </summary>
        /// <param name="variables">The variable list of the calling code.</param>
        public override void Execute(VariableList variables)
        {
            string[] processed = ProcessParameters(variables, Parameters);

            string windowID = processed[0];

            int window = (int)GUIWindow.Window.WINDOW_INVALID;

            try
            {
                window = (int)Enum.Parse(typeof(GUIWindow.Window), "WINDOW_" + windowID, true);
            }
            catch (ArgumentException)
            {
                // Parsing the window id as a GUIWindow.Window failed, so parse it as an int
            }

            if (window == (int)GUIWindow.Window.WINDOW_INVALID)
            {
                int.TryParse(windowID, out window);
            }

            if (window == (int)GUIWindow.Window.WINDOW_INVALID)
            {
                throw new CommandStructureException(String.Format("Failed to parse Goto screen command window id \"{0}\"",
                                                                  windowID));
            }

            GUIGraphicsContext.ResetLastActivity();
            GUIWindowManager.SendThreadMessage(new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, window, 0,
                                                              null));
        }
예제 #2
0
        void airplayServer_VideoReceived(object sender, VideoEventArgs e)
        {
            airplayServer.SetPlaybackState(e.SessionId, PlaybackCategory.Video, PlaybackState.Loading);
            invoke(delegate()
            {
                //YouTube sometimes sends play video twice?? Ignore the second request
                if (e.SessionId == currentVideoSessionId && e.ContentLocation == currentVideoUrl)
                {
                    Logger.Instance.Debug("Airplayer: Ignoring duplicate playback request");
                    return;
                }

                videoReceiveTime = DateTime.Now;
                stopCurrentItem();
                cleanupPlayback();

                GUIGraphicsContext.ResetLastActivity();
                GUIWaitCursor.Init(); GUIWaitCursor.Show();

                currentVideoSessionId = e.SessionId;
                currentVideoUrl       = e.ContentLocation;
                //See if we are loading a HLS stream.
                //If so, manually select the best quality as LAVSplitter just selects the first/default.
                //If not, allow MPUrlSourceFilter as it has better seeking support but doesn't seem to like HLS streams :(
                hlsParser            = new HlsParser(currentVideoUrl);
                hlsParser.Completed += hlsParser_Completed;
                hlsParser.Start();
            });
        }
예제 #3
0
        /* The following code was referenced from the Moving Pictures plugin */
        static void suspendMP(bool suspend)
        {
            if (suspend) //suspend and hide MediaPortal
            {
                Logger.LogDebug("Suspending MediaPortal...");
                // disable mediaportal input devices
                InputDevices.Stop();

                // hide mediaportal and suspend rendering to save resources for the pc game
                GUIGraphicsContext.BlankScreen = true;
                GUIGraphicsContext.form.Hide();
                GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.SUSPENDING;
            }
            else //resume Mediaportal
            {
                Logger.LogDebug("Resuming MediaPortal...");

                InputDevices.Init();
                // Resume Mediaportal rendering
                GUIGraphicsContext.BlankScreen = false;
                GUIGraphicsContext.form.Show();
                GUIGraphicsContext.ResetLastActivity();
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null);
                GUIWindowManager.SendThreadMessage(msg);
                GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.RUNNING;
            }
        }
예제 #4
0
        /// <summary>
        /// Execute this command.
        /// </summary>
        /// <param name="variables">The variable list of the calling code.</param>
        public override void Execute(VariableList variables)
        {
            GUIGraphicsContext.ResetLastActivity();
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null);

            GUIWindowManager.SendThreadMessage(msg);
        }
예제 #5
0
        /// <summary>
        /// Execute this command.
        /// </summary>
        /// <param name="variables">The variable list of the calling code.</param>
        public override void Execute(VariableList variables)
        {
            bool mpBasicHome = false;

            using (Settings xmlreader = new Settings(MPCommon.MPConfigFile))
                mpBasicHome = xmlreader.GetValueAsBool("general", "startbasichome", false);

            GUIGraphicsContext.ResetLastActivity();
            // Stop all media before suspending
            g_Player.Stop();

            GUIMessage msg;

            if (mpBasicHome)
            {
                msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
                                     (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null);
            }
            else
            {
                msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0,
                                     null);
            }

            GUIWindowManager.SendThreadMessage(msg);

            WindowsController.ExitWindows(RestartOptions.Suspend, false);
        }
예제 #6
0
        /// <summary>
        /// Send a MediaPortal message.
        /// </summary>
        /// <param name="command">The command.</param>
        public static void ProcessSendMediaPortalMessage(string[] command)
        {
            GUIMessage.MessageType type =
                (GUIMessage.MessageType)Enum.Parse(typeof(GUIMessage.MessageType), command[0], true);
            int windowId  = int.Parse(command[1]);
            int senderId  = int.Parse(command[2]);
            int controlId = int.Parse(command[3]);
            int param1    = int.Parse(command[4]);
            int param2    = int.Parse(command[5]);

            GUIMessage message = new GUIMessage(type, windowId, senderId, controlId, param1, param2, null);

            GUIGraphicsContext.ResetLastActivity();
            GUIWindowManager.SendThreadMessage(message);
        }
예제 #7
0
        /// <summary>
        /// Open a window (for example Moving Pictures, MP-TV Series, etc.),
        /// invoke on GUI thread if called from a different
        /// thread than UI thread
        /// </summary>
        /// <param name="windowId"></param>
        public static void OpenWindow(int windowId)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                OpenWindowDelegate d = OpenWindow;
                GUIGraphicsContext.form.Invoke(d, new object[] { windowId });
            }
            else
            {
                GUIGraphicsContext.ResetLastActivity();
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, windowId, 0, null);

                GUIWindowManager.SendThreadMessage(msg);
            }
        }
예제 #8
0
        /// <summary>
        /// Execute this command.
        /// </summary>
        /// <param name="variables">The variable list of the calling code.</param>
        public override void Execute(VariableList variables)
        {
            string[] processed = ProcessParameters(variables, Parameters);

            GUIMessage.MessageType type = (GUIMessage.MessageType)Enum.Parse(typeof(GUIMessage.MessageType), processed[0]);
            int windowId  = int.Parse(processed[1]);
            int senderId  = int.Parse(processed[2]);
            int controlId = int.Parse(processed[3]);
            int param1    = int.Parse(processed[4]);
            int param2    = int.Parse(processed[5]);

            GUIMessage message = new GUIMessage(type, windowId, senderId, controlId, param1, param2, null);

            GUIGraphicsContext.ResetLastActivity();
            GUIWindowManager.SendThreadMessage(message);
        }
예제 #9
0
 void airplayServer_ShowPhoto(object sender, PhotoEventArgs e)
 {
     invoke(delegate()
     {
         //When playing a video from the camera roll the client sends a thumbnail before the video.
         //Occasionally we receive it after due to threading so we should ignore it if we have just started playing a video.
         if (!isVideoPlaying || DateTime.Now.Subtract(videoReceiveTime).TotalSeconds > 2)
         {
             if (photoWindow != null)
             {
                 photoSessionId = e.SessionId;
                 photoWindow.SetPhoto(e.AssetKey, e.Photo);
                 GUIGraphicsContext.ResetLastActivity();
                 if (GUIWindowManager.ActiveWindow != PhotoWindow.WINDOW_ID)
                 {
                     GUIWindowManager.ActivateWindow(PhotoWindow.WINDOW_ID);
                 }
             }
         }
     }, false);
 }
        /// <summary>
        /// Suspend mediaportal and hide the window
        /// </summary>
        /// <param name="suspend"></param>
        void SuspendMP(bool suspend)
        {
            if (suspend && _mpWindowHidden)
            {
                return;                             // Should already be suspended
            }
            if (!suspend && !_mpWindowHidden)
            {
                return;              // Should already be visible
            }
            if (suspend)             //suspend and hide MediaPortal
            {
                InputDevices.Stop(); //stop input devices so they don't interfere when the browser player starts listening
                GUIWindowManager.OnNewAction += GUIWindowManager_OnNewAction;

                // Minimise MePo to tray - this is preferrable
                ToggleMinimise(true);

                _mpWindowHidden = true;
            }
            else //resume Mediaportal
            {
                GUIWindowManager.OnNewAction -= GUIWindowManager_OnNewAction;

                InputDevices.Init();

                // Resume Mediaportal rendering
                ToggleMinimise(false);

                ProcessHelper.SetForeground("mediaportal");

                GUIGraphicsContext.ResetLastActivity();


                _mpWindowHidden = false;
            }
        }
예제 #11
0
        /// <summary>
        /// Takes a MediaPortal window name or window number and activates it.
        /// </summary>
        /// <param name="screen">MediaPortal window name or number.</param>
        /// <param name="useBasicHome">Use the basic home screen when home is requested.</param>
        public static void ProcessGoTo(string screen, bool useBasicHome)
        {
            if (String.IsNullOrEmpty(screen))
            {
                throw new ArgumentNullException("screen");
            }

            int window = (int)GUIWindow.Window.WINDOW_INVALID;

            try
            {
                window = (int)Enum.Parse(typeof(GUIWindow.Window), "WINDOW_" + screen, true);
            }
            catch (ArgumentException)
            {
                // Parsing the window id as a GUIWindow.Window failed, so parse it as an int
            }

            if (window == (int)GUIWindow.Window.WINDOW_INVALID)
            {
                int.TryParse(screen, out window);
            }

            if (window == (int)GUIWindow.Window.WINDOW_INVALID)
            {
                throw new ArgumentException(String.Format("Failed to parse Goto command window id \"{0}\"", screen), "screen");
            }

            if (window == (int)GUIWindow.Window.WINDOW_HOME && useBasicHome)
            {
                window = (int)GUIWindow.Window.WINDOW_SECOND_HOME;
            }

            GUIGraphicsContext.ResetLastActivity();
            GUIWindowManager.SendThreadMessage(new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, window, 0,
                                                              null));
        }
예제 #12
0
        private void OnHDPlayerExited(object obj, EventArgs e)
        {
            // Restore refresh rate if it was changed
            if (MovingPicturesCore.Settings.UseDynamicRefreshRateChangerWithExternalPlayer && RefreshRateChanger.RefreshRateChangePending)
            {
                RefreshRateChanger.AdaptRefreshRate();
            }

            // enable mediaportal input devices
            InputDevices.InputDevices.Init();

            // show mediaportal and start rendering
            GUIGraphicsContext.BlankScreen = false;
            GUIGraphicsContext.form.Show();
            GUIGraphicsContext.ResetLastActivity();
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null);

            GUIWindowManager.SendThreadMessage(msg);
            GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.RUNNING;
            logger.Info("HD Playback: The external player has exited.");

            // call the logic for when an external player exits
            onExternalExit();
        }
예제 #13
0
        /// <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))
                {
                    if (_basicHome)
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
                                             (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null);
                    }
                    else
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
                                             (int)GUIWindow.Window.WINDOW_HOME, 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;
                }
                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);
        }
예제 #14
0
        /// <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);
        }
예제 #15
0
        /// <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);
            }

            Log.Debug("{0} / {1} / {2} / {3}", map.Condition, map.ConProperty, map.Command, map.CmdProperty);

            Action action;

            if (map.Sound != string.Empty) // && !g_Player.Playing)
            {
                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);
                return(true);
            }
            switch (map.Command)
            {
            case "ACTION": // execute Action x
                Key key = new Key(map.CmdKeyChar, map.CmdKeyCode);

                Log.Debug("Executing: key {0} / {1} / Action: {2} / {3}", map.CmdKeyChar, map.CmdKeyCode, map.CmdProperty,
                          ((Action.ActionType)Convert.ToInt32(map.CmdProperty)).ToString());

                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))
                {
                    if (_basicHome)
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
                                             (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null);
                    }
                    else
                    {
                        msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0,
                                             (int)GUIWindow.Window.WINDOW_HOME, 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();

                    //Stop all media before suspending or hibernating
                    if (g_Player.Playing)
                    {
                        GUIWindowManager.SendThreadCallbackAndWait(StopPlayback, 0, 0, null);
                    }

                    // this is all handled in mediaportal.cs - OnSuspend

                    /*
                     * if (_basicHome)
                     * msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null);
                     * else
                     * msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0, null);
                     *
                     * GUIWindowManager.SendThreadMessage(msg);
                     */
                }

                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":
                    // we need a slow standby (force=false), in order to have the onsuspend method being called on mediportal.cs
                    // this is needed in order to have "ShowLastActiveModule" working correctly.
                    // also using force=true results in a silent non critical D3DERR_DEVICELOST exception when resuming from powerstate.
                    MPControlPlugin.OnSuspend();
                    WindowsController.ExitWindows(RestartOptions.Suspend, false);
                    break;

                case "HIBERNATE":
                    // we need a slow hibernation (force=false), in order to have the onsuspend method being called on mediportal.cs
                    // this is needed in order to have "ShowLastActiveModule" working correctly.
                    // also using force=true results in a silent non critical D3DERR_DEVICELOST exception when resuming from powerstate.
                    MPControlPlugin.OnSuspend();
                    WindowsController.ExitWindows(RestartOptions.Hibernate, false);
                    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;

            case "BLAST":
                MPControlPlugin.ProcessCommand(map.CmdProperty, true);
                break;

            default:
                return(false);
            }
            return(true);
        }