private void btnAdd_Click(object sender, EventArgs e) { using(GBGClickAddModifyRecord modForm = new GBGClickAddModifyRecord()) { modForm.ShowDialog(this); if(modForm.OkExit) { MacroRecordBase mac = modForm.GetGeneratedRecord(); if(lbRecords.SelectedIndex >= 0) Records.Insert(lbRecords.SelectedIndex+1, mac); else Records.Add(mac); parent.WriteLogLine("New record accepted!"); } else parent.WriteLogLine("Record creation cancelled."); } }
private void btnModifyRecord_Click(object sender, EventArgs e) { int ndx = lbRecords.SelectedIndex; MacroRecordBase record = (MacroRecordBase) lbRecords.SelectedItem; using(GBGClickAddModifyRecord modForm = new GBGClickAddModifyRecord(record)) { modForm.ShowDialog(this); if(modForm.OkExit) { MacroRecordBase gen = modForm.GetGeneratedRecord(); Records.RemoveAt(ndx); Records.Insert(ndx, gen); lbRecords.SelectedIndex = ndx; parent.WriteLogLine("Record modification accepted!"); } else parent.WriteLogLine("Record modification attempt cancelled."); } }