コード例 #1
0
        private void ChangeMacro()
        {
            if (ListMacros.SelectedItem == null)
            {
                EnableMacroButtons();
                return;
            }

            var changeMacro = (Macro)ListMacros.SelectedItem;

            var configureMacro = new ConfigureMacro
                                     {
                                         MacroName = { Text = changeMacro.Name },
                                         MacroCommand = { Text = changeMacro.MacroCommand }
                                     };


            configureMacro.ShowDialog(this);
            if (configureMacro.DialogResult == DialogResult.OK)
            {
                if (MacroManager.Macros.Exists(m => !m.Equals(changeMacro) && m.Name.Equals(configureMacro.MacroName.Text, StringComparison.CurrentCultureIgnoreCase)))
                {
                    MessageBox.Show(string.Format("Macro with name {0} already exists", configureMacro.MacroName.Text));
                }
                else
                {
                    changeMacro.Name = configureMacro.MacroName.Text;
                    changeMacro.MacroCommand = configureMacro.MacroCommand.Text;
                }
            }

            RefreshMacrosList();
        }
コード例 #2
0
 private void AddMacroCommand_Click(object sender, EventArgs e)
 {
     var configureMacro = new ConfigureMacro();
     configureMacro.ShowDialog(this);
     if (configureMacro.DialogResult == DialogResult.OK)
     {
         if (MacroManager.Macros.Exists(m => m.Name.Equals(configureMacro.MacroName.Text, StringComparison.CurrentCultureIgnoreCase)))
         {
             MessageBox.Show(string.Format("Macro with name {0} already exists", configureMacro.MacroName.Text));
         }
         else
         {
             var newMacro = new Macro(configureMacro.MacroName.Text)
             {
                 MacroCommand = configureMacro.MacroCommand.Text
             };
             MacroManager.Macros.Add(newMacro);
             RefreshMacrosList();
         }
     }
 }