Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Command.cs @ 10465

Last change on this file since 10465 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.6 KB
Line 
1
2namespace Netron.Diagramming.Core {
3  /// <summary>
4  /// Command is an abstract class that represents an undoable
5  /// or redoable operation or command. It provides virtual Undo()
6  /// and Redo() methods which your derived command classes can
7  /// override in order to implement actual undo/redo functionality.
8  /// In a derived command class, you also have the option of
9  /// not overriding the Undo() and Redo() methods. Instead, you
10  /// can treat the derived command class like a data class and
11  /// simply provide extra fields, properties, or methods that an
12  /// external class (one that implements IUndoHandler) can use to
13  /// perform the actual undo/redo functionality.
14  /// </summary>
15  public abstract class Command : ICommand {
16
17    #region Fields
18    /// <summary>
19    /// the Controller field
20    /// </summary>
21    private IController mController;
22
23    /// <summary>
24    /// the description of the action
25    /// </summary>
26    private string mText = string.Empty;
27    #endregion
28
29    #region Properties
30    /// <summary>
31    /// Gets or sets the Controller
32    /// </summary>
33    protected IController Controller {
34      get { return mController; }
35      set { mController = value; }
36    }
37    /// <summary>
38    /// Text should return a short description of the
39    /// user operation associated with this command. For example,
40    /// a graphics line drawing operation might have the
41    /// text, "Draw Line". This method can be used to update
42    /// the Text property of an undo menu item. For example,
43    /// instead of just displaying "Undo", the Text property
44    /// of an undo menu item can be augmented to "Undo Draw Line".
45    /// </summary>
46    /// <returns>Short description of the command.</returns>
47    public virtual string Text {
48      get {
49        return mText;
50      }
51      set {
52        mText = value;
53      }
54    }
55    #endregion
56
57    #region Constructor
58    /// <summary>
59    /// Default constructor
60    /// </summary>
61    /// <param name="controller">The controller.</param>
62    protected Command(IController controller) {
63      if (controller == null)
64        throw new InconsistencyException("The controller is 'null'");
65      this.mController = controller;
66    }
67    #endregion
68
69    #region Methods
70    /// <summary>
71    /// Perform undo of this command.
72    /// </summary>
73    public virtual void Undo() {
74      // Empty implementation.
75    }
76
77    /// <summary>
78    /// Perform redo of this command.
79    /// </summary>
80    public virtual void Redo() {
81      // Empty implementation.
82    }
83    #endregion
84  }
85
86}
Note: See TracBrowser for help on using the repository browser.