/// <summary> /// Handler for the UndoRedoCommand. /// </summary> /// <param name="state">The state.</param> /// <param name="command">The command.</param> public static void UndoRedoCommandHandler(GraphToolState state, UndoRedoCommand command) { UndoRedoCommand.DefaultCommandHandler(state, command); var graphModel = state.WindowState.GraphModel; graphModel?.UndoRedoPerformed(); }
private void PushUndoRedoCmd(object obj, Type objType, string propName, object newVal, object oldVal) { if (!newVal.Equals(oldVal)) { UndoRedoCommand cmd = new UndoRedoCommand(obj, objType, propName, newVal, oldVal); _historyStack.PushHistoryItem(cmd); } }
/// <summary> /// Call this static method to reconstruct a RecordableCommand-derived /// object given an XmlElement that was previously saved with Serialize /// method. This method simply redirects the XmlElement to respective /// RecordableCommand-derived classes based on its type. /// </summary> /// <param name="element">The XmlElement from which the RecordableCommand /// can be reconstructed.</param> /// <returns>Returns the reconstructed RecordableCommand object. If a /// RecordableCommand cannot be reconstructed, this method throws a /// relevant exception.</returns> /// internal static RecordableCommand Deserialize(XmlElement element) { if (string.IsNullOrEmpty(element.Name)) { throw new ArgumentException("XmlElement without name"); } RecordableCommand command = null; switch (element.Name) { case "CreateNodeCommand": command = CreateNodeCommand.DeserializeCore(element); break; case "SelectModelCommand": command = SelectModelCommand.DeserializeCore(element); break; case "CreateNoteCommand": command = CreateNoteCommand.DeserializeCore(element); break; case "SelectInRegionCommand": command = SelectInRegionCommand.DeserializeCore(element); break; case "DragSelectionCommand": command = DragSelectionCommand.DeserializeCore(element); break; case "MakeConnectionCommand": command = MakeConnectionCommand.DeserializeCore(element); break; case "DeleteModelCommand": command = DeleteModelCommand.DeserializeCore(element); break; case "UndoRedoCommand": command = UndoRedoCommand.DeserializeCore(element); break; case "UpdateModelValueCommand": command = UpdateModelValueCommand.DeserializeCore(element); break; } if (null != command) { command.IsInPlaybackMode = true; return(command); } string message = string.Format("Unknown command: {0}", element.Name); throw new ArgumentException(message); }
void UndoRedoImpl(UndoRedoCommand command) { if (command.CmdOperation == UndoRedoCommand.Operation.Undo) { CurrentWorkspace.Undo(); } else if (command.CmdOperation == UndoRedoCommand.Operation.Redo) { CurrentWorkspace.Redo(); } }
void UndoRedoImpl(UndoRedoCommand command) { switch (command.CmdOperation) { case UndoRedoCommand.Operation.Undo: CurrentWorkspace.Undo(); break; case UndoRedoCommand.Operation.Redo: CurrentWorkspace.Redo(); break; } }
public void UndoRedoCommandTest_TrackAnalytics() { //Arrange var command = new UndoRedoCommand(UndoRedoCommand.Operation.Undo); //Act command.TrackAnalytics(); //Assert //In this section we are just checking that the command instance is valid and has the correct values Assert.IsNotNull(command); Assert.AreEqual(command.CmdOperation, UndoRedoCommand.Operation.Undo); }
private void UndoRedoImpl(UndoRedoCommand command) { if (command.CmdOperation == UndoRedoCommand.Operation.Undo) { CurrentSpace.Undo(); } else if (command.CmdOperation == UndoRedoCommand.Operation.Redo) { CurrentSpace.Redo(); } UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); }
/// <summary> /// Call this static method to reconstruct a RecordableCommand-derived /// object given an XmlElement that was previously saved with Serialize /// method. This method simply redirects the XmlElement to respective /// RecordableCommand-derived classes based on its type. /// </summary> /// <param name="element">The XmlElement from which the RecordableCommand /// can be reconstructed.</param> /// <returns>Returns the reconstructed RecordableCommand object. If a /// RecordableCommand cannot be reconstructed, this method throws a /// relevant exception.</returns> /// internal static RecordableCommand Deserialize(XmlElement element) { if (string.IsNullOrEmpty(element.Name)) { throw new ArgumentException("XmlElement without name"); } switch (element.Name) { case "CreateNodeCommand": return(CreateNodeCommand.DeserializeCore(element)); case "SelectModelCommand": return(SelectModelCommand.DeserializeCore(element)); case "CreateNoteCommand": return(CreateNoteCommand.DeserializeCore(element)); case "SelectInRegionCommand": return(SelectInRegionCommand.DeserializeCore(element)); case "DragSelectionCommand": return(DragSelectionCommand.DeserializeCore(element)); case "MakeConnectionCommand": return(MakeConnectionCommand.DeserializeCore(element)); case "DeleteModelCommand": return(DeleteModelCommand.DeserializeCore(element)); case "UndoRedoCommand": return(UndoRedoCommand.DeserializeCore(element)); } string message = string.Format("Unknown command: {0}", element.Name); throw new ArgumentException(message); }
private void Undo(object parameter) { var command = new UndoRedoCommand(UndoRedoCommand.Operation.Undo); this.ExecuteCommand(command); }
private void UndoRedoImpl(UndoRedoCommand command) { if (command.CmdOperation == UndoRedoCommand.Operation.Undo) CurrentSpace.Undo(); else if (command.CmdOperation == UndoRedoCommand.Operation.Redo) CurrentSpace.Redo(); UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); }
/// <summary> /// Call this static method to reconstruct a RecordableCommand-derived /// object given an XmlElement that was previously saved with Serialize /// method. This method simply redirects the XmlElement to respective /// RecordableCommand-derived classes based on its type. /// </summary> /// <param name="element">The XmlElement from which the RecordableCommand /// can be reconstructed.</param> /// <returns>Returns the reconstructed RecordableCommand object. If a /// RecordableCommand cannot be reconstructed, this method throws a /// relevant exception.</returns> /// internal static RecordableCommand Deserialize(XmlElement element) { if (string.IsNullOrEmpty(element.Name)) { throw new ArgumentException("XmlElement without name"); } RecordableCommand command = null; switch (element.Name) { case "OpenFileCommand": command = OpenFileCommand.DeserializeCore(element); break; case "PausePlaybackCommand": command = PausePlaybackCommand.DeserializeCore(element); break; case "RunCancelCommand": command = RunCancelCommand.DeserializeCore(element); break; case "CreateNodeCommand": command = CreateNodeCommand.DeserializeCore(element); break; case "SelectModelCommand": command = SelectModelCommand.DeserializeCore(element); break; case "CreateNoteCommand": command = CreateNoteCommand.DeserializeCore(element); break; case "SelectInRegionCommand": command = SelectInRegionCommand.DeserializeCore(element); break; case "DragSelectionCommand": command = DragSelectionCommand.DeserializeCore(element); break; case "MakeConnectionCommand": command = MakeConnectionCommand.DeserializeCore(element); break; case "DeleteModelCommand": command = DeleteModelCommand.DeserializeCore(element); break; case "UndoRedoCommand": command = UndoRedoCommand.DeserializeCore(element); break; case "ModelEventCommand": command = ModelEventCommand.DeserializeCore(element); break; case "UpdateModelValueCommand": command = UpdateModelValueCommand.DeserializeCore(element); break; case "ConvertNodesToCodeCommand": command = ConvertNodesToCodeCommand.DeserializeCore(element); break; case "CreateCustomNodeCommand": command = CreateCustomNodeCommand.DeserializeCore(element); break; case "SwitchTabCommand": command = SwitchTabCommand.DeserializeCore(element); break; } if (null != command) { command.IsInPlaybackMode = true; command.Tag = element.GetAttribute("Tag"); return(command); } string message = string.Format("Unknown command: {0}", element.Name); throw new ArgumentException(message); }
void UndoRedoImpl(UndoRedoCommand command) { if (command.CmdOperation == UndoRedoCommand.Operation.Undo) CurrentWorkspace.Undo(); else if (command.CmdOperation == UndoRedoCommand.Operation.Redo) CurrentWorkspace.Redo(); }