1 | /*******************************************************************************
|
---|
2 | * You may amend and distribute as you like, but don't remove this header!
|
---|
3 | *
|
---|
4 | * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
|
---|
5 | * See http://www.codeplex.com/EPPlus for details.
|
---|
6 | *
|
---|
7 | * Copyright (C) 2011 Jan Källman
|
---|
8 | *
|
---|
9 | * This library is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU Lesser General Public
|
---|
11 | * License as published by the Free Software Foundation; either
|
---|
12 | * version 2.1 of the License, or (at your option) any later version.
|
---|
13 |
|
---|
14 | * This library is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
17 | * See the GNU Lesser General Public License for more details.
|
---|
18 | *
|
---|
19 | * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
|
---|
20 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
|
---|
21 | *
|
---|
22 | * All code and executables are provided "as is" with no warranty either express or implied.
|
---|
23 | * The author accepts no liability for any damage or loss of business that this product may cause.
|
---|
24 | *
|
---|
25 | * Code change notes:
|
---|
26 | *
|
---|
27 | * Author Change Date
|
---|
28 | *******************************************************************************
|
---|
29 | * Jan Källman Added 2009-10-01
|
---|
30 | * Jan Källman License changed GPL-->LGPL 2011-12-16
|
---|
31 | *******************************************************************************/
|
---|
32 | using System;
|
---|
33 | using System.Collections.Generic;
|
---|
34 | using System.Text;
|
---|
35 | using System.Xml;
|
---|
36 | using OfficeOpenXml.Style;
|
---|
37 | using System.Globalization;
|
---|
38 | namespace OfficeOpenXml.Drawing.Chart
|
---|
39 | {
|
---|
40 | /// <summary>
|
---|
41 | /// Position of the axis.
|
---|
42 | /// </summary>
|
---|
43 | public enum eAxisPosition
|
---|
44 | {
|
---|
45 | Left = 0,
|
---|
46 | Bottom = 1,
|
---|
47 | Right = 2,
|
---|
48 | Top = 3
|
---|
49 | }
|
---|
50 | /// <summary>
|
---|
51 | /// Position of the Y-Axis
|
---|
52 | /// </summary>
|
---|
53 | public enum eYAxisPosition
|
---|
54 | {
|
---|
55 | Left = 0,
|
---|
56 | Right = 2,
|
---|
57 | }
|
---|
58 | /// <summary>
|
---|
59 | /// Position of the X-Axis
|
---|
60 | /// </summary>
|
---|
61 | public enum eXAxisPosition
|
---|
62 | {
|
---|
63 | Bottom = 1,
|
---|
64 | Top = 3
|
---|
65 | }
|
---|
66 | /// <summary>
|
---|
67 | /// Axis orientaion
|
---|
68 | /// </summary>
|
---|
69 | public enum eAxisOrientation
|
---|
70 | {
|
---|
71 | MaxMin,
|
---|
72 | MinMax
|
---|
73 | }
|
---|
74 | /// <summary>
|
---|
75 | /// How the axis are crossed
|
---|
76 | /// </summary>
|
---|
77 | public enum eCrossBetween
|
---|
78 | {
|
---|
79 | /// <summary>
|
---|
80 | /// Specifies the value axis shall cross the category axis between data markers
|
---|
81 | /// </summary>
|
---|
82 | Between,
|
---|
83 | /// <summary>
|
---|
84 | /// Specifies the value axis shall cross the category axis at the midpoint of a category.
|
---|
85 | /// </summary>
|
---|
86 | MidCat
|
---|
87 | }
|
---|
88 | /// <summary>
|
---|
89 | /// Where the axis cross.
|
---|
90 | /// </summary>
|
---|
91 | public enum eCrosses
|
---|
92 | {
|
---|
93 | /// <summary>
|
---|
94 | /// (Axis Crosses at Zero) The category axis crosses at the zero point of the valueaxis (if possible), or the minimum value (if theminimum is greater than zero) or the maximum (if the maximum is less than zero).
|
---|
95 | /// </summary>
|
---|
96 | AutoZero,
|
---|
97 | /// <summary>
|
---|
98 | /// The axis crosses at the maximum value
|
---|
99 | /// </summary>
|
---|
100 | Max,
|
---|
101 | /// <summary>
|
---|
102 | /// (Axis crosses at the minimum value of the chart.
|
---|
103 | /// </summary>
|
---|
104 | Min
|
---|
105 | }
|
---|
106 | /// <summary>
|
---|
107 | /// Tickmarks
|
---|
108 | /// </summary>
|
---|
109 | public enum eAxisTickMark
|
---|
110 | {
|
---|
111 | /// <summary>
|
---|
112 | /// Specifies the tick marks shall cross the axis.
|
---|
113 | /// </summary>
|
---|
114 | Cross,
|
---|
115 | /// <summary>
|
---|
116 | /// Specifies the tick marks shall be inside the plot area.
|
---|
117 | /// </summary>
|
---|
118 | In,
|
---|
119 | /// <summary>
|
---|
120 | /// Specifies there shall be no tick marks.
|
---|
121 | /// </summary>
|
---|
122 | None,
|
---|
123 | /// <summary>
|
---|
124 | /// Specifies the tick marks shall be outside the plot area.
|
---|
125 | /// </summary>
|
---|
126 | Out
|
---|
127 | }
|
---|
128 | /// <summary>
|
---|
129 | /// An axis for a chart
|
---|
130 | /// </summary>
|
---|
131 | public sealed class ExcelChartAxis : XmlHelper
|
---|
132 | {
|
---|
133 | /// <summary>
|
---|
134 | /// Type of axis
|
---|
135 | /// </summary>
|
---|
136 | internal enum eAxisType
|
---|
137 | {
|
---|
138 | /// <summary>
|
---|
139 | /// Value axis
|
---|
140 | /// </summary>
|
---|
141 | Val,
|
---|
142 | /// <summary>
|
---|
143 | /// Category axis
|
---|
144 | /// </summary>
|
---|
145 | Cat,
|
---|
146 | /// <summary>
|
---|
147 | /// Date axis
|
---|
148 | /// </summary>
|
---|
149 | Date
|
---|
150 | }
|
---|
151 | internal ExcelChartAxis(XmlNamespaceManager nameSpaceManager, XmlNode topNode) :
|
---|
152 | base(nameSpaceManager, topNode)
|
---|
153 | {
|
---|
154 | SchemaNodeOrder = new string[] { "axId", "scaling", "logBase", "orientation", "max", "min", "delete", "axPos", "majorGridlines", "title", "numFmt", "majorTickMark", "minorTickMark", "tickLblPos", "spPr", "txPr", "crossAx", "crossesAt", "crosses", "crossBetween", "auto", "lblOffset", "majorUnit", "minorUnit", "dispUnits", "spPr", "txPr" };
|
---|
155 | }
|
---|
156 | internal string Id
|
---|
157 | {
|
---|
158 | get
|
---|
159 | {
|
---|
160 | return GetXmlNodeString("c:axId/@val");
|
---|
161 | }
|
---|
162 | }
|
---|
163 | const string _majorTickMark = "c:majorTickMark/@val";
|
---|
164 | /// <summary>
|
---|
165 | /// majorTickMark
|
---|
166 | /// This element specifies the major tick marks for the axis.
|
---|
167 | /// </summary>
|
---|
168 | public eAxisTickMark MajorTickMark
|
---|
169 | {
|
---|
170 | get
|
---|
171 | {
|
---|
172 | return (eAxisTickMark)Enum.Parse( typeof( eAxisTickMark ), GetXmlNodeString( _majorTickMark ) );
|
---|
173 | }
|
---|
174 | set
|
---|
175 | {
|
---|
176 | SetXmlNodeString( _majorTickMark, value.ToString().ToLower() );
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 | const string _minorTickMark = "c:minorTickMark/@val";
|
---|
181 | /// <summary>
|
---|
182 | /// minorTickMark
|
---|
183 | /// This element specifies the minor tick marks for the axis.
|
---|
184 | /// </summary>
|
---|
185 | public eAxisTickMark MinorTickMark
|
---|
186 | {
|
---|
187 | get
|
---|
188 | {
|
---|
189 | return (eAxisTickMark)Enum.Parse(typeof(eAxisTickMark), GetXmlNodeString( _minorTickMark ) );
|
---|
190 | }
|
---|
191 | set
|
---|
192 | {
|
---|
193 | SetXmlNodeString(_minorTickMark, value.ToString().ToLower());
|
---|
194 | }
|
---|
195 | }
|
---|
196 | /// <summary>
|
---|
197 | /// Type of axis
|
---|
198 | /// </summary>
|
---|
199 | internal eAxisType AxisType
|
---|
200 | {
|
---|
201 | get
|
---|
202 | {
|
---|
203 | try
|
---|
204 | {
|
---|
205 | return (eAxisType)Enum.Parse(typeof(eAxisType), TopNode.LocalName.Substring(0,3), true);
|
---|
206 | }
|
---|
207 | catch
|
---|
208 | {
|
---|
209 | return eAxisType.Val;
|
---|
210 | }
|
---|
211 | }
|
---|
212 | }
|
---|
213 | private string AXIS_POSITION_PATH = "c:axPos/@val";
|
---|
214 | /// <summary>
|
---|
215 | /// Where the axis is located
|
---|
216 | /// </summary>
|
---|
217 | public eAxisPosition AxisPosition
|
---|
218 | {
|
---|
219 | get
|
---|
220 | {
|
---|
221 | switch(GetXmlNodeString(AXIS_POSITION_PATH))
|
---|
222 | {
|
---|
223 | case "b":
|
---|
224 | return eAxisPosition.Bottom;
|
---|
225 | case "r":
|
---|
226 | return eAxisPosition.Right;
|
---|
227 | case "t":
|
---|
228 | return eAxisPosition.Top;
|
---|
229 | default:
|
---|
230 | return eAxisPosition.Left;
|
---|
231 | }
|
---|
232 | }
|
---|
233 | internal set
|
---|
234 | {
|
---|
235 | SetXmlNodeString(AXIS_POSITION_PATH, value.ToString().ToLower().Substring(0,1));
|
---|
236 | }
|
---|
237 | }
|
---|
238 | const string _crossesPath = "c:crosses/@val";
|
---|
239 | /// <summary>
|
---|
240 | /// Where the axis cross
|
---|
241 | /// </summary>
|
---|
242 | public eCrosses Crosses
|
---|
243 | {
|
---|
244 | get
|
---|
245 | {
|
---|
246 | return (eCrosses)Enum.Parse(typeof(eCrosses), GetXmlNodeString(_crossesPath), true);
|
---|
247 | }
|
---|
248 | set
|
---|
249 | {
|
---|
250 | var v = value.ToString();
|
---|
251 | v = v.Substring(1).ToLower() + v.Substring(1, v.Length - 1);
|
---|
252 | SetXmlNodeString(_crossesPath, v);
|
---|
253 | }
|
---|
254 |
|
---|
255 | }
|
---|
256 | const string _crossBetweenPath = "c:crossBetween/@val";
|
---|
257 | /// <summary>
|
---|
258 | /// How the axis are crossed
|
---|
259 | /// </summary>
|
---|
260 | public eCrossBetween CrossBetween
|
---|
261 | {
|
---|
262 | get
|
---|
263 | {
|
---|
264 | return (eCrossBetween)Enum.Parse(typeof(eCrossBetween), GetXmlNodeString(_crossBetweenPath), true);
|
---|
265 | }
|
---|
266 | set
|
---|
267 | {
|
---|
268 | var v = value.ToString();
|
---|
269 | v = v.Substring(1).ToLower() + v.Substring(1, v.Length - 1);
|
---|
270 | SetXmlNodeString(_crossBetweenPath, v);
|
---|
271 | }
|
---|
272 |
|
---|
273 | }
|
---|
274 | const string _crossesAtPath = "c:crossesAt/@val";
|
---|
275 | /// <summary>
|
---|
276 | /// The value where the axis cross.
|
---|
277 | /// Null is automatic
|
---|
278 | /// </summary>
|
---|
279 | public double? CrossesAt
|
---|
280 | {
|
---|
281 | get
|
---|
282 | {
|
---|
283 | return GetXmlNodeDoubleNull(_crossesAtPath);
|
---|
284 | }
|
---|
285 | set
|
---|
286 | {
|
---|
287 | if (value == null)
|
---|
288 | {
|
---|
289 | DeleteNode(_crossesAtPath);
|
---|
290 | }
|
---|
291 | else
|
---|
292 | {
|
---|
293 | SetXmlNodeString(_crossesAtPath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
294 | }
|
---|
295 | }
|
---|
296 | }
|
---|
297 | const string _formatPath = "c:numFmt/@formatCode";
|
---|
298 | /// <summary>
|
---|
299 | /// Numberformat
|
---|
300 | /// </summary>
|
---|
301 | public string Format
|
---|
302 | {
|
---|
303 | get
|
---|
304 | {
|
---|
305 | return GetXmlNodeString(_formatPath);
|
---|
306 | }
|
---|
307 | set
|
---|
308 | {
|
---|
309 | SetXmlNodeString(_formatPath,value);
|
---|
310 | }
|
---|
311 | }
|
---|
312 |
|
---|
313 | const string _lblPos = "c:tickLblPos/@val";
|
---|
314 | /// <summary>
|
---|
315 | /// Position of the labels
|
---|
316 | /// </summary>
|
---|
317 | public eTickLabelPosition LabelPosition
|
---|
318 | {
|
---|
319 | get
|
---|
320 | {
|
---|
321 | return (eTickLabelPosition)Enum.Parse(typeof(eTickLabelPosition), GetXmlNodeString(_lblPos), true);
|
---|
322 | }
|
---|
323 | set
|
---|
324 | {
|
---|
325 | string lp = value.ToString();
|
---|
326 | SetXmlNodeString(_lblPos, lp.Substring(0, 1).ToLower() + lp.Substring(1, lp.Length - 1));
|
---|
327 | }
|
---|
328 | }
|
---|
329 | ExcelDrawingFill _fill = null;
|
---|
330 | /// <summary>
|
---|
331 | /// Access to fill properties
|
---|
332 | /// </summary>
|
---|
333 | public ExcelDrawingFill Fill
|
---|
334 | {
|
---|
335 | get
|
---|
336 | {
|
---|
337 | if (_fill == null)
|
---|
338 | {
|
---|
339 | _fill = new ExcelDrawingFill(NameSpaceManager, TopNode, "c:spPr");
|
---|
340 | }
|
---|
341 | return _fill;
|
---|
342 | }
|
---|
343 | }
|
---|
344 | ExcelDrawingBorder _border = null;
|
---|
345 | /// <summary>
|
---|
346 | /// Access to border properties
|
---|
347 | /// </summary>
|
---|
348 | public ExcelDrawingBorder Border
|
---|
349 | {
|
---|
350 | get
|
---|
351 | {
|
---|
352 | if (_border == null)
|
---|
353 | {
|
---|
354 | _border = new ExcelDrawingBorder(NameSpaceManager, TopNode, "c:spPr/a:ln");
|
---|
355 | }
|
---|
356 | return _border;
|
---|
357 | }
|
---|
358 | }
|
---|
359 | ExcelTextFont _font = null;
|
---|
360 | /// <summary>
|
---|
361 | /// Access to font properties
|
---|
362 | /// </summary>
|
---|
363 | public ExcelTextFont Font
|
---|
364 | {
|
---|
365 | get
|
---|
366 | {
|
---|
367 | if (_font == null)
|
---|
368 | {
|
---|
369 | if (TopNode.SelectSingleNode("c:txPr", NameSpaceManager) == null)
|
---|
370 | {
|
---|
371 | CreateNode("c:txPr/a:bodyPr");
|
---|
372 | CreateNode("c:txPr/a:lstStyle");
|
---|
373 | }
|
---|
374 | _font = new ExcelTextFont(NameSpaceManager, TopNode, "c:txPr/a:p/a:pPr/a:defRPr", new string[] { "pPr", "defRPr", "solidFill", "uFill", "latin", "cs", "r", "rPr", "t" });
|
---|
375 | }
|
---|
376 | return _font;
|
---|
377 | }
|
---|
378 | }
|
---|
379 | /// <summary>
|
---|
380 | /// If the axis is deleted
|
---|
381 | /// </summary>
|
---|
382 | public bool Deleted
|
---|
383 | {
|
---|
384 | get
|
---|
385 | {
|
---|
386 | return GetXmlNodeBool("c:delete/@val");
|
---|
387 | }
|
---|
388 | set
|
---|
389 | {
|
---|
390 | SetXmlNodeBool("c:delete/@val", value);
|
---|
391 | }
|
---|
392 | }
|
---|
393 | const string _ticLblPos_Path = "c:tickLblPos/@val";
|
---|
394 | /// <summary>
|
---|
395 | /// Position of the Lables
|
---|
396 | /// </summary>
|
---|
397 | public eTickLabelPosition TickLabelPosition
|
---|
398 | {
|
---|
399 | get
|
---|
400 | {
|
---|
401 | string v = GetXmlNodeString(_ticLblPos_Path);
|
---|
402 | if (v == "")
|
---|
403 | {
|
---|
404 | return eTickLabelPosition.None;
|
---|
405 | }
|
---|
406 | else
|
---|
407 | {
|
---|
408 | return (eTickLabelPosition)Enum.Parse(typeof(eTickLabelPosition), v, true);
|
---|
409 | }
|
---|
410 | }
|
---|
411 | set
|
---|
412 | {
|
---|
413 | string v = value.ToString();
|
---|
414 | v=v.Substring(0, 1).ToLower() + v.Substring(1, v.Length - 1);
|
---|
415 | SetXmlNodeString(_ticLblPos_Path,v);
|
---|
416 | }
|
---|
417 | }
|
---|
418 | ExcelChartTitle _title = null;
|
---|
419 | /// <summary>
|
---|
420 | /// Chart axis title
|
---|
421 | /// </summary>
|
---|
422 | public ExcelChartTitle Title
|
---|
423 | {
|
---|
424 | get
|
---|
425 | {
|
---|
426 | if (_title == null)
|
---|
427 | {
|
---|
428 | var node = TopNode.SelectSingleNode("c:title", NameSpaceManager);
|
---|
429 | if (node == null)
|
---|
430 | {
|
---|
431 | CreateNode("c:title");
|
---|
432 | node = TopNode.SelectSingleNode("c:title", NameSpaceManager);
|
---|
433 | node.InnerXml = "<c:tx><c:rich><a:bodyPr /><a:lstStyle /><a:p><a:r><a:t /></a:r></a:p></c:rich></c:tx><c:layout /><c:overlay val=\"0\" />";
|
---|
434 | }
|
---|
435 | _title = new ExcelChartTitle(NameSpaceManager, TopNode);
|
---|
436 | }
|
---|
437 | return _title;
|
---|
438 | }
|
---|
439 | }
|
---|
440 | #region "Scaling"
|
---|
441 | const string _minValuePath = "c:scaling/c:min/@val";
|
---|
442 | /// <summary>
|
---|
443 | /// Minimum value for the axis.
|
---|
444 | /// Null is automatic
|
---|
445 | /// </summary>
|
---|
446 | public double? MinValue
|
---|
447 | {
|
---|
448 | get
|
---|
449 | {
|
---|
450 | return GetXmlNodeDoubleNull(_minValuePath);
|
---|
451 | }
|
---|
452 | set
|
---|
453 | {
|
---|
454 | if (value == null)
|
---|
455 | {
|
---|
456 | DeleteNode(_minValuePath);
|
---|
457 | }
|
---|
458 | else
|
---|
459 | {
|
---|
460 | SetXmlNodeString(_minValuePath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
461 | }
|
---|
462 | }
|
---|
463 | }
|
---|
464 | const string _maxValuePath = "c:scaling/c:max/@val";
|
---|
465 | /// <summary>
|
---|
466 | /// Max value for the axis.
|
---|
467 | /// Null is automatic
|
---|
468 | /// </summary>
|
---|
469 | public double? MaxValue
|
---|
470 | {
|
---|
471 | get
|
---|
472 | {
|
---|
473 | return GetXmlNodeDoubleNull(_maxValuePath);
|
---|
474 | }
|
---|
475 | set
|
---|
476 | {
|
---|
477 | if (value == null)
|
---|
478 | {
|
---|
479 | DeleteNode(_maxValuePath);
|
---|
480 | }
|
---|
481 | else
|
---|
482 | {
|
---|
483 | SetXmlNodeString(_maxValuePath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
484 | }
|
---|
485 | }
|
---|
486 | }
|
---|
487 | const string _majorUnitPath = "c:majorUnit/@val";
|
---|
488 | const string _majorUnitCatPath = "c:tickLblSkip/@val";
|
---|
489 | /// <summary>
|
---|
490 | /// Major unit for the axis.
|
---|
491 | /// Null is automatic
|
---|
492 | /// </summary>
|
---|
493 | public double? MajorUnit
|
---|
494 | {
|
---|
495 | get
|
---|
496 | {
|
---|
497 | if (AxisType == eAxisType.Cat)
|
---|
498 | {
|
---|
499 | return GetXmlNodeDoubleNull(_majorUnitCatPath);
|
---|
500 | }
|
---|
501 | else
|
---|
502 | {
|
---|
503 | return GetXmlNodeDoubleNull(_majorUnitPath);
|
---|
504 | }
|
---|
505 | }
|
---|
506 | set
|
---|
507 | {
|
---|
508 | if (value == null)
|
---|
509 | {
|
---|
510 | DeleteNode(_majorUnitPath);
|
---|
511 | DeleteNode(_majorUnitCatPath);
|
---|
512 | }
|
---|
513 | else
|
---|
514 | {
|
---|
515 | if (AxisType == eAxisType.Cat)
|
---|
516 | {
|
---|
517 | SetXmlNodeString(_majorUnitCatPath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
518 | }
|
---|
519 | else
|
---|
520 | {
|
---|
521 | SetXmlNodeString(_majorUnitPath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
522 | }
|
---|
523 | }
|
---|
524 | }
|
---|
525 | }
|
---|
526 | const string _minorUnitPath = "c:minorUnit/@val";
|
---|
527 | const string _minorUnitCatPath = "c:tickMarkSkip/@val";
|
---|
528 | /// <summary>
|
---|
529 | /// Minor unit for the axis.
|
---|
530 | /// Null is automatic
|
---|
531 | /// </summary>
|
---|
532 | public double? MinorUnit
|
---|
533 | {
|
---|
534 | get
|
---|
535 | {
|
---|
536 | if (AxisType == eAxisType.Cat)
|
---|
537 | {
|
---|
538 | return GetXmlNodeDoubleNull(_minorUnitCatPath);
|
---|
539 | }
|
---|
540 | else
|
---|
541 | {
|
---|
542 | return GetXmlNodeDoubleNull(_minorUnitPath);
|
---|
543 | }
|
---|
544 | }
|
---|
545 | set
|
---|
546 | {
|
---|
547 | if (value == null)
|
---|
548 | {
|
---|
549 | DeleteNode(_minorUnitPath);
|
---|
550 | DeleteNode(_minorUnitCatPath);
|
---|
551 | }
|
---|
552 | else
|
---|
553 | {
|
---|
554 | if (AxisType == eAxisType.Cat)
|
---|
555 | {
|
---|
556 | SetXmlNodeString(_minorUnitCatPath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
557 | }
|
---|
558 | else
|
---|
559 | {
|
---|
560 | SetXmlNodeString(_minorUnitPath, ((double)value).ToString(CultureInfo.InvariantCulture));
|
---|
561 | }
|
---|
562 | }
|
---|
563 | }
|
---|
564 | }
|
---|
565 | const string _logbasePath = "c:scaling/c:logBase/@val";
|
---|
566 | /// <summary>
|
---|
567 | /// The base for a logaritmic scale
|
---|
568 | /// Null for a normal scale
|
---|
569 | /// </summary>
|
---|
570 | public double? LogBase
|
---|
571 | {
|
---|
572 | get
|
---|
573 | {
|
---|
574 | return GetXmlNodeDoubleNull(_logbasePath);
|
---|
575 | }
|
---|
576 | set
|
---|
577 | {
|
---|
578 | if (value == null)
|
---|
579 | {
|
---|
580 | DeleteNode(_logbasePath);
|
---|
581 | }
|
---|
582 | else
|
---|
583 | {
|
---|
584 | double v = ((double)value);
|
---|
585 | if (v < 2 || v > 1000)
|
---|
586 | {
|
---|
587 | throw(new ArgumentOutOfRangeException("Value must be between 2 and 1000"));
|
---|
588 | }
|
---|
589 | SetXmlNodeString(_logbasePath, v.ToString("0.0", CultureInfo.InvariantCulture));
|
---|
590 | }
|
---|
591 | }
|
---|
592 | }
|
---|
593 | const string _orientationPath = "c:scaling/c:orientation/@val";
|
---|
594 | /// <summary>
|
---|
595 | ///
|
---|
596 | /// </summary>
|
---|
597 | public eAxisOrientation Orientation
|
---|
598 | {
|
---|
599 | get
|
---|
600 | {
|
---|
601 | string v = GetXmlNodeString(_orientationPath);
|
---|
602 | if (v == "")
|
---|
603 | {
|
---|
604 | return eAxisOrientation.MinMax;
|
---|
605 | }
|
---|
606 | else
|
---|
607 | {
|
---|
608 | return (eAxisOrientation)Enum.Parse(typeof(eAxisOrientation), v, true);
|
---|
609 | }
|
---|
610 | }
|
---|
611 | set
|
---|
612 | {
|
---|
613 | string s=value.ToString();
|
---|
614 | s=s.Substring(0,1).ToLower() + s.Substring(1,s.Length-1);
|
---|
615 | SetXmlNodeString(_orientationPath, s);
|
---|
616 | }
|
---|
617 | }
|
---|
618 | #endregion
|
---|
619 | }
|
---|
620 | }
|
---|