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/Commands/MoveCommand.cs @ 4068

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

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

File size: 2.1 KB
Line 
1using System.Drawing;
2namespace Netron.Diagramming.Core {
3  /// <summary>
4  /// ICommand implementation of the move action
5  /// </summary>
6  class MoveCommand : Command {
7    #region Fields
8    IBundle bundle;
9    IController controller;
10    Point delta;
11    #endregion
12
13    #region Properties
14
15    /// <summary>
16    /// Gets the shape.
17    /// </summary>
18    /// <value>The shape.</value>
19    public CollectionBase<IDiagramEntity> Entities {
20      get { return bundle.Entities; }
21    }
22
23    #endregion
24
25    #region Constructor
26    /// <summary>
27    /// Initializes a new instance of the <see cref="T:MoveCommand"/> class.
28    /// </summary>
29    /// <param name="controller">The controller.</param>
30    /// <param name="bundle">The bundle.</param>
31    /// <param name="delta">The delta.</param>
32    public MoveCommand(IController controller, IBundle bundle, Point delta)
33      : base(controller) {
34      this.Text = "Move " + bundle.EntityName;
35      this.controller = controller;
36      this.delta = delta;
37      this.bundle = bundle;
38    }
39    #endregion
40
41    #region Methods
42
43    /// <summary>
44    /// Perform redo of this command.
45    /// </summary>
46    public override void Redo() {
47      bundle.MoveBy(delta);
48      //invalidate the space before the move
49      Rectangle rec = bundle.Rectangle;
50      rec.Offset(-delta.X, -delta.Y);
51      rec.Inflate(20, 20);
52      bundle.Invalidate(rec);//same as an invalidate on the controller level
53      //invalidate the current neighborhood of the bundle
54      bundle.Invalidate();
55
56    }
57
58    /// <summary>
59    /// Perform undo of this command.
60    /// </summary>
61    public override void Undo() {
62      bundle.MoveBy(new Point(-delta.X, -delta.Y)); //invert the vector
63      //invalidate the space before the move
64      Rectangle rec = bundle.Rectangle;
65      rec.Offset(delta.X, delta.Y);
66      rec.Inflate(20, 20);
67      bundle.Invalidate(rec);//same as an invalidate on the controller level
68      //invalidate the current neighborhood of the bundle
69      bundle.Invalidate();
70    }
71
72
73    #endregion
74  }
75
76}
Note: See TracBrowser for help on using the repository browser.