Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Commands/FillStyleCommand.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.1 KB
Line 
1using System.Collections.Generic;
2namespace 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;
10
11    IPaintStyle newStyle;
12    Dictionary<string, IPaintStyle> previousStyles = new Dictionary<string, IPaintStyle>();
13    #endregion
14
15    #region Properties
16
17
18
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;
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      }
73
74
75
76
77    }
78
79
80    #endregion
81  }
82
83}
Note: See TracBrowser for help on using the repository browser.