public UserInput_UnasignedInteger(UserInputTagData _Data) { InitializeComponent(); Data = _Data; numericUpDown1.Value = (int)Data.Value; groupBox1.Text = Data.InputID; this.Tag = Data; }
public UserInput_Boolean(UserInputTagData _Data) { InitializeComponent(); Data = _Data; set = (bool)Data.Value; button1.Text = set ? "On" : "Off"; groupBox1.Text = Data.InputID; this.Tag = Data; }
public UserInput_String(UserInputTagData _Data) { InitializeComponent(); Data = _Data; if (!string.IsNullOrEmpty(Data.Value as string)) { richTextBox1.Text = (string)Data.Value; } groupBox1.Text = Data.InputID; this.Tag = Data; }
private void addButton_Click(object sender, EventArgs e) { if (SelectedHandler == null) { MessageBox.Show("Select a command"); return; } if (FlagTextbox.Text == string.Empty) { MessageBox.Show("Enter a flag"); return; } var objectData = new Dictionary <string, object>(); if (hasUserInput) { foreach (Control c in UserInputPanel.Controls) { UserInputTagData data = c.Tag as UserInputTagData; if (data == null) { continue; } if (objectData.ContainsKey(data.InputID)) { continue; } if (data.InputType == typeof(string) && string.IsNullOrEmpty((string)data.Value)) { MessageBox.Show(string.Format("Enter a value for \"{0}\".", data.InputID)); return; } objectData.Add(data.InputID, data.Value); } } NewCommand = new RegisteredCommand(FlagTextbox.Text, SelectedHandler); NewCommand.IsModOnly = modOnly.Checked; NewCommand.FlagIsRegex = Isregex.Checked; NewCommand.FlagIsCaseSensitive = CaseSensitive.Checked; if (objectData.Count > 0) { NewCommand.UserDataInput = new UserData(objectData); } else { NewCommand.UserDataInput = null; } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
void LoadUserInput(UserData data = null) { UserInput[] UserData = null; if (SelectedHandler != null) { UserData = SelectedHandler.Command.UserData; } userInputHeight = 0; this.Height = DefaultHeight; UserInputPanel.Controls.Clear(); if (UserData == null || UserData == null || UserData.Length < 1) { this.Height = DefaultHeight; UserInputPanel.Visible = false; hasUserInput = false; return; } this.Height += 10; foreach (var u in UserData) { if (TypeForm.ContainsKey(u.InputType)) { var tagData = new UserInputTagData(u.InputType, u.ID); if (data != null) { object value = data.GetValue <object>(u.ID, null); if (value != null && value.GetType() == u.InputType) { tagData.Value = value; } } Control c = (Control)Activator.CreateInstance(TypeForm[u.InputType], tagData); c.Width = UserInputPanel.Width; c.Parent = UserInputPanel; c.Location = new Point(0, userInputHeight); userInputHeight += c.Height; UserInputPanel.Controls.Add(c); } } hasUserInput = true; UserInputPanel.Visible = true; UserInputPanel.Height = userInputHeight; this.Height += userInputHeight; }