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/PenStyleCommand.cs @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

File size: 2.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Drawing;
5namespace Netron.Diagramming.Core
6{
7    /// <summary>
8    /// Pen style command
9    /// </summary>
10    class PenStyleCommand : Command
11    {
12        #region Fields
13        CollectionBase<IDiagramEntity> bundle;
14        IController controller;
15
16        IPenStyle newStyle;
17        Dictionary<string, IPenStyle> previousStyles = new Dictionary<string, IPenStyle>();           
18        #endregion
19
20        #region Properties
21       
22       
23
24
25        /// <summary>
26        /// Gets the entities.
27        /// </summary>
28        /// <value>The shape.</value>
29        public CollectionBase<IDiagramEntity> Entities
30        {
31            get { return bundle; }
32        }
33
34        #endregion
35
36        #region Constructor
37        /// <summary>
38        /// Initializes a new instance of the <see cref="T:PenStyleCommand"/> class.
39        /// </summary>
40        /// <param name="controller">The controller.</param>
41        /// <param name="bundle">The bundle.</param>
42        /// <param name="penStyle">The pen style.</param>
43        public PenStyleCommand(IController controller, CollectionBase<IDiagramEntity> bundle, IPenStyle penStyle)
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 = penStyle;
50        }
51        #endregion
52
53        #region Methods
54
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 IConnection)
66                {
67                    previousStyles.Add(entity.Uid.ToString(), entity.PenStyle);
68                    (entity as IConnection).PenStyle  = 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 IConnection)
83                    (entity as IConnection).PenStyle = previousStyles[entity.Uid.ToString()];
84            }
85
86           
87
88
89        }
90
91
92        #endregion
93    }
94
95}
Note: See TracBrowser for help on using the repository browser.