1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Drawing.Drawing2D;
|
---|
6 |
|
---|
7 | namespace Netron.Diagramming.Core
|
---|
8 | {
|
---|
9 | // ----------------------------------------------------------------------
|
---|
10 | /// <summary>
|
---|
11 | /// Basic <see cref="IPenStyle"/> implementation; this is the minimal
|
---|
12 | /// structure for a pen, add other <see cref="Pen"/> properties as needed.
|
---|
13 | /// </summary>
|
---|
14 | // ----------------------------------------------------------------------
|
---|
15 | public partial class PenStyle : IPenStyle
|
---|
16 | {
|
---|
17 | #region Fields
|
---|
18 |
|
---|
19 | // ------------------------------------------------------------------
|
---|
20 | /// <summary>
|
---|
21 | /// Implementation of IVersion - the current version of
|
---|
22 | /// PenStyle.
|
---|
23 | /// </summary>
|
---|
24 | // ------------------------------------------------------------------
|
---|
25 | protected const double penStyleVersion = 1.0;
|
---|
26 |
|
---|
27 | // -------------------------------------------------------------------
|
---|
28 | /// <summary>
|
---|
29 | /// the pen's color
|
---|
30 | /// </summary>
|
---|
31 | // -------------------------------------------------------------------
|
---|
32 | private Color mColor = Color.Gray;
|
---|
33 |
|
---|
34 | // -------------------------------------------------------------------
|
---|
35 | /// <summary>
|
---|
36 | /// the dashstyle of the pen
|
---|
37 | /// </summary>
|
---|
38 | // -------------------------------------------------------------------
|
---|
39 | private DashStyle mDashStyle = DashStyle.Solid;
|
---|
40 |
|
---|
41 | // -------------------------------------------------------------------
|
---|
42 | /// <summary>
|
---|
43 | /// the pen's width
|
---|
44 | /// </summary>
|
---|
45 | // -------------------------------------------------------------------
|
---|
46 | private float mWidth = 1F;
|
---|
47 |
|
---|
48 | #endregion
|
---|
49 |
|
---|
50 | #region Properties
|
---|
51 |
|
---|
52 | // ------------------------------------------------------------------
|
---|
53 | /// <summary>
|
---|
54 | /// Gets the current version.
|
---|
55 | /// </summary>
|
---|
56 | // ------------------------------------------------------------------
|
---|
57 | public virtual double Version
|
---|
58 | {
|
---|
59 | get
|
---|
60 | {
|
---|
61 | return penStyleVersion;
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | // -------------------------------------------------------------------
|
---|
66 | /// <summary>
|
---|
67 | /// Gets or sets the color.
|
---|
68 | /// </summary>
|
---|
69 | /// <value>The color.</value>
|
---|
70 | // -------------------------------------------------------------------
|
---|
71 | public Color Color
|
---|
72 | {
|
---|
73 | get
|
---|
74 | {
|
---|
75 | return mColor;
|
---|
76 | }
|
---|
77 | set
|
---|
78 | {
|
---|
79 | mColor = value;
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | // -------------------------------------------------------------------
|
---|
84 | /// <summary>
|
---|
85 | /// Gets or sets the dash style.
|
---|
86 | /// </summary>
|
---|
87 | /// <value>The dash style.</value>
|
---|
88 | // -------------------------------------------------------------------
|
---|
89 | public DashStyle DashStyle
|
---|
90 | {
|
---|
91 | get
|
---|
92 | {
|
---|
93 | return mDashStyle;
|
---|
94 | }
|
---|
95 | set
|
---|
96 | {
|
---|
97 | mDashStyle = value;
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | // -------------------------------------------------------------------
|
---|
102 | /// <summary>
|
---|
103 | /// Gets or sets the width.
|
---|
104 | /// </summary>
|
---|
105 | /// <value>The width.</value>
|
---|
106 | // -------------------------------------------------------------------
|
---|
107 | public float Width
|
---|
108 | {
|
---|
109 | get
|
---|
110 | {
|
---|
111 | return mWidth;
|
---|
112 | }
|
---|
113 | set
|
---|
114 | {
|
---|
115 | mWidth = value;
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | #endregion
|
---|
120 |
|
---|
121 | #region Constructors
|
---|
122 |
|
---|
123 | // -------------------------------------------------------------------
|
---|
124 | /// <summary>
|
---|
125 | /// Initializes a new instance of the <see cref="T:PenStyle"/> class.
|
---|
126 | /// </summary>
|
---|
127 | // -------------------------------------------------------------------
|
---|
128 | public PenStyle()
|
---|
129 | { }
|
---|
130 |
|
---|
131 | // -------------------------------------------------------------------
|
---|
132 | /// <summary>
|
---|
133 | /// Initializes a new instance of the <see cref="T:PenStyle"/> class.
|
---|
134 | /// </summary>
|
---|
135 | /// <param name="color">The color.</param>
|
---|
136 | /// <param name="dashStyle">The dash style.</param>
|
---|
137 | /// <param name="width">The width.</param>
|
---|
138 | // -------------------------------------------------------------------
|
---|
139 | public PenStyle(Color color, DashStyle dashStyle, float width)
|
---|
140 | {
|
---|
141 | this.mColor = color;
|
---|
142 | this.mWidth = width;
|
---|
143 | this.mDashStyle = dashStyle;
|
---|
144 | }
|
---|
145 |
|
---|
146 | #endregion
|
---|
147 |
|
---|
148 | #region Methods
|
---|
149 |
|
---|
150 | // -------------------------------------------------------------------
|
---|
151 | /// <summary>
|
---|
152 | /// Returns the constructed pen.
|
---|
153 | /// </summary>
|
---|
154 | /// <returns>Pen</returns>
|
---|
155 | // -------------------------------------------------------------------
|
---|
156 | public virtual Pen DrawingPen()
|
---|
157 | {
|
---|
158 | Pen pen = new Pen(mColor, mWidth);
|
---|
159 | pen.DashStyle = mDashStyle;
|
---|
160 | return pen;
|
---|
161 | }
|
---|
162 | #endregion
|
---|
163 | }
|
---|
164 | }
|
---|