Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.7/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/UndoRedo/Commands/PenStyleCommand.cs @ 13398

Last change on this file since 13398 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  /// Pen style command
5  /// </summary>
6  class PenStyleCommand : Command {
7    #region Fields
8    CollectionBase<IDiagramEntity> bundle;
9    IController controller;
10
11    IPenStyle newStyle;
12    Dictionary<string, IPenStyle> previousStyles = new Dictionary<string, IPenStyle>();
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:PenStyleCommand"/> class.
33    /// </summary>
34    /// <param name="controller">The controller.</param>
35    /// <param name="bundle">The bundle.</param>
36    /// <param name="penStyle">The pen style.</param>
37    public PenStyleCommand(IController controller, CollectionBase<IDiagramEntity> bundle, IPenStyle penStyle)
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 = penStyle;
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 IConnection) {
57          previousStyles.Add(entity.Uid.ToString(), entity.PenStyle);
58          (entity as IConnection).PenStyle = 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 IConnection)
71          (entity as IConnection).PenStyle = 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.