public Form3(IKeyProcess keyproc) { InitializeComponent(); initCmbVkey(); if (keyproc.GetType() == typeof(GenericKeyProcess)) { GenericKeyProcess proc = (GenericKeyProcess)keyproc; radioGeneric.Checked = true; tbName.Text = proc.Name; cbxCtrl.Checked = proc.UseCtrl; cbxAlt.Checked = proc.UseAlt; cbxShift.Checked = proc.UseShift; cmbVKey.SelectedItem = items.Find(x => x.VALUE == proc.KeyCode); } else if (keyproc.GetType() == typeof(KeyStrokeProcess)) { KeyStrokeProcess proc = (KeyStrokeProcess)keyproc; radioKeyStroke.Checked = true; tbName.Text = proc.Name; tbKeyStroke.Text = proc.GetStrokeString(); } else if (keyproc.GetType() == typeof(LaunchProcess)) { LaunchProcess proc = (LaunchProcess)keyproc; radioLaunch.Checked = true; tbName.Text = proc.Name; tbLaunchFile.Text = proc.File; tbLaunchArgs.Text = proc.Args; } else if (keyproc.GetType() == typeof(NullKeyProcess)) { radioNull.Checked = true; } }
private void ButtonClick(object sender, EventArgs e) { if (form == null || form.IsDisposed) { ushort key = buttons.First(x => x.Value.Equals(sender)).Key; IKeyProcess keyproc = MapList[cmbKeyMapList.SelectedIndex].Map[key]; form = new Form3(keyproc); if (form.ShowDialog() == DialogResult.OK) { IKeyProcess proc = form.GetKeyProcess(); MapList[cmbKeyMapList.SelectedIndex].Map[key] = proc; cmbKeyMapList.Refresh(); } form.Dispose(); form = null; UpdateButtons(); } }
public IKeyProcess GetKeyProcess() { IKeyProcess proc = null; if (radioGeneric.Checked) { proc = generateGenericKeyProc(); } else if (radioKeyStroke.Checked) { proc = generateKeyStrokeProc(); } else if (radioLaunch.Checked) { proc = generateLaunchProc(); } else if (radioNull.Checked) { proc = new NullKeyProcess(); } return(proc); }