コード例 #1
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);
      }
    }
コード例 #2
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.ToString();
        }
        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.CmdPrefixPopup, StringComparison.OrdinalIgnoreCase))
        {
          string[] commands = Common.SplitPopupCommand(selected.Substring(Common.CmdPrefixPopup.Length));

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

          BlastCommand blastCommand = new BlastCommand(
            new BlastIrDelegate(Tray.BlastIR),
            Common.FolderIRCommands,
            Tray.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)
      {
        IrssLog.Error(ex);
        MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }
コード例 #3
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);
      }
    }
コード例 #4
0
    private void treeViewMenu_DoubleClick(object sender, EventArgs e)
    {
      if (treeViewMenu.SelectedNode == null)
        return;

      if (treeViewMenu.SelectedNode.Level != 2)
        return;

      string command = treeViewMenu.SelectedNode.Text;
      string newCommand = null;

      if (command.StartsWith(IrssUtils.Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitRunCommand(command.Substring(IrssUtils.Common.CmdPrefixRun.Length));
        ExternalProgram externalProgram = new ExternalProgram(commands);
        if (externalProgram.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixRun + externalProgram.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixGotoScreen, StringComparison.OrdinalIgnoreCase))
      {
        GoToScreen goToScreen = new GoToScreen(command.Substring(IrssUtils.Common.CmdPrefixGotoScreen.Length));
        if (goToScreen.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitSerialCommand(command.Substring(IrssUtils.Common.CmdPrefixSerial.Length));
        SerialCommand serialCommand = new SerialCommand(commands);
        if (serialCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixSerial + serialCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitWindowMessageCommand(command.Substring(IrssUtils.Common.CmdPrefixWindowMsg.Length));
        MessageCommand messageCommand = new MessageCommand(commands);
        if (messageCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixWindowMsg + messageCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitTcpMessageCommand(command.Substring(IrssUtils.Common.CmdPrefixTcpMsg.Length));
        TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(commands);
        if (tcpMessageCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitBlastCommand(command.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))
        treeViewMenu.SelectedNode.Text = newCommand;
    }
コード例 #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.ToString();
        }
        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.UITextWindowState, StringComparison.OrdinalIgnoreCase))
        {
          newCommand = Common.CmdPrefixWindowState;
        }
        */
        else if (selected.Equals(Common.UITextFocus, StringComparison.OrdinalIgnoreCase))
        {
          newCommand = Common.CmdPrefixFocus;
        }
        else if (selected.Equals(Common.UITextExit, StringComparison.OrdinalIgnoreCase))
        {
          newCommand = Common.CmdPrefixExit;
        }
        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(
            new BlastIrDelegate(Tray.BlastIR),
            Common.FolderIRCommands,
            Tray.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)
      {
        IrssLog.Error(ex);
        MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }
コード例 #6
0
    private void CommandPropChanged()
    {
      if ((string) comboBoxCmdProperty.SelectedItem == "Key Pressed")
        textBoxKeyChar.Enabled = textBoxKeyCode.Enabled = true;
      else
      {
        textBoxKeyChar.Enabled = textBoxKeyCode.Enabled = false;
        textBoxKeyChar.Text = textBoxKeyCode.Text = String.Empty;
      }

      TreeNode node = getNode("COMMAND");
      Data data = (Data) node.Tag;
      switch ((string) data.Parameter)
      {
        case "ACTION":
          if ((string) comboBoxCmdProperty.SelectedItem != "Key Pressed")
          {
            node.Tag = new Data("COMMAND", "ACTION",
                                (int)
                                Enum.Parse(typeof (Action.ActionType),
                                           GetActionName((string) comboBoxCmdProperty.SelectedItem)));
            node.Text = "Action \"" + (string) comboBoxCmdProperty.SelectedItem + "\"";
          }
          else
          {
            textBoxKeyChar.Text = "0";
            textBoxKeyCode.Text = "0";
            Key key = new Key(Convert.ToInt32(textBoxKeyChar.Text), Convert.ToInt32(textBoxKeyCode.Text));
            node.Tag = new Data("COMMAND", "KEY", key);
            node.Text = String.Format("Key Pressed: {0} [{1}]", textBoxKeyChar.Text, textBoxKeyCode.Text);
          }
          break;
        case "WINDOW":
          {
            int windowID;
            try
            {
              windowID = (int) Enum.Parse(typeof (GUIWindow.Window), GetWindowName(comboBoxCmdProperty.Text));
            }
            catch
            {
              windowID = Convert.ToInt32(comboBoxCmdProperty.Text);
            }

            node.Tag = new Data("COMMAND", "WINDOW", windowID);
            node.Text = "Window \"" + comboBoxCmdProperty.Text + "\"";
            break;
          }
        case "POWER":
          node.Tag = new Data("COMMAND", "POWER",
                              _nativePowerList[Array.IndexOf(_powerList, (string) comboBoxCmdProperty.SelectedItem)]);
          node.Text = (string) comboBoxCmdProperty.SelectedItem;
          break;
        case "PROCESS":
          node.Tag = new Data("COMMAND", "PROCESS",
                              _nativeProcessList[Array.IndexOf(_processList, (string) comboBoxCmdProperty.SelectedItem)]);
          node.Text = (string) comboBoxCmdProperty.SelectedItem;
          break;
        case "BLAST":
          {
            string text = (string) comboBoxCmdProperty.SelectedItem;
            if (text.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.InvariantCultureIgnoreCase))
            {
              BlastCommand blastCommand = new BlastCommand(
                MPControlPlugin.BlastIR,
                IrssUtils.Common.FolderIRCommands,
                MPControlPlugin.TransceiverInformation.Ports,
                text.Substring(IrssUtils.Common.CmdPrefixBlast.Length));

              if (blastCommand.ShowDialog(this) == DialogResult.OK)
              {
                string command = IrssUtils.Common.CmdPrefixBlast + blastCommand.CommandString;
                node.Tag = new Data("COMMAND", "BLAST", command);
                node.Text = command;
              }
            }
            else if (text.StartsWith(IrssUtils.Common.CmdPrefixMacro, StringComparison.InvariantCultureIgnoreCase))
            {
              node.Tag = new Data("COMMAND", "BLAST", text);
              node.Text = text;
            }
            break;
          }
      }
      ((Data) node.Tag).Focus = checkBoxGainFocus.Checked;
      _changedSettings = true;
    }
コード例 #7
0
    private void buttonSetCommand_Click(object sender, EventArgs e)
    {
      if (treeViewMenu.SelectedNode == null)
        return;

      TreeNode parent = treeViewMenu.SelectedNode;
      switch (treeViewMenu.SelectedNode.Level)
      {
        case 0:
          return;

        case 1:
          parent = treeViewMenu.SelectedNode;
          break;

        case 2:
          parent = treeViewMenu.SelectedNode.Parent;
          break;
      }

      if (comboBoxCommands.SelectedIndex == -1)
        return;

      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.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.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.UITextGotoScreen, StringComparison.OrdinalIgnoreCase))
      {
        GoToScreen goToScreen = new GoToScreen();
        if (goToScreen.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
      }
      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
      {
        newCommand = selected;
      }

      parent.Nodes.Clear();

      TreeNode newNode = new TreeNode(newCommand);
      newNode.ForeColor = Color.Blue;

      parent.Nodes.Add(newNode);
      newNode.EnsureVisible();
    }
