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:
2.0 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using System.Drawing;
|
---|
5 | namespace Netron.Diagramming.Core
|
---|
6 | {
|
---|
7 | /// <summary>
|
---|
8 | /// ICommand implementation of the AddShape action
|
---|
9 | /// </summary>
|
---|
10 | public class AddShapeCommand : Command
|
---|
11 | {
|
---|
12 | #region Fields
|
---|
13 | IShape shape;
|
---|
14 | Point location;
|
---|
15 | #endregion
|
---|
16 |
|
---|
17 | #region Properties
|
---|
18 | public IShape Shape
|
---|
19 | {
|
---|
20 | get { return shape; }
|
---|
21 | }
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 | #region Methods
|
---|
27 | /// <summary>
|
---|
28 | /// Initializes a new instance of the <see cref="T:AddShapeCommand"/> class.
|
---|
29 | /// </summary>
|
---|
30 | /// <param name="controller">The controller.</param>
|
---|
31 | /// <param name="shape">The shape.</param>
|
---|
32 | /// <param name="location">The location.</param>
|
---|
33 | public AddShapeCommand(
|
---|
34 | IController controller,
|
---|
35 | IShape shape,
|
---|
36 | Point location) :base(controller)
|
---|
37 | {
|
---|
38 | if (shape == null)
|
---|
39 | throw new ArgumentNullException("The shape is 'null' and cannot be inserted.");
|
---|
40 | this.Text = "Add " + shape.EntityName;
|
---|
41 |
|
---|
42 | this.location = location;
|
---|
43 | this.shape = shape;
|
---|
44 | }
|
---|
45 |
|
---|
46 | /// <summary>
|
---|
47 | /// Perform redo of this command.
|
---|
48 | /// </summary>
|
---|
49 | public override void Redo()
|
---|
50 | {
|
---|
51 | Controller.Model.AddShape(shape);
|
---|
52 |
|
---|
53 | shape.Transform(location.X, location.Y, shape.Width, shape.Height);
|
---|
54 | Rectangle rec = shape.Rectangle;
|
---|
55 | rec.Inflate(20, 20);
|
---|
56 | Controller.View.Invalidate(rec);
|
---|
57 | }
|
---|
58 |
|
---|
59 | /// <summary>
|
---|
60 | /// Perform undo of this command.
|
---|
61 | /// </summary>
|
---|
62 | public override void Undo()
|
---|
63 | {
|
---|
64 | Rectangle rec = shape.Rectangle;
|
---|
65 | rec.Inflate(20, 20);
|
---|
66 | Controller.Model.RemoveShape(shape);
|
---|
67 |
|
---|
68 | Controller.View.Invalidate(rec);
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | #endregion
|
---|
73 |
|
---|
74 | }
|
---|
75 |
|
---|
76 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.