private void mnuUndo_Click(object sender, EventArgs e) { UndoableTextOperation op = _undo.PeekUndo(); if (op != null) { if (Utils.AskToConfirm("Undo moving " + op.TextContents.Length + " lines of text to " + op.Destfile + "?")) { op.Undo(this.listBox); _undo.Undo(); } } }
void AddToFile(string destfile) { UndoableTextOperation op = new UndoableTextOperation(); op.Destfile = destfile; op.Srcfile = _currentfile; op.ListIndices = listBox.SelectedIndices.Cast <int>().ToArray(); op.TextContents = listBox.SelectedItems.Cast <string>().ToArray(); if (op.ListIndices.Length > 0) { op.Do(this.listBox); _undo.Add(op); } else { MessageBox.Show("Nothing selected."); } }