1 | using System;
|
---|
2 | using System.Drawing.Drawing2D;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Runtime.Serialization;
|
---|
5 | namespace Netron.GraphLib.IO.Binary
|
---|
6 | {
|
---|
7 | /// <summary>
|
---|
8 | /// Collects ambient properties of the GraphControl
|
---|
9 | /// </summary>
|
---|
10 | [Serializable] public class BinaryAmbiance : ISerializable
|
---|
11 | {
|
---|
12 |
|
---|
13 | #region Fields
|
---|
14 |
|
---|
15 | /// <summary>
|
---|
16 | /// the Locked setting
|
---|
17 | /// </summary>
|
---|
18 | private bool mLocked;
|
---|
19 | /// <summary>
|
---|
20 | /// the ShowGrid setting
|
---|
21 | /// </summary>
|
---|
22 | private bool mShowGrid;
|
---|
23 | /// <summary>
|
---|
24 | /// the bottom gradient
|
---|
25 | /// </summary>
|
---|
26 | private Color mGradientBottom;
|
---|
27 | /// <summary>
|
---|
28 | /// the top gradient
|
---|
29 | /// </summary>
|
---|
30 | private Color mGradientTop;
|
---|
31 | /// <summary>
|
---|
32 | /// the AllowAddConnection property
|
---|
33 | /// </summary>
|
---|
34 | private bool mAllowAddConnection;
|
---|
35 | /// <summary>
|
---|
36 | /// the AllowAddShape property
|
---|
37 | /// </summary>
|
---|
38 | private bool mAllowAddShape;
|
---|
39 | /// <summary>
|
---|
40 | /// the AllowDeleteShape property
|
---|
41 | /// </summary>
|
---|
42 | private bool mAllowDeleteShape;
|
---|
43 | /// <summary>
|
---|
44 | /// the AllowMoveShape property
|
---|
45 | /// </summary>
|
---|
46 | private bool mAllowMoveShape;
|
---|
47 | /// <summary>
|
---|
48 | /// the AutomataPulse property
|
---|
49 | /// </summary>
|
---|
50 | private int mAutomataPulse;
|
---|
51 | /// <summary>
|
---|
52 | /// the BackgroundColor property
|
---|
53 | /// </summary>
|
---|
54 | private Color mBackgroundColor;
|
---|
55 | /// <summary>
|
---|
56 | /// the BackgroundImagePath property
|
---|
57 | /// </summary>
|
---|
58 | private string mBackgroundImagePath;
|
---|
59 | /// <summary>
|
---|
60 | /// the BackgroundType property
|
---|
61 | /// </summary>
|
---|
62 | private CanvasBackgroundType mBackgroundType;
|
---|
63 | /// <summary>
|
---|
64 | /// the DefaultConnectionPath property
|
---|
65 | /// </summary>
|
---|
66 | private string mDefaultConnectionPath;
|
---|
67 | /// <summary>
|
---|
68 | /// the GradientMode property
|
---|
69 | /// </summary>
|
---|
70 | private LinearGradientMode mGradientMode;
|
---|
71 | /// <summary>
|
---|
72 | /// the EnableContextMenu property
|
---|
73 | /// </summary>
|
---|
74 | private bool mEnableContextMenu;
|
---|
75 | /// <summary>
|
---|
76 | /// the GridSize property
|
---|
77 | /// </summary>
|
---|
78 | private int mGridSize;
|
---|
79 | /// <summary>
|
---|
80 | /// the RestrictToCanvas property
|
---|
81 | /// </summary>
|
---|
82 | private bool mRestrictToCanvas;
|
---|
83 | /// <summary>
|
---|
84 | /// the Snap property
|
---|
85 | /// </summary>
|
---|
86 | private bool mSnap;
|
---|
87 | /// <summary>
|
---|
88 | /// the DefaultConnectionEnd property
|
---|
89 | /// </summary>
|
---|
90 | private ConnectionEnd mDefaultConnectionEnd ;
|
---|
91 | /// <summary>
|
---|
92 | /// the mEnableLayout property
|
---|
93 | /// </summary>
|
---|
94 | private bool mEnableLayout;
|
---|
95 | /// <summary>
|
---|
96 | /// the GraphLayoutAlgorithm property
|
---|
97 | /// </summary>
|
---|
98 | private GraphLayoutAlgorithms mGraphLayoutAlgorithm;
|
---|
99 | /// <summary>
|
---|
100 | /// the EnableTooltip property
|
---|
101 | /// </summary>
|
---|
102 | private bool mEnableTooltip;
|
---|
103 | /// <summary>
|
---|
104 | /// the ShowAutomataController property
|
---|
105 | /// </summary>
|
---|
106 | private bool mShowAutomataController;
|
---|
107 | #endregion
|
---|
108 |
|
---|
109 | #region Properties
|
---|
110 | /// <summary>
|
---|
111 | /// Gets or sets whether the internal dataflow is runnning
|
---|
112 | /// </summary> |
---|
113 | public bool ShowAutomataController |
---|
114 | { |
---|
115 | get{return mShowAutomataController;} |
---|
116 | set{mShowAutomataController = value;} |
---|
117 | }
|
---|
118 |
|
---|
119 | /// <summary>
|
---|
120 | /// Gets or sets the EnableTooltip property of the GraphControl
|
---|
121 | /// </summary>
|
---|
122 | public bool EnableTooltip
|
---|
123 | {
|
---|
124 | get{return mEnableTooltip;}
|
---|
125 | set{mEnableTooltip = value;}
|
---|
126 | }
|
---|
127 |
|
---|
128 | /// <summary>
|
---|
129 | /// Gets or sets the Locked property of the GraphControl
|
---|
130 | /// </summary>
|
---|
131 | public bool Locked
|
---|
132 | {
|
---|
133 | get{return mLocked;}
|
---|
134 | set{mLocked = value;}
|
---|
135 | }
|
---|
136 | /// <summary>
|
---|
137 | /// Gets or sets the GraphLayoutAlgorithm property of the GraphControl
|
---|
138 | /// </summary>
|
---|
139 | public GraphLayoutAlgorithms GraphLayoutAlgorithm
|
---|
140 | {
|
---|
141 | get{return mGraphLayoutAlgorithm;}
|
---|
142 | set{mGraphLayoutAlgorithm = value;}
|
---|
143 | }
|
---|
144 |
|
---|
145 | /// <summary>
|
---|
146 | /// Gets or sets the EnableLayout property of the GraphControl
|
---|
147 | /// </summary>
|
---|
148 | public bool EnableLayout
|
---|
149 | {
|
---|
150 | get{return mEnableLayout ;}
|
---|
151 | set{mEnableLayout = value;}
|
---|
152 | }
|
---|
153 |
|
---|
154 | /// <summary>
|
---|
155 | /// Gets or sets the DefaultConnectionEnd property of the GraphControl
|
---|
156 | /// </summary>
|
---|
157 | public ConnectionEnd DefaultConnectionEnd
|
---|
158 | {
|
---|
159 | get{return mDefaultConnectionEnd ;}
|
---|
160 | set{mDefaultConnectionEnd = value;}
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 | /// <summary>
|
---|
165 | /// Gets or sets the Snap property of the GraphControl
|
---|
166 | /// </summary>
|
---|
167 | public bool Snap
|
---|
168 | {
|
---|
169 | get{return mSnap ;}
|
---|
170 | set{mSnap = value;}
|
---|
171 | }
|
---|
172 |
|
---|
173 | /// <summary>
|
---|
174 | /// Gets or sets the RestrictToCanvas property of the GraphControl
|
---|
175 | /// </summary>
|
---|
176 | public bool RestrictToCanvas
|
---|
177 | {
|
---|
178 | get{return mRestrictToCanvas ;}
|
---|
179 | set{mRestrictToCanvas = value;}
|
---|
180 | }
|
---|
181 | /// <summary>
|
---|
182 | /// Gets or sets the GridSize property of the GraphControl
|
---|
183 | /// </summary>
|
---|
184 | public int GridSize
|
---|
185 | {
|
---|
186 | get{return mGridSize ;}
|
---|
187 | set{mGridSize = value;}
|
---|
188 | }
|
---|
189 | /// <summary>
|
---|
190 | /// Gets or sets the GradientMode property of the GraphControl
|
---|
191 | /// </summary>
|
---|
192 | public LinearGradientMode GradientMode
|
---|
193 | {
|
---|
194 | get{return mGradientMode ;}
|
---|
195 | set{mGradientMode = value;}
|
---|
196 | }
|
---|
197 |
|
---|
198 | /// <summary>
|
---|
199 | /// Gets or sets the EnableContextMenu property of the GraphControl
|
---|
200 | /// </summary>
|
---|
201 | public bool EnableContextMenu
|
---|
202 | {
|
---|
203 | get{return mEnableContextMenu ;}
|
---|
204 | set{mEnableContextMenu = value;}
|
---|
205 | }
|
---|
206 |
|
---|
207 | /// <summary>
|
---|
208 | /// Gets or sets the DefaultConnectionPath property of the GraphControl
|
---|
209 | /// </summary>
|
---|
210 | public string DefaultConnectionPath
|
---|
211 | {
|
---|
212 | get{return mDefaultConnectionPath;}
|
---|
213 | set{mDefaultConnectionPath = value;}
|
---|
214 | }
|
---|
215 | /// <summary>
|
---|
216 | /// Gets or sets the BackgroundType property of the GraphControl
|
---|
217 | /// </summary>
|
---|
218 | public CanvasBackgroundType BackgroundType
|
---|
219 | {
|
---|
220 | get{return mBackgroundType;}
|
---|
221 | set{mBackgroundType = value;}
|
---|
222 | }
|
---|
223 |
|
---|
224 | /// <summary>
|
---|
225 | /// Gets or sets the BackgroundImagePath property of the GraphControl
|
---|
226 | /// </summary>
|
---|
227 | public string BackgroundImagePath
|
---|
228 | {
|
---|
229 | get{return mBackgroundImagePath;}
|
---|
230 | set{mBackgroundImagePath = value;}
|
---|
231 | }
|
---|
232 | /// <summary>
|
---|
233 | /// Gets or sets the BackgroundColor property of the GraphControl
|
---|
234 | /// </summary>
|
---|
235 | public Color BackgroundColor
|
---|
236 | {
|
---|
237 | get{return mBackgroundColor;}
|
---|
238 | set{mBackgroundColor = value;}
|
---|
239 | }
|
---|
240 | /// <summary>
|
---|
241 | /// Gets or sets the AutomataPulse property
|
---|
242 | /// </summary>
|
---|
243 | public int AutomataPulse
|
---|
244 | {
|
---|
245 | get{return mAutomataPulse;}
|
---|
246 | set{mAutomataPulse = value;}
|
---|
247 | }
|
---|
248 | /// <summary>
|
---|
249 | /// Gets or sets the AllowAddShape property of the GraphControl
|
---|
250 | /// </summary>
|
---|
251 | public bool AllowMoveShape
|
---|
252 | {
|
---|
253 | get{return mAllowMoveShape;}
|
---|
254 | set{mAllowMoveShape = value;}
|
---|
255 | }
|
---|
256 | /// <summary>
|
---|
257 | /// Gets or sets the AllowAddShape property of the GraphControl
|
---|
258 | /// </summary>
|
---|
259 | public bool AllowDeleteShape
|
---|
260 | {
|
---|
261 | get{return mAllowDeleteShape;}
|
---|
262 | set{mAllowDeleteShape = value;}
|
---|
263 | }
|
---|
264 |
|
---|
265 | /// <summary>
|
---|
266 | /// Gets or sets the AllowAddShape property of the GraphControl
|
---|
267 | /// </summary>
|
---|
268 | public bool AllowAddShape
|
---|
269 | {
|
---|
270 | get{return mAllowAddShape;}
|
---|
271 | set{mAllowAddShape = value;}
|
---|
272 | }
|
---|
273 |
|
---|
274 | /// <summary>
|
---|
275 | /// Gets or sets the AllowAddConnection property of the GraphControl
|
---|
276 | /// </summary>
|
---|
277 | public bool AllowAddConnection
|
---|
278 | {
|
---|
279 | get{return mAllowAddConnection;}
|
---|
280 | set{mAllowAddConnection = value;}
|
---|
281 | }
|
---|
282 |
|
---|
283 | /// <summary>
|
---|
284 | /// Gets or sets the gradient top-color
|
---|
285 | /// </summary>
|
---|
286 | public Color GradientTop
|
---|
287 | {
|
---|
288 | get{return mGradientTop;}
|
---|
289 | set{mGradientTop = value;}
|
---|
290 | }
|
---|
291 |
|
---|
292 | /// <summary>
|
---|
293 | /// Gets or sets the gradient bottom-color
|
---|
294 | /// </summary>
|
---|
295 | public Color GradientBottom
|
---|
296 | {
|
---|
297 | get{return mGradientBottom;}
|
---|
298 | set{mGradientBottom = value;}
|
---|
299 | }
|
---|
300 |
|
---|
301 | /// <summary>
|
---|
302 | /// Gets or sets the ShowGrid setting
|
---|
303 | /// </summary>
|
---|
304 | public bool ShowGrid
|
---|
305 | {
|
---|
306 | get{return mShowGrid;}
|
---|
307 | set{mShowGrid = value;}
|
---|
308 | }
|
---|
309 | #endregion
|
---|
310 |
|
---|
311 | #region Constructor
|
---|
312 | /// <summary>
|
---|
313 | /// Constructor
|
---|
314 | /// </summary>
|
---|
315 | public BinaryAmbiance()
|
---|
316 | {
|
---|
317 |
|
---|
318 | }
|
---|
319 | /// <summary>
|
---|
320 | /// Deserialization constructor
|
---|
321 | /// </summary>
|
---|
322 | /// <param name="info"></param>
|
---|
323 | /// <param name="context"></param> |
---|
324 | protected BinaryAmbiance(SerializationInfo info, StreamingContext context) |
---|
325 | {
|
---|
326 |
|
---|
327 |
|
---|
328 | #region Incremental serialization fix; delete try-catch when properly saved with all members
|
---|
329 | try
|
---|
330 | {
|
---|
331 | mLocked = info.GetBoolean("mLocked");
|
---|
332 | }
|
---|
333 | catch
|
---|
334 | {
|
---|
335 | this.mLocked = false;
|
---|
336 | }
|
---|
337 |
|
---|
338 | try
|
---|
339 | {
|
---|
340 | mEnableTooltip = info.GetBoolean("mEnableTooltip");
|
---|
341 | }
|
---|
342 | catch
|
---|
343 | {
|
---|
344 | mEnableTooltip = true;
|
---|
345 | }
|
---|
346 |
|
---|
347 | try
|
---|
348 | {
|
---|
349 | mShowAutomataController = info.GetBoolean("mShowAutomataController");
|
---|
350 | }
|
---|
351 | catch
|
---|
352 | {
|
---|
353 | mShowAutomataController = false;
|
---|
354 | }
|
---|
355 | #endregion
|
---|
356 | mShowGrid = info.GetBoolean("mShowGrid");
|
---|
357 | mGradientBottom = (Color) info.GetValue("mGradientBottom", typeof(Color));
|
---|
358 | mGradientTop = (Color) info.GetValue("mGradientTop", typeof(Color));
|
---|
359 | mAllowAddConnection = info.GetBoolean("mAllowAddConnection");
|
---|
360 | mAllowAddShape = info.GetBoolean("mAllowAddShape");
|
---|
361 | mAllowDeleteShape = info.GetBoolean("mAllowDeleteShape");
|
---|
362 | mAllowMoveShape = info.GetBoolean("mAllowMoveShape");
|
---|
363 | mAutomataPulse = info.GetInt32("mAutomataPulse");
|
---|
364 | mBackgroundColor = (Color) info.GetValue("mBackgroundColor", typeof(Color));
|
---|
365 | mBackgroundImagePath = info.GetString("mBackgroundImagePath");
|
---|
366 | mBackgroundType = (CanvasBackgroundType) info.GetValue("mBackgroundType", typeof(CanvasBackgroundType));
|
---|
367 | mDefaultConnectionPath = info.GetString("mDefaultConnectionPath");
|
---|
368 | mGradientMode =(LinearGradientMode) info.GetValue("mGradientMode", typeof(LinearGradientMode));
|
---|
369 | mEnableContextMenu = info.GetBoolean("mEnableContextMenu");
|
---|
370 | mGridSize = info.GetInt32("mGridSize");
|
---|
371 | mRestrictToCanvas = info.GetBoolean("mRestrictToCanvas");
|
---|
372 | mSnap = info.GetBoolean("mSnap");
|
---|
373 | mDefaultConnectionEnd = (ConnectionEnd) info.GetValue("mDefaultConnectionEnd", typeof(ConnectionEnd));
|
---|
374 | mEnableLayout = info.GetBoolean("mEnableLayout");
|
---|
375 | mGraphLayoutAlgorithm = (GraphLayoutAlgorithms) info.GetValue("mGraphLayoutAlgorithm", typeof(GraphLayoutAlgorithms));
|
---|
376 |
|
---|
377 |
|
---|
378 | }
|
---|
379 | #endregion
|
---|
380 |
|
---|
381 | #region ISerializable Members
|
---|
382 |
|
---|
383 | /// <summary>
|
---|
384 | /// Serialization of this class
|
---|
385 | /// </summary>
|
---|
386 | /// <param name="info"></param>
|
---|
387 | /// <param name="context"></param>
|
---|
388 | public void GetObjectData(SerializationInfo info, StreamingContext context)
|
---|
389 | {
|
---|
390 | info.AddValue("mLocked", mLocked);
|
---|
391 | info.AddValue("mShowGrid", mShowGrid);
|
---|
392 | info.AddValue("mGradientBottom", mGradientBottom);
|
---|
393 | info.AddValue("mGradientTop", mGradientTop);
|
---|
394 | info.AddValue("mAllowAddConnection", mAllowAddConnection);
|
---|
395 | info.AddValue("mAllowAddShape", mAllowAddShape);
|
---|
396 | info.AddValue("mAllowDeleteShape", mAllowDeleteShape);
|
---|
397 | info.AddValue("mAllowMoveShape", mAllowMoveShape);
|
---|
398 | info.AddValue("mAutomataPulse", mAutomataPulse);
|
---|
399 | info.AddValue("mBackgroundColor", mBackgroundColor);
|
---|
400 | info.AddValue("mBackgroundImagePath", mBackgroundImagePath);
|
---|
401 | info.AddValue("mBackgroundType", mBackgroundType);
|
---|
402 | info.AddValue("mDefaultConnectionPath", mDefaultConnectionPath);
|
---|
403 | info.AddValue("mGradientMode", mGradientMode);
|
---|
404 | info.AddValue("mEnableContextMenu", mEnableContextMenu);
|
---|
405 | info.AddValue("mGridSize", mGridSize);
|
---|
406 | info.AddValue("mRestrictToCanvas", mRestrictToCanvas);
|
---|
407 | info.AddValue("mSnap", mSnap);
|
---|
408 | info.AddValue("mDefaultConnectionEnd", mDefaultConnectionEnd);
|
---|
409 | info.AddValue("mEnableLayout", mEnableLayout);
|
---|
410 | info.AddValue("mGraphLayoutAlgorithm", mGraphLayoutAlgorithm);
|
---|
411 | info.AddValue("mEnableTooltip", mEnableTooltip);
|
---|
412 | info.AddValue("mShowAutomataController", mShowAutomataController);
|
---|
413 | }
|
---|
414 |
|
---|
415 | #endregion
|
---|
416 | }
|
---|
417 | }
|
---|