Exemple #1
0
        private void RefreshEventMapperCommands()
        {
            comboBoxCommands.Items.Clear();

            comboBoxCommands.Items.Add(IrssUtils.Common.UITextRun);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSerial);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextWindowMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextTcpMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextKeys);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextEject);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextGotoScreen);
            //comboBoxCommands.Items.Add(IrssUtils.Common.UITextWindowState);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextExit);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextStandby);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextHibernate);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextReboot);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextShutdown);

            string[] fileList = MPControlPlugin.GetFileList(true);

            if (fileList != null && fileList.Length > 0)
            {
                comboBoxCommands.Items.AddRange(fileList);
            }
        }
        private void buttonTest_Click(object sender, EventArgs e)
        {
            string name = textBoxName.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            if (!IrssUtils.Common.IsValidFileName(name))
            {
                MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                textBoxName.Focus();
                return;
            }

            try
            {
                string fileName = Path.Combine(MPControlPlugin.FolderMacros, name + IrssUtils.Common.FileExtensionMacro);
                WriteToFile(fileName);

                MPControlPlugin.ProcessCommand(IrssUtils.Common.CmdPrefixMacro + name, false);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void RefreshMacroList()
        {
            listViewMacro.Items.Clear();

            string[] macroList = MPControlPlugin.GetMacroList(false);
            if (macroList != null && macroList.Length > 0)
            {
                foreach (string macroFile in macroList)
                {
                    listViewMacro.Items.Add(macroFile);
                }
            }
        }
Exemple #4
0
        private void buttonChangeServer_Click(object sender, EventArgs e)
        {
            MPControlPlugin.StopClient();

            ServerAddress serverAddress = new ServerAddress(MPControlPlugin.ServerHost);

            serverAddress.ShowDialog(this);

            MPControlPlugin.ServerHost = serverAddress.ServerHost;

            IPAddress  serverIP = Network.GetIPFromName(MPControlPlugin.ServerHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            MPControlPlugin.StartClient(endPoint);
        }
Exemple #5
0
        private void buttonTestMacro_Click(object sender, EventArgs e)
        {
            if (listViewMacro.SelectedItems.Count != 1)
            {
                return;
            }

            try
            {
                MPControlPlugin.ProcessCommand(IrssUtils.Common.CmdPrefixMacro + listViewMacro.SelectedItems[0].Text, false);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void RefreshCommandList()
        {
            comboBoxCommands.Items.Clear();

            comboBoxCommands.Items.Add(IrssUtils.Common.UITextRun);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextPause);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSerial);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextWindowMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextTcpMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextHttpMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextKeys);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextMouse);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextEject);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextPopup);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextGotoScreen);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextMultiMap);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextMouseMode);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextInputLayer);
            //comboBoxCommands.Items.Add(Common.UITextWindowState);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextFocus);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextExit);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSendMPAction);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSendMPMsg);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextVirtualKB);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSmsKB);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextBeep);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextSound);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextDisplayMode);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextStandby);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextHibernate);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextReboot);
            comboBoxCommands.Items.Add(IrssUtils.Common.UITextShutdown);

            string[] fileList = MPControlPlugin.GetFileList(true);
            if (fileList != null && fileList.Length > 0)
            {
                comboBoxCommands.Items.AddRange(fileList);
            }
        }
Exemple #7
0
        private void SetupForm_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(MPControlPlugin.ServerHost))
            {
                ServerAddress serverAddress = new ServerAddress();
                serverAddress.ShowDialog(this);

                MPControlPlugin.ServerHost = serverAddress.ServerHost;
            }

            IPAddress  serverIP = Network.GetIPFromName(MPControlPlugin.ServerHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            if (!MPControlPlugin.StartClient(endPoint))
            {
                MessageBox.Show(this, "Failed to start local comms. IR functions temporarily disabled.",
                                "MP Control Plugin - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            checkBoxRequiresFocus.Checked = MPControlPlugin.RequireFocus;
            checkBoxMultiMapping.Checked  = MPControlPlugin.MultiMappingEnabled;
            checkBoxEventMapper.Checked   = MPControlPlugin.EventMapperEnabled;
            checkBoxMouseMode.Checked     = MPControlPlugin.MouseModeEnabled;

            RefreshIRList();
            RefreshMacroList();

            // Mouse Mode ...
            foreach (string button in Enum.GetNames(typeof(RemoteButton)))
            {
                if (!button.Equals("None", StringComparison.OrdinalIgnoreCase))
                {
                    comboBoxMouseModeButton.Items.Add(button);
                }
            }

            comboBoxMouseModeButton.SelectedItem = Enum.GetName(typeof(RemoteButton), MPControlPlugin.MouseModeButton);

            numericUpDownMouseStep.Value = new decimal(MPControlPlugin.MouseModeStep);

            checkBoxMouseAcceleration.Checked = MPControlPlugin.MouseModeAcceleration;

            // Multi-Mapping ...
            foreach (string button in Enum.GetNames(typeof(RemoteButton)))
            {
                if (!button.Equals("None", StringComparison.OrdinalIgnoreCase))
                {
                    comboBoxMultiButton.Items.Add(button);
                }
            }

            comboBoxMultiButton.SelectedItem = Enum.GetName(typeof(RemoteButton), MPControlPlugin.MultiMappingButton);

            foreach (string map in MPControlPlugin.MultiMaps)
            {
                listBoxMappings.Items.Add(map);
            }

            // Event Mapper ...
            RefreshEventMapperCommands();

            comboBoxEvents.Items.Clear();
            foreach (string eventType in Enum.GetNames(typeof(MappedEvent.MappingEvent)))
            {
                if (!eventType.Equals("None", StringComparison.OrdinalIgnoreCase))
                {
                    comboBoxEvents.Items.Add(eventType);
                }
            }

            // TODO: Add Enter/Exit screen events.
            //comboBoxEvents.Items.Add("Enter screen");
            //comboBoxEvents.Items.Add("Exit screen");

            comboBoxParameter.Items.Clear();
            comboBoxParameter.Items.Add("Ignore Parameters");
            comboBoxParameter.Items.Add("Label 1");
            comboBoxParameter.Items.Add("Label 2");
            comboBoxParameter.Items.Add("Label 3");
            comboBoxParameter.Items.Add("Label 4");
            comboBoxParameter.Items.Add("Parameter 1");
            comboBoxParameter.Items.Add("Parameter 2");
            comboBoxParameter.Items.Add("Parameter 3");
            comboBoxParameter.Items.Add("Parameter 4");
            comboBoxParameter.Items.Add("Send To Target Window");
            comboBoxParameter.Items.Add("Sender Control ID");
            comboBoxParameter.Items.Add("Target Control ID");
            comboBoxParameter.Items.Add("Target Window ID");
            comboBoxParameter.SelectedIndex = 0;

            LoadEvents();

            // Remote Control Presets ...
            comboBoxRemotePresets.Items.Clear();
            string[] presets = Directory.GetFiles(MPControlPlugin.RemotePresetsFolder, "*.xml", SearchOption.TopDirectoryOnly);
            foreach (string preset in presets)
            {
                comboBoxRemotePresets.Items.Add(Path.GetFileNameWithoutExtension(preset));
            }
            comboBoxRemotePresets.SelectedIndex = 0;

            // Load Remotes ...
            treeViewRemotes.Nodes.Clear();
            LoadRemotes(MPControlPlugin.RemotesFile);

            // Register for remote button presses
            _addNode = AddNode;

            MPControlPlugin.HandleMessage += ReceivedMessage;
        }
        /// <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);
        }