public FormAction(Actions a) { InitializeComponent(); keyDataSource = (Keys[])Enum.GetValues(typeof(Keys)).Cast<Keys>(); comboBox2.DataSource = keyDataSource; comboBox1.DataSource = new string[] { "Key press", "Timer" }; numericUpDown1.DecimalPlaces = 2; numericUpDown1.Increment = 0.1M; comboBox2.SelectedItem = a.keys; numericUpDown1.Value = Convert.ToDecimal(a.timer); comboBox1.SelectedItem = a.type; switch (a.keyModifier) { case Keys.ControlKey: checkBox1.Checked = true; break; case Keys.ShiftKey: checkBox2.Checked = true; break; case Keys.Alt: checkBox3.Checked = true; break; default : break; } }
private void button1_Click(object sender, EventArgs e) { FormAction newActionForm = new FormAction(); newActionForm.ShowDialog(); if (newActionForm.selectedType != "") { if (newActionForm.selectedType == "Key press" && newActionForm.selectedKey != Keys.None || newActionForm.selectedType == "Timer" && newActionForm.selectedTimer != 0) { Actions myNewAction = new Actions(newActionForm.selectedType, newActionForm.selectedKey, newActionForm.modifier, newActionForm.selectedTimer); actionList.Add(myNewAction); listBox1.DataSource = null; listBox1.DataSource = actionList; } } }
private void ButtonAdd_Click(object sender, EventArgs e) { using (FormAction form = new FormAction()) { form.ShowDialog(); if (form.SelectedType != "") { if (form.SelectedType == "Key press" && form.SelectedKey != Keys.None || form.SelectedType == "Timer" && form.SelectedTimer != 0) { Actions myNewAction = new Actions(form.SelectedType, form.SelectedKey, form.modifier, form.SelectedTimer); actionList.Add(myNewAction); ListCommands.DataSource = null; ListCommands.DataSource = actionList; } } } }
public FormAction(Actions action) { InitializeComponent(); keyDataSource = (Keys[])Enum.GetValues(typeof(Keys)).Cast<Keys>(); ComboKeys.DataSource = keyDataSource; NumericTimer.DecimalPlaces = 2; NumericTimer.Increment = 0.1M; ComboKeys.SelectedItem = action.keys; NumericTimer.Value = Convert.ToDecimal(action.timer); if (action.type == "Key press") this.RadioCommand.Checked = true; else this.RadioTimer.Checked = true; switch (action.keyModifier) { case Keys.ControlKey: checkBox1.Checked = true; break; case Keys.ShiftKey: checkBox2.Checked = true; break; case Keys.Alt: checkBox3.Checked = true; break; default: break; } }
private void button1_Click(object sender, EventArgs e) { FormAction newActionForm = new FormAction(); DialogResult actionFormResult = newActionForm.ShowDialog(); if (actionFormResult == DialogResult.OK) { Actions myNewAction = new Actions(newActionForm.selectedType, newActionForm.selectedKey, newActionForm.modifier, newActionForm.selectedTimer); actionList.Add(myNewAction); listBox1.DataSource = null; listBox1.DataSource = actionList; } }