private void bt_Ok_Click(object sender, EventArgs e) { CmdPair dlgCmd = mainf.dlgCmd; dlgCmd.cmd = tb_Char.Text.ToCharArray()[0]; dlgCmd.hex = String.Format("0x{0:X02}", (int)dlgCmd.cmd); dlgCmd.scripts = tbScripts.Text; mainf.dlgCmd = dlgCmd; }
private void editCmds(CmdPair cp, int idx = -1) { dlgCmd = new CmdPair(); CmdEditForm dlg = new CmdEditForm(this, cp, psm.cmds); DialogResult result = dlg.ShowDialog(this); if (result == DialogResult.OK) { if (idx == -1) { ((SortBindingList <CmdPair>)dgv.DataSource).Add(dlgCmd); } else { ((SortBindingList <CmdPair>)dgv.DataSource)[idx] = dlgCmd; } dgv.Sort(dgv.Columns[0], ListSortDirection.Ascending); Properties.Settings.Default.CmdPairs = psm.cmds; Properties.Settings.Default.Save(); } }
public CmdEditForm(MainForm mf, CmdPair cp, SortBindingList <CmdPair> cpl) { InitializeComponent(); mainf = mf; if (cp.cmd != 0) { tb_Char.Text = cp.cmd.ToString(); tb_Char.ReadOnly = true; tbScripts.Select(); } else { tb_Char.Text = String.Empty; } tbScripts.Text = cp.scripts; cmdPairs = cpl; lbAlreadyMsg.Text = ""; if (tb_Char.Text.Equals(String.Empty)) { bt_Ok.Enabled = false; } }