Esempio n. 1
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            if (listViewExternalCommands.SelectedIndices.Count == 0 || comboBoxCommands.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = comboBoxCommands.SelectedItem as string;
                string newCommand = null;

                if (selected.Equals(Common.UITextRun, StringComparison.OrdinalIgnoreCase))
                {
                    ExternalProgram externalProgram = new ExternalProgram(ParameterInfo);
                    if (externalProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixRun + externalProgram.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextSerial, StringComparison.OrdinalIgnoreCase))
                {
                    SerialCommand serialCommand = new SerialCommand(ParameterInfo);
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    MessageCommand messageCommand = new MessageCommand();
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand();
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand();
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    BlastCommand blastCommand = new BlastCommand(
                        TV3BlasterPlugin.BlastIR,
                        Common.FolderIRCommands,
                        TV3BlasterPlugin.TransceiverInformation.Ports,
                        selected.Substring(Common.CmdPrefixBlast.Length));

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = selected;
                }
                else
                {
                    throw new CommandStructureException(String.Format("Invalid command in STB Setup: {0}", selected));
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    foreach (ListViewItem item in listViewExternalCommands.SelectedItems)
                    {
                        item.SubItems[1].Text = newCommand;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                MessageBox.Show(this, ex.Message, "Failed to set command", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            switch (tabControl.SelectedTab.Name)
            {
            case "tabPageBlastIR":
            {
                textBoxCommand.Text = _command =
                    String.Format("{0}{1}|{2}",
                                  Common.CmdPrefixBlast,
                                  comboBoxIRCode.SelectedItem as string,
                                  comboBoxPort.SelectedItem as string);
                break;
            }

            case "tabPageMacro":
            {
                textBoxCommand.Text = _command = Common.CmdPrefixMacro + comboBoxMacro.SelectedItem;
                break;
            }

            case "tabPageSerial":
            {
                textBoxCommand.Text = _command =
                    String.Format("{0}{1}|{2}|{3}|{4}|{5}|{6}|{7}",
                                  Common.CmdPrefixSerial,
                                  textBoxSerialCommand.Text,
                                  comboBoxComPort.SelectedItem as string,
                                  numericUpDownBaudRate.Value,
                                  comboBoxParity.SelectedItem as string,
                                  numericUpDownDataBits.Value,
                                  comboBoxStopBits.SelectedItem as string,
                                  checkBoxWaitForResponse.Checked);
                break;
            }

            case "tabPageProgram":
            {
                textBoxCommand.Text = _command =
                    String.Format("{0}{1}|{2}|{3}|{4}|{5}|{6}|False|{7}",
                                  Common.CmdPrefixRun,
                                  textBoxApp.Text,
                                  textBoxAppStartFolder.Text,
                                  textBoxApplicationParameters.Text,
                                  comboBoxWindowStyle.SelectedItem as string,
                                  checkBoxNoWindow.Checked,
                                  checkBoxShellExecute.Checked,
                                  checkBoxForceFocus.Checked);
                break;
            }

            case "tabPageMessage":
            {
                string target = "ERROR";

                if (radioButtonActiveWindow.Checked)
                {
                    target = Common.TargetActive;
                    textBoxMsgTarget.Text = "*";
                }
                else if (radioButtonApplication.Checked)
                {
                    target = Common.TargetApplication;
                }
                else if (radioButtonClass.Checked)
                {
                    target = Common.TargetClass;
                }
                else if (radioButtonWindowTitle.Checked)
                {
                    target = Common.TargetWindow;
                }

                textBoxCommand.Text = _command =
                    String.Format("{0}{1}|{2}|{3}|{4}|{5}",
                                  Common.CmdPrefixWindowMsg,
                                  target,
                                  textBoxMsgTarget.Text,
                                  numericUpDownMsg.Value,
                                  numericUpDownWParam.Value,
                                  numericUpDownLParam.Value);
                break;
            }

            case "tabPageKeystrokes":
            {
                textBoxCommand.Text = _command = Common.CmdPrefixKeys + keystrokeCommandPanel.CommandString;
                break;
            }

            case "tabPageMouse":
            {
                StringBuilder newCommand = new StringBuilder();
                newCommand.Append(Common.CmdPrefixMouse);

                if (checkBoxMouseClickLeft.Checked)
                {
                    newCommand.Append(Common.MouseClickLeft);
                }
                else if (checkBoxMouseClickRight.Checked)
                {
                    newCommand.Append(Common.MouseClickRight);
                }
                else if (checkBoxMouseClickMiddle.Checked)
                {
                    newCommand.Append(Common.MouseClickMiddle);
                }
                else if (checkBoxMouseScrollUp.Checked)
                {
                    newCommand.Append(Common.MouseScrollUp);
                }
                else if (checkBoxMouseScrollDown.Checked)
                {
                    newCommand.Append(Common.MouseScrollDown);
                }
                else
                {
                    if (checkBoxMouseMoveUp.Checked)
                    {
                        newCommand.Append(Common.MouseMoveUp);
                    }
                    else if (checkBoxMouseMoveDown.Checked)
                    {
                        newCommand.Append(Common.MouseMoveDown);
                    }
                    else if (checkBoxMouseMoveLeft.Checked)
                    {
                        newCommand.Append(Common.MouseMoveLeft);
                    }
                    else if (checkBoxMouseMoveRight.Checked)
                    {
                        newCommand.Append(Common.MouseMoveRight);
                    }
                    else
                    {
                        break;
                    }

                    newCommand.Append(numericUpDownMouseMove.Value.ToString());
                }

                textBoxCommand.Text = _command = newCommand.ToString();
                break;
            }

            case "tabPageMisc":
            {
                switch (comboBoxMiscCommand.SelectedItem as string)
                {
                case Common.UITextTranslator:
                    textBoxCommand.Text = _command = Common.CmdPrefixTranslator;
                    break;

                case Common.UITextVirtualKB:
                    textBoxCommand.Text = _command = Common.CmdPrefixVirtualKB;
                    break;

                case Common.UITextSmsKB:
                    textBoxCommand.Text = _command = Common.CmdPrefixSmsKB;
                    break;

                case Common.UITextTcpMsg:
                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand();
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                    break;

                case Common.UITextHttpMsg:
                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand();
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                    break;

                case Common.UITextEject:
                    EjectCommand ejectCommand = new EjectCommand();
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                    break;

                case Common.UITextPopup:
                    PopupMessage popupMessage = new PopupMessage();
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixPopup + popupMessage.CommandString;
                    }
                    break;

                case Common.UITextStandby:
                    textBoxCommand.Text = _command = Common.CmdPrefixStandby;
                    break;

                case Common.UITextHibernate:
                    textBoxCommand.Text = _command = Common.CmdPrefixHibernate;
                    break;

                case Common.UITextReboot:
                    textBoxCommand.Text = _command = Common.CmdPrefixReboot;
                    break;

                case Common.UITextShutdown:
                    textBoxCommand.Text = _command = Common.CmdPrefixShutdown;
                    break;

                case Common.UITextBeep:
                    BeepCommand beepCommand = new BeepCommand();
                    if (beepCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixBeep + beepCommand.CommandString;
                    }
                    break;

                case Common.UITextSound:
                    OpenFileDialog openFileDialog = new OpenFileDialog();
                    openFileDialog.Filter      = "Wave Files|*.wav";
                    openFileDialog.Multiselect = false;

                    if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        textBoxCommand.Text = Common.CmdPrefixSound + openFileDialog.FileName;
                    }
                    break;
                }

                break;
            }
            }
        }
Esempio n. 3
0
        private void listViewExternalCommands_DoubleClick(object sender, EventArgs e)
        {
            if (listViewExternalCommands.SelectedIndices.Count != 1)
            {
                return;
            }

            try
            {
                string selected   = listViewExternalCommands.SelectedItems[0].SubItems[1].Text;
                string newCommand = null;

                if (selected.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBlastCommand(selected.Substring(Common.CmdPrefixBlast.Length));

                    BlastCommand blastCommand = new BlastCommand(
                        TV3BlasterPlugin.BlastIR,
                        Common.FolderIRCommands,
                        TV3BlasterPlugin.TransceiverInformation.Ports,
                        commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixSTB, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBlastCommand(selected.Substring(Common.CmdPrefixSTB.Length));

                    BlastCommand blastCommand = new BlastCommand(
                        TV3BlasterPlugin.BlastIR,
                        Common.FolderSTB,
                        TV3BlasterPlugin.TransceiverInformation.Ports,
                        commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSTB + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitRunCommand(selected.Substring(Common.CmdPrefixRun.Length));

                    ExternalProgram executeProgram = new ExternalProgram(commands, ParameterInfo);
                    if (executeProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixRun + executeProgram.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitSerialCommand(selected.Substring(Common.CmdPrefixSerial.Length));

                    SerialCommand serialCommand = new SerialCommand(commands, ParameterInfo);
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitWindowMessageCommand(selected.Substring(Common.CmdPrefixWindowMsg.Length));

                    MessageCommand messageCommand = new MessageCommand(commands);
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitTcpMessageCommand(selected.Substring(Common.CmdPrefixTcpMsg.Length));

                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(commands);
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitHttpMessageCommand(selected.Substring(Common.CmdPrefixHttpMsg.Length));

                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand(commands);
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    listViewExternalCommands.SelectedItems[0].SubItems[1].Text = newCommand;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                MessageBox.Show(this, ex.Message, "Failed to edit command", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void listBoxCommandSequence_DoubleClick(object sender, EventArgs e)
        {
            if (listBoxMacro.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = listBoxMacro.SelectedItem as string;
                string newCommand = null;

                if (selected.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitRunCommand(selected.Substring(Common.CmdPrefixRun.Length));

                    ExternalProgram executeProgram = new ExternalProgram(commands);
                    if (executeProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixRun + executeProgram.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixPause, StringComparison.OrdinalIgnoreCase))
                {
                    PauseTime pauseTime = new PauseTime(int.Parse(selected.Substring(Common.CmdPrefixPause.Length)));
                    if (pauseTime.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixPause + pauseTime.Time;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitSerialCommand(selected.Substring(Common.CmdPrefixSerial.Length));

                    SerialCommand serialCommand = new SerialCommand(commands);
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitWindowMessageCommand(selected.Substring(Common.CmdPrefixWindowMsg.Length));

                    MessageCommand messageCommand = new MessageCommand(commands);
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitTcpMessageCommand(selected.Substring(Common.CmdPrefixTcpMsg.Length));

                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(commands);
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitHttpMessageCommand(selected.Substring(Common.CmdPrefixHttpMsg.Length));

                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand(commands);
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase))
                {
                    KeysCommand keysCommand = new KeysCommand(selected.Substring(Common.CmdPrefixKeys.Length));
                    if (keysCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixKeys + keysCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase))
                {
                    MouseCommand mouseCommand = new MouseCommand(selected.Substring(Common.CmdPrefixMouse.Length));
                    if (mouseCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixMouse + mouseCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase))
                {
                    EjectCommand ejectCommand = new EjectCommand(selected.Substring(Common.CmdPrefixEject.Length));
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBlastCommand(selected.Substring(Common.CmdPrefixBlast.Length));

                    BlastCommand blastCommand = new BlastCommand(
                        TV3BlasterPlugin.BlastIR,
                        Common.FolderIRCommands,
                        TV3BlasterPlugin.TransceiverInformation.Ports,
                        commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    int index = listBoxMacro.SelectedIndex;
                    listBoxMacro.Items.RemoveAt(index);
                    listBoxMacro.Items.Insert(index, newCommand);
                    listBoxMacro.SelectedIndex = index;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void buttonAddCommand_Click(object sender, EventArgs e)
        {
            if (comboBoxCommands.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = comboBoxCommands.SelectedItem as string;
                string newCommand = null;

                if (selected.Equals(Common.UITextRun, StringComparison.OrdinalIgnoreCase))
                {
                    ExternalProgram externalProgram = new ExternalProgram();
                    if (externalProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixRun + externalProgram.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextPause, StringComparison.OrdinalIgnoreCase))
                {
                    PauseTime pauseTime = new PauseTime();
                    if (pauseTime.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixPause + pauseTime.Time;
                    }
                }
                else if (selected.Equals(Common.UITextSerial, StringComparison.OrdinalIgnoreCase))
                {
                    SerialCommand serialCommand = new SerialCommand();
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    MessageCommand messageCommand = new MessageCommand();
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand();
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand();
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextKeys, StringComparison.OrdinalIgnoreCase))
                {
                    KeysCommand keysCommand = new KeysCommand();
                    if (keysCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixKeys + keysCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextEject, StringComparison.OrdinalIgnoreCase))
                {
                    EjectCommand ejectCommand = new EjectCommand();
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextStandby, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixStandby;
                }
                else if (selected.Equals(Common.UITextHibernate, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixHibernate;
                }
                else if (selected.Equals(Common.UITextReboot, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixReboot;
                }
                else if (selected.Equals(Common.UITextShutdown, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixShutdown;
                }
                else if (selected.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    BlastCommand blastCommand = new BlastCommand(
                        TV3BlasterPlugin.BlastIR,
                        Common.FolderIRCommands,
                        TV3BlasterPlugin.TransceiverInformation.Ports,
                        selected.Substring(Common.CmdPrefixBlast.Length));

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = selected;
                }
                else
                {
                    throw new CommandStructureException(String.Format("Unknown command in macro command list \"{0}\"", selected));
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    listBoxMacro.Items.Add(newCommand);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        private void listBoxCommandSequence_DoubleClick(object sender, EventArgs e)
        {
            if (listBoxMacro.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = listBoxMacro.SelectedItem as string;
                string newCommand = null;

                if (selected.StartsWith(IrssUtils.Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitRunCommand(selected.Substring(IrssUtils.Common.CmdPrefixRun.Length));

                    ExternalProgram executeProgram = new ExternalProgram(commands);
                    if (executeProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixRun + executeProgram.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixPause, StringComparison.OrdinalIgnoreCase))
                {
                    PauseTime pauseTime = new PauseTime(int.Parse(selected.Substring(IrssUtils.Common.CmdPrefixPause.Length)));
                    if (pauseTime.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixPause + pauseTime.Time;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitSerialCommand(selected.Substring(IrssUtils.Common.CmdPrefixSerial.Length));

                    SerialCommand serialCommand = new SerialCommand(commands);
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitWindowMessageCommand(selected.Substring(IrssUtils.Common.CmdPrefixWindowMsg.Length));

                    MessageCommand messageCommand = new MessageCommand(commands);
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitTcpMessageCommand(selected.Substring(IrssUtils.Common.CmdPrefixTcpMsg.Length));

                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(commands);
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitHttpMessageCommand(selected.Substring(IrssUtils.Common.CmdPrefixHttpMsg.Length));

                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand(commands);
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase))
                {
                    KeysCommand keysCommand = new KeysCommand(selected.Substring(IrssUtils.Common.CmdPrefixKeys.Length));
                    if (keysCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixKeys + keysCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase))
                {
                    MouseCommand mouseCommand = new MouseCommand(selected.Substring(IrssUtils.Common.CmdPrefixMouse.Length));
                    if (mouseCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixMouse + mouseCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase))
                {
                    EjectCommand ejectCommand = new EjectCommand(selected.Substring(IrssUtils.Common.CmdPrefixEject.Length));
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixPopup, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitPopupCommand(selected.Substring(IrssUtils.Common.CmdPrefixPopup.Length));

                    PopupMessage popupMessage = new PopupMessage(commands);
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixPopup + popupMessage.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixGotoScreen, StringComparison.OrdinalIgnoreCase))
                {
                    GoToScreen goToScreen = new GoToScreen(selected.Substring(IrssUtils.Common.CmdPrefixGotoScreen.Length));
                    if (goToScreen.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixSendMPAction, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitSendMPActionCommand(selected.Substring(IrssUtils.Common.CmdPrefixSendMPAction.Length));

                    MPAction edit = new MPAction(commands);
                    if (edit.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSendMPAction + edit.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixSendMPMsg, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitSendMPMsgCommand(selected.Substring(IrssUtils.Common.CmdPrefixSendMPMsg.Length));

                    MPMessage edit = new MPMessage(commands);
                    if (edit.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSendMPMsg + edit.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixBeep, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitBeepCommand(selected.Substring(IrssUtils.Common.CmdPrefixBeep.Length));

                    BeepCommand beepCommand = new BeepCommand(commands);
                    if (beepCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixBeep + beepCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixSound, StringComparison.OrdinalIgnoreCase))
                {
                    OpenFileDialog openFileDialog = new OpenFileDialog();
                    openFileDialog.Filter      = "Wave Files|*.wav";
                    openFileDialog.Multiselect = false;
                    openFileDialog.FileName    = selected.Substring(IrssUtils.Common.CmdPrefixSound.Length);

                    if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSound + openFileDialog.FileName;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixDisplayMode, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitDisplayModeCommand(selected.Substring(IrssUtils.Common.CmdPrefixDisplayMode.Length));

                    DisplayModeCommand displayModeCommand = new DisplayModeCommand(commands);
                    if (displayModeCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixDisplayMode + displayModeCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = IrssUtils.Common.SplitBlastCommand(selected.Substring(IrssUtils.Common.CmdPrefixBlast.Length));

                    BlastCommand blastCommand = new BlastCommand(
                        MPBlastZonePlugin.BlastIR,
                        IrssUtils.Common.FolderIRCommands,
                        MPBlastZonePlugin.TransceiverInformation.Ports,
                        commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    int index = listBoxMacro.SelectedIndex;
                    listBoxMacro.Items.RemoveAt(index);
                    listBoxMacro.Items.Insert(index, newCommand);
                    listBoxMacro.SelectedIndex = index;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 7
0
        private void buttonAddCommand_Click(object sender, EventArgs e)
        {
            if (comboBoxCommands.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = comboBoxCommands.SelectedItem as string;
                string newCommand = null;

                if (selected.Equals(IrssUtils.Common.UITextRun, StringComparison.OrdinalIgnoreCase))
                {
                    ExternalProgram externalProgram = new ExternalProgram();
                    if (externalProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixRun + externalProgram.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextPause, StringComparison.OrdinalIgnoreCase))
                {
                    PauseTime pauseTime = new PauseTime();
                    if (pauseTime.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixPause + pauseTime.Time;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextSerial, StringComparison.OrdinalIgnoreCase))
                {
                    SerialCommand serialCommand = new SerialCommand();
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    MessageCommand messageCommand = new MessageCommand();
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand();
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand();
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextKeys, StringComparison.OrdinalIgnoreCase))
                {
                    KeysCommand keysCommand = new KeysCommand();
                    if (keysCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixKeys + keysCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextMouse, StringComparison.OrdinalIgnoreCase))
                {
                    MouseCommand mouseCommand = new MouseCommand();
                    if (mouseCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixMouse + mouseCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextEject, StringComparison.OrdinalIgnoreCase))
                {
                    EjectCommand ejectCommand = new EjectCommand();
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextPopup, StringComparison.OrdinalIgnoreCase))
                {
                    PopupMessage popupMessage = new PopupMessage();
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixPopup + popupMessage.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextGotoScreen, StringComparison.OrdinalIgnoreCase))
                {
                    GoToScreen goToScreen = new GoToScreen();
                    if (goToScreen.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
                    }
                }

                /*
                 * else if (selected.Equals(IrssUtils.Common.UITextWindowState, StringComparison.OrdinalIgnoreCase))
                 * {
                 * newCommand = IrssUtils.Common.CmdPrefixWindowState;
                 * }
                 */
                else if (selected.Equals(IrssUtils.Common.UITextFocus, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixFocus;
                }
                else if (selected.Equals(IrssUtils.Common.UITextExit, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixExit;
                }
                else if (selected.Equals(IrssUtils.Common.UITextSendMPAction, StringComparison.OrdinalIgnoreCase))
                {
                    MPAction edit = new MPAction();
                    if (edit.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSendMPAction + edit.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextSendMPMsg, StringComparison.OrdinalIgnoreCase))
                {
                    MPMessage edit = new MPMessage();
                    if (edit.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSendMPMsg + edit.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextVirtualKB, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixVirtualKB;
                }
                else if (selected.Equals(IrssUtils.Common.UITextSmsKB, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixSmsKB;
                }
                else if (selected.Equals(IrssUtils.Common.UITextBeep, StringComparison.OrdinalIgnoreCase))
                {
                    BeepCommand beepCommand = new BeepCommand();
                    if (beepCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixBeep + beepCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextSound, StringComparison.OrdinalIgnoreCase))
                {
                    OpenFileDialog openFileDialog = new OpenFileDialog();
                    openFileDialog.Filter      = "Wave Files|*.wav";
                    openFileDialog.Multiselect = false;

                    if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixSound + openFileDialog.FileName;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextDisplayMode, StringComparison.OrdinalIgnoreCase))
                {
                    DisplayModeCommand displayModeCommand = new DisplayModeCommand();
                    if (displayModeCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixDisplayMode + displayModeCommand.CommandString;
                    }
                }
                else if (selected.Equals(IrssUtils.Common.UITextStandby, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixStandby;
                }
                else if (selected.Equals(IrssUtils.Common.UITextHibernate, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixHibernate;
                }
                else if (selected.Equals(IrssUtils.Common.UITextReboot, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixReboot;
                }
                else if (selected.Equals(IrssUtils.Common.UITextShutdown, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = IrssUtils.Common.CmdPrefixShutdown;
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    BlastCommand blastCommand = new BlastCommand(
                        MPBlastZonePlugin.BlastIR,
                        IrssUtils.Common.FolderIRCommands,
                        MPBlastZonePlugin.TransceiverInformation.Ports,
                        selected.Substring(IrssUtils.Common.CmdPrefixBlast.Length));

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = IrssUtils.Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(IrssUtils.Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = selected;
                }
                else
                {
                    throw new CommandStructureException(String.Format("Unknown command in macro command list \"{0}\"", selected));
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    listBoxMacro.Items.Add(newCommand);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
        private void buttonAddCommand_Click(object sender, EventArgs e)
        {
            if (comboBoxCommands.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                string selected   = comboBoxCommands.SelectedItem as string;
                string newCommand = null;

                if (selected.Equals(Common.UITextIf, StringComparison.OrdinalIgnoreCase))
                {
                    IfCommand ifCommand = new IfCommand();
                    if (ifCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixIf + ifCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog();
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixLabel + labelDialog.LabelName;
                    }
                }
                else if (selected.Equals(Common.UITextGotoLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog();
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixGotoLabel + labelDialog.LabelName;
                    }
                }
                else if (selected.Equals(Common.UITextSetVar, StringComparison.OrdinalIgnoreCase))
                {
                    SetVariableCommand setVariableCommand = new SetVariableCommand();
                    if (setVariableCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSetVar + setVariableCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextClearVars, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixClearVars;
                }
                else if (selected.Equals(Common.UITextLoadVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog = new VariablesFileDialog();
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixLoadVars + varsFileDialog.FileName;
                    }
                }
                else if (selected.Equals(Common.UITextSaveVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog = new VariablesFileDialog();
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSaveVars + varsFileDialog.FileName;
                    }
                }
                else if (selected.Equals(Common.UITextRun, StringComparison.OrdinalIgnoreCase))
                {
                    ExternalProgram externalProgram = new ExternalProgram();
                    if (externalProgram.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixRun + externalProgram.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextPause, StringComparison.OrdinalIgnoreCase))
                {
                    PauseTime pauseTime = new PauseTime();
                    if (pauseTime.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixPause + pauseTime.Time;
                    }
                }
                else if (selected.Equals(Common.UITextSerial, StringComparison.OrdinalIgnoreCase))
                {
                    SerialCommand serialCommand = new SerialCommand();
                    if (serialCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSerial + serialCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextWindowMsg, StringComparison.OrdinalIgnoreCase))
                {
                    MessageCommand messageCommand = new MessageCommand();
                    if (messageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextTcpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    TcpMessageCommand tcpMessageCommand = new TcpMessageCommand();
                    if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextHttpMsg, StringComparison.OrdinalIgnoreCase))
                {
                    HttpMessageCommand httpMessageCommand = new HttpMessageCommand();
                    if (httpMessageCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixHttpMsg + httpMessageCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextKeys, StringComparison.OrdinalIgnoreCase))
                {
                    KeysCommand keysCommand = new KeysCommand();
                    if (keysCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixKeys + keysCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextMouse, StringComparison.OrdinalIgnoreCase))
                {
                    MouseCommand mouseCommand = new MouseCommand();
                    if (mouseCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixMouse + mouseCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextEject, StringComparison.OrdinalIgnoreCase))
                {
                    EjectCommand ejectCommand = new EjectCommand();
                    if (ejectCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixEject + ejectCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextPopup, StringComparison.OrdinalIgnoreCase))
                {
                    PopupMessage popupMessage = new PopupMessage();
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixPopup + popupMessage.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextVirtualKB, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixVirtualKB;
                }
                else if (selected.Equals(Common.UITextSmsKB, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixSmsKB;
                }
                else if (selected.Equals(Common.UITextBeep, StringComparison.OrdinalIgnoreCase))
                {
                    BeepCommand beepCommand = new BeepCommand();
                    if (beepCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBeep + beepCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextSound, StringComparison.OrdinalIgnoreCase))
                {
                    OpenFileDialog openFileDialog = new OpenFileDialog();
                    openFileDialog.Filter      = "Wave Files|*.wav";
                    openFileDialog.Multiselect = false;

                    if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSound + openFileDialog.FileName;
                    }
                }
                else if (selected.Equals(Common.UITextDisplayMode, StringComparison.OrdinalIgnoreCase))
                {
                    DisplayModeCommand displayModeCommand = new DisplayModeCommand();
                    if (displayModeCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixDisplayMode + displayModeCommand.CommandString;
                    }
                }
                else if (selected.Equals(Common.UITextStandby, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixStandby;
                }
                else if (selected.Equals(Common.UITextHibernate, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixHibernate;
                }
                else if (selected.Equals(Common.UITextReboot, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixReboot;
                }
                else if (selected.Equals(Common.UITextShutdown, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = Common.CmdPrefixShutdown;
                }
                else if (selected.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    BlastCommand blastCommand = new BlastCommand(
                        Program.BlastIR,
                        Common.FolderIRCommands,
                        Program.TransceiverInformation.Ports,
                        selected.Substring(Common.CmdPrefixBlast.Length));

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (selected.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = selected;
                }
                else
                {
                    throw new CommandStructureException(String.Format("Unknown macro command ({0})", selected));
                }

                if (!String.IsNullOrEmpty(newCommand))
                {
                    listBoxMacro.Items.Add(newCommand);
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }