Ejemplo n.º 1
0
 /// <summary>
 /// Undoes the most recent command.
 /// </summary>
 public void Undo()
 {
     // Undo the command and step up a level
     // in the command tree.
     tree.Current.Undo();
     tree.StepOut();
     // Broadcast information about the command state.
     CommandsUpdated?.Invoke(!tree.IsAtRoot, true);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Redoes a command that was undone.
 /// </summary>
 public void Redo()
 {
     // Step down to the next child and re-execute
     // its command implementation.
     tree.StepIn(0);
     tree.Current.Execute();
     // Broadcast information about the command state.
     CommandsUpdated?.Invoke(true, tree.Children.Count > 0);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Executes a command and adds it to the command tree.
 /// </summary>
 /// <param name="command">The command to add.</param>
 public void Do(StageEditorCommand command)
 {
     // Allows for overwritten commands to clean up
     // after themselves.
     foreach (StageEditorCommand subCommand in tree.GetAllChildrenBelowLocation())
     {
         subCommand.Delete();
     }
     // This explicitly removes branched history on
     // the tree. TODO would be interesting to
     // explore branched history.
     while (tree.Children.Count > 0)
     {
         tree.RemoveChildBranch(tree.Children[0]);
     }
     // Execute the command.
     command.Execute();
     // Add the command to the tree and move down to it.
     tree.AddChildren(command);
     tree.StepIn(0);
     // Broadcast information about the command state.
     CommandsUpdated?.Invoke(true, tree.Children.Count > 0);
 }