Ejemplo n.º 1
0
        protected virtual string GetArgument(int index, RCProcess.CustomCommandParser.CommandArg arg)
        {
            switch (arg.Type)
            {
            case RCProcess.CustomCommandParser.DataType.Date:
            {
                DateTimePicker dateTimePicker = this.controlArgs[index] as DateTimePicker;
                return(dateTimePicker.Value.ToString("yyyy/MM/dd HH:mm:ss"));
            }

            case RCProcess.CustomCommandParser.DataType.Boolean:
            {
                TwoRadioButton twoRadioButton = this.controlArgs[index] as TwoRadioButton;
                if (!twoRadioButton.Checked)
                {
                    return("0");
                }
                return("1");
            }

            default:
                return(this.controlArgs[index].Text);
            }
        }
Ejemplo n.º 2
0
        protected IEnumerable <CommandForm.ArgumentControl> SetArgPanel(Panel panel, RCProcess.CustomCommandParser command, IEnumerable <string> serverList)
        {
            panel.Controls.Clear();
            this.controlArgs.Clear();
            this.ctrlTotalSize = 0;
            foreach (RCProcess.CustomCommandParser.CommandArg arg in command.Arguments)
            {
                Label textLabel = new Label();
                textLabel.Text      = arg.Name;
                textLabel.TextAlign = ContentAlignment.MiddleCenter;
                textLabel.Location  = new Point(0, this.ctrlTotalSize);
                textLabel.Size      = new Size(100, 24);
                Control ctrl   = null;
                int     width  = panel.Size.Width - 120;
                int     height = 24;
                int     x      = 100;
                int     y      = this.ctrlTotalSize;
                switch (arg.Type)
                {
                case RCProcess.CustomCommandParser.DataType.Numeric:
                    ctrl = new Utility.NumericTextBox();
                    break;

                case RCProcess.CustomCommandParser.DataType.Date:
                    ctrl = new DateTimePicker();
                    ((DateTimePicker)ctrl).CustomFormat = "yyyy-MM-dd HH:mm:ss";
                    ((DateTimePicker)ctrl).Format       = DateTimePickerFormat.Custom;
                    break;

                case RCProcess.CustomCommandParser.DataType.Boolean:
                    ctrl = new TwoRadioButton();
                    break;

                case RCProcess.CustomCommandParser.DataType.ServerGroup:
                {
                    ctrl = new ComboBox();
                    ComboBox comboBox = ctrl as ComboBox;
                    comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                    if (serverList != null)
                    {
                        comboBox.Items.AddRange(serverList.ToArray <string>());
                    }
                    break;
                }

                case RCProcess.CustomCommandParser.DataType.LargeString:
                {
                    ctrl = new RichTextBox();
                    RichTextBox richTextBox = ctrl as RichTextBox;
                    richTextBox.Multiline = true;
                    x      = 20;
                    y      = this.ctrlTotalSize + 24;
                    height = 120;
                    width  = panel.Width - 40;
                    break;
                }

                default:
                    ctrl = new TextBox();
                    break;
                }
                if (ctrl != null)
                {
                    ctrl.Name     = arg.Name;
                    ctrl.Location = new Point(x, y);
                    ctrl.Size     = new Size(width, height);
                    ctrl.Anchor   = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                    new ToolTip
                    {
                        AutoPopDelay = 5000,
                        InitialDelay = 500,
                        ReshowDelay  = 250,
                        ShowAlways   = true
                    }.SetToolTip(ctrl, arg.Comment);
                    panel.Controls.Add(textLabel);
                    panel.Controls.Add(ctrl);
                    this.controlArgs.Add(ctrl);
                    yield return(new CommandForm.ArgumentControl(textLabel, ctrl, arg));
                }
                int sizeToIncrease = y - this.ctrlTotalSize + (ctrl.Visible ? height : 0);
                this.ctrlTotalSize += sizeToIncrease;
            }
            yield break;
        }