Пример #1
0
        private void CommandArgumentControl_ArgumentValueChanged(CommandArgumentControl control, IMacroCommandArgument argument, object newValue)
        {
            List <object> argumentValues = new List <object>();

            object[] argumentValuesArr = null;

            bool collecting = true;

            foreach (CommandArgumentControl argControl in commandArgumentControls)
            {
                if (collecting)
                {
                    argumentValues.Add(argControl.ArgumentValue);
                }
                else
                {
                    argControl.PreviousArgumentValues = argumentValuesArr;
                }

                if (argControl == control)
                {
                    collecting        = false;
                    argumentValuesArr = argumentValues.ToArray();
                }
            }
        }
Пример #2
0
        private void selectCommandComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            IMacroCommand selectedCommand = selectCommandComboBox.SelectedValue as IMacroCommand;

            commandDescriptionTextBox.Text = "";
            commandArgumentsPanel.Controls.Clear();
            foreach (CommandArgumentControl argControl in commandArgumentControls)
            {
                argControl.ArgumentValueChanged -= CommandArgumentControl_ArgumentValueChanged;
            }
            commandArgumentControls.Clear();

            addCommandButton.Enabled = (selectedCommand != null);

            if (selectedCommand != null)
            {
                commandDescriptionTextBox.Text = selectedCommand.Description;
                int i        = 0;
                int argCount = selectedCommand.Arguments.Length;
                foreach (IMacroCommandArgument arg in selectedCommand.Arguments)
                {
                    var argumentControl = new CommandArgumentControl(arg, i, (i == (argCount - 1)));
                    argumentControl.ArgumentValueChanged += CommandArgumentControl_ArgumentValueChanged;
                    commandArgumentControls.Add(argumentControl);
                    i++;
                }
            }

            for (int i = commandArgumentControls.Count - 1; i >= 0; i--)
            {
                CommandArgumentControl control = commandArgumentControls[i];
                commandArgumentsPanel.Controls.Add(control);
                control.Dock = DockStyle.Top;
            }
        }