Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ReportTableCreated.cs
1using SkiaSharp;
2using System.Collections.Generic;
3using System.Xml;
7
9{
14 {
15 private readonly string tableId;
16 private readonly string name;
17 private readonly Column[] columns;
18
25 public ReportTableCreated(string TableId, string Name, Column[] Columns)
26 {
27 this.tableId = TableId;
28 this.name = Name;
29 this.columns = Columns;
30 }
31
36 public ReportTableCreated(XmlElement Xml)
37 {
38 this.tableId = XML.Attribute(Xml, "tableId");
39 this.name = XML.Attribute(Xml, "name");
40
41 List<Column> Columns = new List<Column>();
42
43 foreach (XmlNode N in Xml.ChildNodes)
44 {
45 if (N is XmlElement E && E.LocalName == "Column")
46 {
47 string ColumnId = XML.Attribute(E, "columnId");
48 string Header = XML.Attribute(E, "header");
49 string DataSourceId = E.HasAttribute("dataSourceId") ? XML.Attribute(E, "dataSourceId") : null;
50 string Partition = E.HasAttribute("partition") ? XML.Attribute(E, "partition") : null;
51 SKColor? FgColor = E.HasAttribute("fgColor") ? Graph.ToColor(XML.Attribute(E, "fgColor")) : (SKColor?)null;
52 SKColor? BgColor = E.HasAttribute("bgColor") ? Graph.ToColor(XML.Attribute(E, "bgColor")) : (SKColor?)null;
53 ColumnAlignment? Alignment = E.HasAttribute("alignment") ? XML.Attribute(E, "alignment", ColumnAlignment.Left) : (ColumnAlignment?)null;
54 byte? NrDecimals = E.HasAttribute("nrDecimals") ? (byte)XML.Attribute(E, "nrDecimals", 0) : (byte?)null;
55
56 Columns.Add(new Column(ColumnId, Header, DataSourceId, Partition, FgColor, BgColor, Alignment, NrDecimals));
57 }
58 }
59
60 this.columns = Columns.ToArray();
61 }
62
66 public string TableId => this.tableId;
67
71 public string Name => this.name;
72
76 public Column[] Columns => this.columns;
77
82 public override void ExportXml(XmlWriter Output)
83 {
84 Output.WriteStartElement("TableStart");
85 Output.WriteAttributeString("tableId", this.tableId);
86 Output.WriteAttributeString("name", this.name);
87
88 if (!(this.columns is null))
89 {
90 foreach (Column Column in this.columns)
91 {
92 Output.WriteStartElement("Column");
93 Output.WriteAttributeString("columnId", Column.ColumnId);
94 Output.WriteAttributeString("header", Column.Header);
95
96 if (!string.IsNullOrEmpty(Column.DataSourceId))
97 Output.WriteAttributeString("dataSourceId", Column.DataSourceId);
98
99 if (!string.IsNullOrEmpty(Column.Partition))
100 Output.WriteAttributeString("partition", Column.Partition);
101
102 if (Column.FgColor.HasValue)
103 Output.WriteAttributeString("fgColor", Column.FgColor.ToString());
104
105 if (Column.BgColor.HasValue)
106 Output.WriteAttributeString("bgColor", Column.BgColor.ToString());
107
108 if (Column.Alignment.HasValue)
109 Output.WriteAttributeString("alignment", Column.Alignment.ToString());
110
111 if (Column.NrDecimals.HasValue)
112 Output.WriteAttributeString("nrDecimals", Column.NrDecimals.ToString());
113
114 Output.WriteEndElement();
115 }
116 }
117
118 Output.WriteEndElement();
119 }
120 }
121}
Abstract base class for report elements.
override void ExportXml(XmlWriter Output)
Exports element to XML
ReportTableCreated(XmlElement Xml)
Creation of a table.
ReportTableCreated(string TableId, string Name, Column[] Columns)
Creation of a table.
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Base class for graphs.
Definition: Graph.cs:79
static SKColor ToColor(object Object)
Converts an object to a color.
Definition: Graph.cs:828
Defines a column in a table.
Definition: Column.cs:30
SKColor? FgColor
Optional Foreground Color.
Definition: Column.cs:87
string Partition
Optional partition reference.
Definition: Column.cs:82
SKColor? BgColor
Optional Background Color.
Definition: Column.cs:92
string Header
Optional localized header.
Definition: Column.cs:72
string DataSourceId
Optional Data Suorce ID reference.
Definition: Column.cs:77
string ColumnId
Column ID
Definition: Column.cs:67
byte? NrDecimals
Optional Number of Decimals.
Definition: Column.cs:102
ColumnAlignment? Alignment
Optional Column Alignment.
Definition: Column.cs:97
ColumnAlignment
Column alignment.
Definition: Column.cs:9