Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Commands/FillStyleCommand.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/FillStyleCommand.cs
r2768 r4068 1 using System;2 1 using System.Collections.Generic; 3 using System.Text; 4 using System.Drawing; 5 namespace Netron.Diagramming.Core 6 { 7 /// <summary> 8 /// Fill style command 9 /// </summary> 10 class FillStyleCommand : Command 11 { 12 #region Fields 13 CollectionBase<IDiagramEntity> bundle; 14 IController controller; 2 namespace Netron.Diagramming.Core { 3 /// <summary> 4 /// Fill style command 5 /// </summary> 6 class FillStyleCommand : Command { 7 #region Fields 8 CollectionBase<IDiagramEntity> bundle; 9 IController controller; 15 10 16 17 Dictionary<string, IPaintStyle> previousStyles = new Dictionary<string, IPaintStyle>();18 11 IPaintStyle newStyle; 12 Dictionary<string, IPaintStyle> previousStyles = new Dictionary<string, IPaintStyle>(); 13 #endregion 19 14 20 #region Properties 21 22 15 #region Properties 23 16 24 17 25 /// <summary>26 /// Gets the entities.27 /// </summary>28 /// <value>The shape.</value>29 public CollectionBase<IDiagramEntity> Entities30 {31 get { return bundle; }32 }33 34 #endregion35 36 #region Constructor37 /// <summary>38 /// Initializes a new instance of the <see cref="T:FillStyleCommand"/> class.39 /// </summary>40 /// <param name="controller">The controller.</param>41 /// <param name="bundle">The bundle.</param>42 /// <param name="paintStyle">The paint style.</param>43 public FillStyleCommand(IController controller, CollectionBase<IDiagramEntity> bundle, IPaintStyle paintStyle)44 : base(controller)45 {46 this.Text = "Fill style";47 this.controller = controller;48 this.bundle = bundle;//the bundle should contain only IShape and IConnection entities!49 this.newStyle = paintStyle;50 }51 #endregion52 53 #region Methods54 55 /// <summary>56 /// Perform redo of this command.57 /// </summary>58 public override void Redo()59 {60 if (bundle == null || bundle.Count == 0)61 return;62 previousStyles.Clear();63 foreach (IDiagramEntity entity in bundle)64 {65 if (entity is IShape)66 {67 previousStyles.Add(entity.Uid.ToString(), entity.PaintStyle);68 (entity as IShape).PaintStyle = newStyle;69 }70 }71 }72 73 /// <summary>74 /// Perform undo of this command.75 /// </summary>76 public override void Undo()77 {78 if (bundle == null || bundle.Count == 0)79 return;80 foreach (IDiagramEntity entity in bundle)81 {82 if (entity is IShape)83 (entity as IShape).PaintStyle = previousStyles[entity.Uid.ToString()];84 }85 86 87 18 88 19 20 /// <summary> 21 /// Gets the entities. 22 /// </summary> 23 /// <value>The shape.</value> 24 public CollectionBase<IDiagramEntity> Entities { 25 get { return bundle; } 26 } 27 28 #endregion 29 30 #region Constructor 31 /// <summary> 32 /// Initializes a new instance of the <see cref="T:FillStyleCommand"/> class. 33 /// </summary> 34 /// <param name="controller">The controller.</param> 35 /// <param name="bundle">The bundle.</param> 36 /// <param name="paintStyle">The paint style.</param> 37 public FillStyleCommand(IController controller, CollectionBase<IDiagramEntity> bundle, IPaintStyle paintStyle) 38 : base(controller) { 39 this.Text = "Fill style"; 40 this.controller = controller; 41 this.bundle = bundle;//the bundle should contain only IShape and IConnection entities! 42 this.newStyle = paintStyle; 43 } 44 #endregion 45 46 #region Methods 47 48 /// <summary> 49 /// Perform redo of this command. 50 /// </summary> 51 public override void Redo() { 52 if (bundle == null || bundle.Count == 0) 53 return; 54 previousStyles.Clear(); 55 foreach (IDiagramEntity entity in bundle) { 56 if (entity is IShape) { 57 previousStyles.Add(entity.Uid.ToString(), entity.PaintStyle); 58 (entity as IShape).PaintStyle = newStyle; 89 59 } 60 } 61 } 62 63 /// <summary> 64 /// Perform undo of this command. 65 /// </summary> 66 public override void Undo() { 67 if (bundle == null || bundle.Count == 0) 68 return; 69 foreach (IDiagramEntity entity in bundle) { 70 if (entity is IShape) 71 (entity as IShape).PaintStyle = previousStyles[entity.Uid.ToString()]; 72 } 90 73 91 74 92 #endregion 75 76 93 77 } 94 78 79 80 #endregion 81 } 82 95 83 }
Note: See TracChangeset
for help on using the changeset viewer.