private void drawWindow_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (m_mouseController.Selected.Nodes.Any() || m_mouseController.Selected.Groups.Any()) { //TODO: This would probably make more sense in MouseController.Delete CurrentFile.Remove(m_mouseController.Selected.Nodes.Select(CurrentFile.GetNode), m_mouseController.Selected.Groups, m_localization); } else { var delete = m_mouseController.Delete(); if (delete != null) { GenericUndoAction action = new GenericUndoAction(() => { delete.Value.Undo(); Redraw(); }, () => { delete.Value.Redo(); Redraw(); }, "Deleted"); CurrentFile.UndoableFile.Change(action); } } } else if (e.KeyCode == Keys.Tab && e.Control) { int index = m_context.CurrentProject.Value.Localizer.LocalizationSets.IndexOf(m_context.CurrentLocalization.Value); if (index >= 0) { m_context.CurrentLocalization.Value = m_context.CurrentProject.Value.Localizer.LocalizationSets.InfiniteRepeat().ElementAt(index + 1); Redraw(); } } }
public void ClearErrors() { ReadOnlyCollection <LoadError> oldErrors = m_errors; GenericUndoAction action = new GenericUndoAction(() => { m_errors = oldErrors; }, () => { m_errors = new ReadOnlyCollection <LoadError>(new LoadError[0]); }, "Cleared errors on conversation"); UndoableFile.Change(action); }
public void Change(SimpleUndoPair actions, string description) { var action = new GenericUndoAction(new SimpleUndoPair { Redo = () => { actions.Redo(); Modified.Execute(); }, Undo = () => { actions.Undo(); Modified.Execute(); } }, description); action.Redo(); m_undoQueue.Queue(action); }