using System.Drawing; namespace Netron.Diagramming.Core { /// /// Delete command. /// public class DeleteCommand : Command { #region Fields CollectionBase bundle; IController controller; #endregion #region Properties /// /// Gets the entities. /// /// The shape. public CollectionBase Entities { get { return bundle; } } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The controller. /// The bundle. public DeleteCommand( IController controller, CollectionBase bundle) : base(controller) { this.Text = "Delete"; this.controller = controller; this.bundle = bundle; } #endregion #region Methods /// /// Perform redo of this command. /// public override void Redo() { if (bundle.Count == 0) return; foreach (IDiagramEntity entity in bundle) { //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Remove(entity); Controller.Model.Remove(entity); } this.Controller.View.HideTracker(); Rectangle rec = Utils.BoundingRectangle(bundle); rec.Inflate(30, 30); this.Controller.View.Invalidate(rec); } /// /// Perform undo of this command. /// public override void Undo() { if (bundle.Count == 0) return; foreach (IDiagramEntity entity in bundle) { //this.Controller.Model.DefaultPage.DefaultLayer.Entities.Add(entity); Controller.Model.AddEntity(entity); } this.Controller.View.HideTracker(); Rectangle rec = Utils.BoundingRectangle(bundle); rec.Inflate(30, 30); this.Controller.View.Invalidate(rec); } #endregion } }