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