13 private SKColor backgroundColor = SKColors.White;
14 private SKColor axisColor = SKColors.Black;
15 private SKColor gridColor = SKColors.LightGray;
16 private string fontName = SKTypeface.Default.FamilyName;
17 private double labelFontSize = 12;
18 private int axisWidth = 2;
19 private int gridWidth = 1;
20 private int approxNrLabelsX = 5;
21 private int approxNrLabelsY = 10;
22 private int width = 640;
23 private int height = 480;
24 private int marginTop = 10;
25 private int marginBottom = 10;
26 private int marginLeft = 15;
27 private int marginRight = 15;
28 private int marginLabel = 5;
45 backgroundColor = this.backgroundColor,
46 axisColor = this.axisColor,
47 gridColor = this.gridColor,
48 fontName = this.fontName,
49 labelFontSize = this.labelFontSize,
50 axisWidth = this.axisWidth,
51 gridWidth = this.gridWidth,
52 approxNrLabelsX = this.approxNrLabelsX,
53 approxNrLabelsY = this.approxNrLabelsY,
56 marginTop = this.marginTop,
57 marginBottom = this.marginBottom,
58 marginLeft = this.marginLeft,
59 marginRight = this.marginRight,
60 marginLabel = this.marginLabel
73 throw new ArgumentOutOfRangeException(
"Value must be positive.", nameof(this.
Width));
88 throw new ArgumentOutOfRangeException(
"Value must be positive.", nameof(this.
Height));
99 get => this.backgroundColor;
100 set => this.backgroundColor = value;
108 get => this.axisColor;
109 set => this.axisColor = value;
117 get => this.axisWidth;
121 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
AxisWidth));
123 this.axisWidth = value;
132 get => this.gridColor;
133 set => this.gridColor = value;
141 get => this.gridWidth;
145 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
GridWidth));
147 this.gridWidth = value;
156 get => this.marginTop;
160 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
MarginTop));
162 this.marginTop = value;
171 get => this.marginBottom;
175 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
MarginBottom));
177 this.marginBottom = value;
186 get => this.marginLeft;
190 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
MarginLeft));
192 this.marginLeft = value;
201 get => this.marginRight;
205 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
MarginRight));
207 this.marginRight = value;
216 get => this.marginLabel;
220 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
MarginLabel));
222 this.marginLabel = value;
231 get => this.fontName;
234 if (
string.IsNullOrEmpty(value))
235 throw new ArgumentException(
"Value cannot be empty.", nameof(this.
FontName));
237 this.fontName = value;
246 get => this.labelFontSize;
250 throw new ArgumentOutOfRangeException(
"Value must be positive.", nameof(this.
LabelFontSize));
252 this.labelFontSize = value;
261 get => this.approxNrLabelsX;
265 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
ApproxNrLabelsX));
267 this.approxNrLabelsX = value;
276 get => this.approxNrLabelsY;
280 throw new ArgumentOutOfRangeException(
"Value must be non-negative.", nameof(this.
ApproxNrLabelsY));
282 this.approxNrLabelsY = value;
292 Output.WriteStartElement(
"Settings");
293 Output.WriteAttributeString(
"backgroundColor",
Graph.
ToRGBAStyle(
this.backgroundColor));
294 Output.WriteAttributeString(
"axisColor",
Graph.
ToRGBAStyle(
this.axisColor));
295 Output.WriteAttributeString(
"gridColor",
Graph.
ToRGBAStyle(
this.gridColor));
296 Output.WriteAttributeString(
"fontName", this.fontName);
297 Output.WriteAttributeString(
"labelFontSize",
Expression.
ToString(
this.labelFontSize));
298 Output.WriteAttributeString(
"axisWidth", this.axisWidth.ToString());
299 Output.WriteAttributeString(
"gridWidth", this.gridWidth.ToString());
300 Output.WriteAttributeString(
"approxNrLabelsX", this.approxNrLabelsX.ToString());
301 Output.WriteAttributeString(
"approxNrLabelsY", this.approxNrLabelsY.ToString());
302 Output.WriteAttributeString(
"width", this.width.ToString());
303 Output.WriteAttributeString(
"height", this.height.ToString());
304 Output.WriteAttributeString(
"marginTop", this.marginTop.ToString());
305 Output.WriteAttributeString(
"marginBottom", this.marginBottom.ToString());
306 Output.WriteAttributeString(
"marginLeft", this.marginLeft.ToString());
307 Output.WriteAttributeString(
"marginRight", this.marginRight.ToString());
308 Output.WriteAttributeString(
"marginLabel", this.marginLabel.ToString());
309 Output.WriteEndElement();
322 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"backgroundColor")) &&
Color.
TryParse(s, out SKColor cl))
323 Result.backgroundColor = cl;
325 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"axisColor")) &&
Color.
TryParse(s, out cl))
326 Result.axisColor = cl;
328 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"gridColor")) &&
Color.
TryParse(s, out cl))
329 Result.gridColor = cl;
331 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"fontName")))
334 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"labelFontSize")) &&
Expression.
TryParse(s, out
double d))
335 Result.labelFontSize = d;
337 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"axisWidth")) &&
int.TryParse(s, out
int i))
338 Result.axisWidth = i;
340 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"gridWidth")) &&
int.TryParse(s, out i))
341 Result.gridWidth = i;
343 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"approxNrLabelsX")) &&
int.TryParse(s, out i))
344 Result.approxNrLabelsX = i;
346 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"approxNrLabelsY")) &&
int.TryParse(s, out i))
347 Result.approxNrLabelsY = i;
349 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"width")) &&
int.TryParse(s, out i))
352 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"height")) &&
int.TryParse(s, out i))
355 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"marginTop")) &&
int.TryParse(s, out i))
356 Result.marginTop = i;
358 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"marginBottom")) &&
int.TryParse(s, out i))
359 Result.marginBottom = i;
361 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"marginLeft")) &&
int.TryParse(s, out i))
362 Result.marginLeft = i;
364 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"marginRight")) &&
int.TryParse(s, out i))
365 Result.marginRight = i;
367 if (!
string.IsNullOrEmpty(s = Xml.GetAttribute(
"marginLabel")) &&
int.TryParse(s, out i))
368 Result.marginLabel = i;
Class managing a script expression.
static bool TryParse(string s, out double Value)
Tries to parse a double-precision floating-point value.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Returns a color value from a string.
static bool TryParse(string s, out SKColor Color)
Tries to parse a string containing a color name.
static string ToRGBAStyle(SKColor Color)
Converts a color to an RGB(A) style string.
void ExportSettings(XmlWriter Output)
Exports the settings to an XML writer.
SKColor AxisColor
Axis color.
SKColor BackgroundColor
Background color.
int ApproxNrLabelsY
Approximate number of labels along the Y-axis.
int MarginLabel
Label margin.
int MarginRight
Right margin.
int ApproxNrLabelsX
Approximate number of labels along the X-axis.
GraphSettings()
Graph settings.
int MarginLeft
Left margin.
static GraphSettings Import(XmlElement Xml)
Imports graph settings from an XML element.
int MarginBottom
Bottom margin.
double LabelFontSize
Label font size
SKColor GridColor
Grid color.
int Width
Width of graph, in pixels. (Default=640 pixels.)
int Height
Height of graph, in pixels. (Default=480 pixels.)
GraphSettings Copy()
Copies the graph settings.
string FontName
Font name.