/// <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();
        }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
            /// <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);
            }
Esempio n. 4
0
 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);
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
            /// <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);
            }
Esempio n. 9
0
 private void Undo(object parameter)
 {
     var command = new UndoRedoCommand(UndoRedoCommand.Operation.Undo);
     this.ExecuteCommand(command);
 }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
 void UndoRedoImpl(UndoRedoCommand command)
 {
     switch (command.CmdOperation)
     {
         case UndoRedoCommand.Operation.Undo:
             CurrentWorkspace.Undo();
             break;
         case UndoRedoCommand.Operation.Redo:
             CurrentWorkspace.Redo();
             break;
     }
 }
Esempio n. 12
0
            /// <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);
            }
Esempio n. 13
0
 void UndoRedoImpl(UndoRedoCommand command)
 {
     if (command.CmdOperation == UndoRedoCommand.Operation.Undo)
         CurrentWorkspace.Undo();
     else if (command.CmdOperation == UndoRedoCommand.Operation.Redo)
         CurrentWorkspace.Redo();
 }