Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Commands/DeleteCommand.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/DeleteCommand.cs
r2768 r4068 1 using System;2 using System.Collections.Generic;3 using System.Text;4 1 using System.Drawing; 5 namespace Netron.Diagramming.Core 6 { 7 /// <summary> 8 /// Delete command. 9 /// </summary> 10 public class DeleteCommand : Command 11 { 12 #region Fields 13 CollectionBase<IDiagramEntity> bundle; 14 IController controller; 15 16 #endregion 2 namespace Netron.Diagramming.Core { 3 /// <summary> 4 /// Delete command. 5 /// </summary> 6 public class DeleteCommand : Command { 7 #region Fields 8 CollectionBase<IDiagramEntity> bundle; 9 IController controller; 17 10 18 #region Properties 19 11 #endregion 20 12 21 /// <summary> 22 /// Gets the entities. 23 /// </summary> 24 /// <value>The shape.</value> 25 public CollectionBase<IDiagramEntity> Entities 26 { 27 get { return bundle; } 28 } 29 30 #endregion 31 32 #region Constructor 33 /// <summary> 34 /// Initializes a new instance of the <see cref="T:DeleteCommand"/> class. 35 /// </summary> 36 /// <param name="controller">The controller.</param> 37 /// <param name="bundle">The bundle.</param> 38 public DeleteCommand( 39 IController controller, 40 CollectionBase<IDiagramEntity> bundle) 41 : base(controller) 42 { 43 this.Text = "Delete"; 44 this.controller = controller; 45 this.bundle = bundle; 46 47 } 48 #endregion 49 50 #region Methods 51 52 /// <summary> 53 /// Perform redo of this command. 54 /// </summary> 55 public override void Redo() 56 { 57 if (bundle.Count == 0) return; 58 59 foreach (IDiagramEntity entity in bundle) 60 { 61 //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Remove(entity); 62 Controller.Model.Remove(entity); 63 } 64 this.Controller.View.HideTracker(); 65 Rectangle rec = Utils.BoundingRectangle(bundle); 66 rec.Inflate(30, 30); 67 this.Controller.View.Invalidate(rec); 68 } 69 70 /// <summary> 71 /// Perform undo of this command. 72 /// </summary> 73 public override void Undo() 74 { 75 76 if (bundle.Count == 0) return; 77 78 foreach (IDiagramEntity entity in bundle) 79 { 80 //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(entity); 81 Controller.Model.AddEntity(entity); 82 } 83 this.Controller.View.HideTracker(); 84 85 Rectangle rec = Utils.BoundingRectangle(bundle); 86 rec.Inflate(30, 30); 87 this.Controller.View.Invalidate(rec); 88 89 90 91 } 13 #region Properties 92 14 93 15 94 #endregion 16 /// <summary> 17 /// Gets the entities. 18 /// </summary> 19 /// <value>The shape.</value> 20 public CollectionBase<IDiagramEntity> Entities { 21 get { return bundle; } 95 22 } 96 23 24 #endregion 25 26 #region Constructor 27 /// <summary> 28 /// Initializes a new instance of the <see cref="T:DeleteCommand"/> class. 29 /// </summary> 30 /// <param name="controller">The controller.</param> 31 /// <param name="bundle">The bundle.</param> 32 public DeleteCommand( 33 IController controller, 34 CollectionBase<IDiagramEntity> bundle) 35 : base(controller) { 36 this.Text = "Delete"; 37 this.controller = controller; 38 this.bundle = bundle; 39 40 } 41 #endregion 42 43 #region Methods 44 45 /// <summary> 46 /// Perform redo of this command. 47 /// </summary> 48 public override void Redo() { 49 if (bundle.Count == 0) return; 50 51 foreach (IDiagramEntity entity in bundle) { 52 //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Remove(entity); 53 Controller.Model.Remove(entity); 54 } 55 this.Controller.View.HideTracker(); 56 Rectangle rec = Utils.BoundingRectangle(bundle); 57 rec.Inflate(30, 30); 58 this.Controller.View.Invalidate(rec); 59 } 60 61 /// <summary> 62 /// Perform undo of this command. 63 /// </summary> 64 public override void Undo() { 65 66 if (bundle.Count == 0) return; 67 68 foreach (IDiagramEntity entity in bundle) { 69 //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(entity); 70 Controller.Model.AddEntity(entity); 71 } 72 this.Controller.View.HideTracker(); 73 74 Rectangle rec = Utils.BoundingRectangle(bundle); 75 rec.Inflate(30, 30); 76 this.Controller.View.Invalidate(rec); 77 78 79 80 } 81 82 83 #endregion 84 } 85 97 86 }
Note: See TracChangeset
for help on using the changeset viewer.