Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Command.cs @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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