コード例 #8
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);
      }
    }
コード例 #9
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);
      }
    }
コード例 #10
0
        /// <summary>
        /// Show the configuration window for the specified command with its arguments.
        /// </summary>
        /// <param name="cmdArgs">Command and its argument to be edited. </param>
        /// <returns>command with its arguments, or null if cancel or error</returns>
        public string CommandEdit(string cmdArgs)
        {
            string newCommand = null;
            if (String.IsNullOrEmpty(cmdArgs)) return null;

            try
            {
                
                if (cmdArgs.StartsWith(Common.CmdPrefixIf, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitIfCommand(cmdArgs.Substring(Common.CmdPrefixIf.Length));

                    IfCommand ifCommand = new IfCommand(commands);
                    if (ifCommand.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixIf + ifCommand.CommandString;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog(cmdArgs.Substring(Common.CmdPrefixLabel.Length));
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixLabel + labelDialog.LabelName;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixGotoLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog(cmdArgs.Substring(Common.CmdPrefixGotoLabel.Length));
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixGotoLabel + labelDialog.LabelName;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixSetVar, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitSetVarCommand(cmdArgs.Substring(Common.CmdPrefixSetVar.Length));

                    SetVariableCommand setVariableCommand = new SetVariableCommand(commands);
                    if (setVariableCommand.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixSetVar + setVariableCommand.CommandString;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixLoadVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog =
                      new VariablesFileDialog(cmdArgs.Substring(Common.CmdPrefixLoadVars.Length));
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixLoadVars + varsFileDialog.FileName;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixSaveVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog =
                      new VariablesFileDialog(cmdArgs.Substring(Common.CmdPrefixSaveVars.Length));
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixSaveVars + varsFileDialog.FileName;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitRunCommand(cmdArgs.Substring(Common.CmdPrefixRun.Length));

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

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

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

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

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

                    PopupMessage popupMessage = new PopupMessage(commands);
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixPopup + popupMessage.CommandString;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixBeep, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBeepCommand(cmdArgs.Substring(Common.CmdPrefixBeep.Length));

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

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

                    DisplayModeCommand displayModeCommand = new DisplayModeCommand(commands);
                    if (displayModeCommand.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixDisplayMode + displayModeCommand.CommandString;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBlastCommand(cmdArgs.Substring(Common.CmdPrefixBlast.Length));
                    string[] ports = null;
                    if (IRServer != null) ports = IRServer.Ports;
                    BlastCommand blastCommand = new BlastCommand(_BlastFunc, Common.FolderIRCommands, ports, commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = CommandFetch(cmdArgs, true);
                }
                else
                {
                    throw new CommandStructureException(String.Format("Unknown macro command ({0})", cmdArgs));
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return newCommand;
        }
コード例 #11
0
    public void SetToXml(string xmlFile)
    {
      if (xmlFile.Equals("Clear all", StringComparison.OrdinalIgnoreCase))
      {
        foreach (ListViewItem item in listViewExternalCommands.Items)
          item.SubItems[1].Text = String.Empty;

        return;
      }

      string fileName = Path.Combine(Common.FolderSTB, xmlFile + ".xml");

      XmlDocument doc = new XmlDocument();
      doc.Load(fileName);

      XmlNodeList nodeList = doc.DocumentElement.ChildNodes;

      string command;
      BlastCommand blastCommand;

      bool useForAllBlastCommands = false;
      string useForAllBlasterPort = String.Empty;

      int blastCommandCount = 0;
      for (int i = 0; i < 12; i++)
      {
        if (i == 10)
          command = XML.GetString(nodeList, "SelectCommand", String.Empty);
        else if (i == 11)
          command = XML.GetString(nodeList, "PreChangeCommand", String.Empty);
        else
          command = XML.GetString(nodeList, String.Format("Digit{0}", i), String.Empty);

        if (command.StartsWith(Common.CmdPrefixSTB, StringComparison.OrdinalIgnoreCase))
          blastCommandCount++;
      }

      for (int i = 0; i < 12; i++)
      {
        if (i == 10)
          command = XML.GetString(nodeList, "SelectCommand", String.Empty);
        else if (i == 11)
          command = XML.GetString(nodeList, "PreChangeCommand", String.Empty);
        else
          command = XML.GetString(nodeList, String.Format("Digit{0}", i), String.Empty);

        if (command.StartsWith(Common.CmdPrefixSTB, StringComparison.OrdinalIgnoreCase))
        {
          blastCommand = new BlastCommand(
            TV3BlasterPlugin.BlastIR,
            Common.FolderSTB,
            TV3BlasterPlugin.TransceiverInformation.Ports,
            command.Substring(Common.CmdPrefixSTB.Length),
            blastCommandCount--);

          if (useForAllBlastCommands)
          {
            blastCommand.BlasterPort = useForAllBlasterPort;
            listViewExternalCommands.Items[i].SubItems[1].Text = Common.CmdPrefixSTB + blastCommand.CommandString;
          }
          else
          {
            if (blastCommand.ShowDialog(this) == DialogResult.OK)
            {
              if (blastCommand.UseForAll)
              {
                useForAllBlastCommands = true;
                useForAllBlasterPort = blastCommand.BlasterPort;
              }
              listViewExternalCommands.Items[i].SubItems[1].Text = Common.CmdPrefixSTB + blastCommand.CommandString;
            }
            else
            {
              blastCommand = new BlastCommand(
                TV3BlasterPlugin.BlastIR,
                Common.FolderSTB,
                TV3BlasterPlugin.TransceiverInformation.Ports,
                command.Substring(Common.CmdPrefixSTB.Length));

              listViewExternalCommands.Items[i].SubItems[1].Text = Common.CmdPrefixSTB + blastCommand.CommandString;
            }
          }
        }
        else
        {
          listViewExternalCommands.Items[i].SubItems[1].Text = command;
        }
      }

      numericUpDownPauseTime.Value =
        new Decimal(XML.GetInt(nodeList, "PauseTime", Decimal.ToInt32(numericUpDownPauseTime.Value)));
      checkBoxUsePreChange.Checked = XML.GetBool(nodeList, "UsePreChangeCommand", checkBoxUsePreChange.Checked);
      checkBoxSendSelect.Checked = XML.GetBool(nodeList, "SendSelect", checkBoxSendSelect.Checked);
      checkBoxDoubleSelect.Checked = XML.GetBool(nodeList, "DoubleChannelSelect", checkBoxDoubleSelect.Checked);
      numericUpDownRepeat.Value =
        new Decimal(XML.GetInt(nodeList, "RepeatChannelCommands", Decimal.ToInt32(numericUpDownRepeat.Value)));
      numericUpDownRepeatDelay.Value =
        new Decimal(XML.GetInt(nodeList, "RepeatDelay", Decimal.ToInt32(numericUpDownRepeatDelay.Value)));

      int digitsWas = comboBoxChDigits.SelectedIndex;
      if (digitsWas > 0)
        digitsWas--;
      int digits = XML.GetInt(nodeList, "ChannelDigits", digitsWas);
      if (digits > 0)
        digits++;
      comboBoxChDigits.SelectedIndex = digits;
    }
コード例 #12
0
        /// <summary>
        /// Show the configuration window for the specified command with its arguments.
        /// </summary>
        /// <param name="cmdArgs">Command and its argument to be edited. </param>
        /// <returns>command with its arguments, or null if cancel or error</returns>
        public string CommandEdit(string cmdArgs)
        {
            string newCommand = null;

            if (String.IsNullOrEmpty(cmdArgs))
            {
                return(null);
            }

            try
            {
                if (cmdArgs.StartsWith(Common.CmdPrefixIf, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitIfCommand(cmdArgs.Substring(Common.CmdPrefixIf.Length));

                    IfCommand ifCommand = new IfCommand(commands);
                    if (ifCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixIf + ifCommand.CommandString;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog(cmdArgs.Substring(Common.CmdPrefixLabel.Length));
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixLabel + labelDialog.LabelName;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixGotoLabel, StringComparison.OrdinalIgnoreCase))
                {
                    LabelNameDialog labelDialog = new LabelNameDialog(cmdArgs.Substring(Common.CmdPrefixGotoLabel.Length));
                    if (labelDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixGotoLabel + labelDialog.LabelName;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixSetVar, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitSetVarCommand(cmdArgs.Substring(Common.CmdPrefixSetVar.Length));

                    SetVariableCommand setVariableCommand = new SetVariableCommand(commands);
                    if (setVariableCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSetVar + setVariableCommand.CommandString;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixLoadVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog =
                        new VariablesFileDialog(cmdArgs.Substring(Common.CmdPrefixLoadVars.Length));
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixLoadVars + varsFileDialog.FileName;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixSaveVars, StringComparison.OrdinalIgnoreCase))
                {
                    VariablesFileDialog varsFileDialog =
                        new VariablesFileDialog(cmdArgs.Substring(Common.CmdPrefixSaveVars.Length));
                    if (varsFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixSaveVars + varsFileDialog.FileName;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitRunCommand(cmdArgs.Substring(Common.CmdPrefixRun.Length));

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

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

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

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

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

                    PopupMessage popupMessage = new PopupMessage(commands);
                    if (popupMessage.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixPopup + popupMessage.CommandString;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixBeep, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBeepCommand(cmdArgs.Substring(Common.CmdPrefixBeep.Length));

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

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

                    DisplayModeCommand displayModeCommand = new DisplayModeCommand(commands);
                    if (displayModeCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixDisplayMode + displayModeCommand.CommandString;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
                {
                    string[] commands = Common.SplitBlastCommand(cmdArgs.Substring(Common.CmdPrefixBlast.Length));
                    string[] ports    = null;
                    if (IRServer != null)
                    {
                        ports = IRServer.Ports;
                    }
                    BlastCommand blastCommand = new BlastCommand(_BlastFunc, Common.FolderIRCommands, ports, commands);

                    if (blastCommand.ShowDialog(this) == DialogResult.OK)
                    {
                        newCommand = Common.CmdPrefixBlast + blastCommand.CommandString;
                    }
                }
                else if (cmdArgs.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
                {
                    newCommand = CommandFetch(cmdArgs, true);
                }
                else
                {
                    throw new CommandStructureException(String.Format("Unknown macro command ({0})", cmdArgs));
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
                MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(newCommand);
        }
コード例 #13
0
    private void listViewEventMap_DoubleClick(object sender, EventArgs e)
    {
      if (listViewEventMap.SelectedItems.Count != 1)
        return;

      string command = listViewEventMap.SelectedItems[0].SubItems[1].Text;

      if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length));
        ExternalProgram externalProgram = new ExternalProgram(commands);
        if (externalProgram.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixRun + externalProgram.CommandString;
      }
      else if (command.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = Common.SplitSerialCommand(command.Substring(Common.CmdPrefixSerial.Length));
        SerialCommand serialCommand = new SerialCommand(commands);
        if (serialCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixSerial + serialCommand.CommandString;
      }
      else if (command.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length));
        MessageCommand messageCommand = new MessageCommand(commands);
        if (messageCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
      }
      else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase))
      {
        KeysCommand keysCommand = new KeysCommand(command.Substring(Common.CmdPrefixKeys.Length));
        if (keysCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixKeys + keysCommand.CommandString;
      }
      else if (command.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length));

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

        if (blastCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixBlast + blastCommand.CommandString;
      }
      else
      {
        return;
      }

      listViewEventMap.SelectedItems[0].SubItems[1].Text = command;
    }
コード例 #14
0
    private void SetCommandToEvent(object sender, EventArgs e)
    {
      if (comboBoxCommands.SelectedIndex == -1 || listViewEventMap.SelectedItems.Count == 0)
        return;

      string selected = comboBoxCommands.SelectedItem as string;
      string command = String.Empty;

      if (selected.Equals(Common.UITextRun, StringComparison.OrdinalIgnoreCase))
      {
        ExternalProgram externalProgram = new ExternalProgram();

        if (externalProgram.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixRun + externalProgram.CommandString;
      }
      else if (selected.Equals(Common.UITextSerial, StringComparison.OrdinalIgnoreCase))
      {
        SerialCommand serialCommand = new SerialCommand();
        if (serialCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixSerial + serialCommand.CommandString;
      }
      else if (selected.Equals(Common.UITextWindowMsg, StringComparison.OrdinalIgnoreCase))
      {
        MessageCommand messageCommand = new MessageCommand();
        if (messageCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixWindowMsg + messageCommand.CommandString;
      }
      else if (selected.Equals(Common.UITextKeys, StringComparison.OrdinalIgnoreCase))
      {
        KeysCommand keysCommand = new KeysCommand();
        if (keysCommand.ShowDialog(this) == DialogResult.Cancel)
          return;

        command = Common.CmdPrefixKeys + keysCommand.CommandString;
      }
      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.Cancel)
          return;

        command = Common.CmdPrefixBlast + blastCommand.CommandString;
      }
      else if (selected.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase))
      {
        command = selected;
      }
      else
      {
        IrssLog.Error("Invalid command set in Events: {0}", selected);
        return;
      }

      foreach (ListViewItem listViewItem in listViewEventMap.SelectedItems)
        listViewItem.SubItems[1].Text = command;
    }
コード例 #15
0
ファイル: SetupForm.cs プロジェクト: Azzuro/IR-Server-Suite
    private void listViewEventMap_DoubleClick(object sender, EventArgs e)
    {
      if (listViewEventMap.SelectedItems.Count != 1)
        return;

      string command = listViewEventMap.SelectedItems[0].SubItems[1].Text;
      string newCommand = null;

      if (command.StartsWith(IrssUtils.Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitRunCommand(command.Substring(IrssUtils.Common.CmdPrefixRun.Length));
        ExternalProgram externalProgram = new ExternalProgram(commands);
        if (externalProgram.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixRun + externalProgram.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixGotoScreen, StringComparison.OrdinalIgnoreCase))
      {
        GoToScreen goToScreen = new GoToScreen(command.Substring(IrssUtils.Common.CmdPrefixGotoScreen.Length));
        if (goToScreen.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitSerialCommand(command.Substring(IrssUtils.Common.CmdPrefixSerial.Length));
        SerialCommand serialCommand = new SerialCommand(commands);
        if (serialCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixSerial + serialCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitWindowMessageCommand(command.Substring(IrssUtils.Common.CmdPrefixWindowMsg.Length));
        MessageCommand messageCommand = new MessageCommand(commands);
        if (messageCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixWindowMsg + messageCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase))
      {
        KeysCommand keysCommand = new KeysCommand(command.Substring(IrssUtils.Common.CmdPrefixKeys.Length));
        if (keysCommand.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixKeys + keysCommand.CommandString;
      }
      else if (command.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
      {
        string[] commands = IrssUtils.Common.SplitBlastCommand(command.Substring(IrssUtils.Common.CmdPrefixBlast.Length));

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

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

      if (!String.IsNullOrEmpty(newCommand))
        listViewEventMap.SelectedItems[0].SubItems[1].Text = newCommand;
    }
コード例 #16
0
ファイル: SetupForm.cs プロジェクト: Azzuro/IR-Server-Suite
    private void buttonSetCommand_Click(object sender, EventArgs e)
    {
      if (comboBoxCommands.SelectedIndex == -1)
        return;

      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.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.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.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.UITextGotoScreen, StringComparison.OrdinalIgnoreCase))
      {
        GoToScreen goToScreen = new GoToScreen();
        if (goToScreen.ShowDialog(this) == DialogResult.OK)
          newCommand = IrssUtils.Common.CmdPrefixGotoScreen + goToScreen.CommandString;
      }
      else if (selected.StartsWith(IrssUtils.Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase))
      {
        BlastCommand blastCommand = new BlastCommand(
          MPControlPlugin.BlastIR,
          IrssUtils.Common.FolderIRCommands,
          MPControlPlugin.TransceiverInformation.Ports,
          selected.Substring(IrssUtils.Common.CmdPrefixBlast.Length));

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

      foreach (ListViewItem listViewItem in listViewEventMap.SelectedItems)
        listViewItem.SubItems[1].Text = newCommand;
    }