Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FigurePoint.cs
1using System.Threading.Tasks;
2using System.Xml;
4
6{
10 public abstract class FigurePoint : Figure
11 {
12 private LengthAttribute x;
13 private LengthAttribute y;
14 private StringAttribute @ref;
15
22 : base(Document, Parent)
23 {
24 }
25
30 {
31 get => this.x;
32 set => this.x = value;
33 }
34
39 {
40 get => this.y;
41 set => this.y = value;
42 }
43
48 {
49 get => this.@ref;
50 set => this.@ref = value;
51 }
52
57 public override Task FromXml(XmlElement Input)
58 {
59 this.x = new LengthAttribute(Input, "x", this.Document);
60 this.y = new LengthAttribute(Input, "y", this.Document);
61 this.@ref = new StringAttribute(Input, "ref", this.Document);
62
63 return base.FromXml(Input);
64 }
65
70 public override void ExportAttributes(XmlWriter Output)
71 {
72 base.ExportAttributes(Output);
73
74 this.x?.Export(Output);
75 this.y?.Export(Output);
76 this.@ref?.Export(Output);
77 }
78
83 public override void CopyContents(ILayoutElement Destination)
84 {
85 base.CopyContents(Destination);
86
87 if (Destination is FigurePoint Dest)
88 {
89 Dest.x = this.x?.CopyIfNotPreset(Destination.Document);
90 Dest.y = this.y?.CopyIfNotPreset(Destination.Document);
91 Dest.@ref = this.@ref?.CopyIfNotPreset(Destination.Document);
92 }
93 }
94
100 public override async Task DoMeasureDimensions(DrawingState State)
101 {
102 await base.DoMeasureDimensions(State);
103
104 CalculatedPoint P = await this.IncludePoint(State, this.x, this.y, this.@ref, this.xCoordinate, this.yCoordinate);
105 if (P.Ok)
106 {
107 this.xCoordinate = P.X;
108 this.yCoordinate = P.Y;
109 }
110 else
111 {
112 this.xCoordinate = 0;
113 this.yCoordinate = 0;
114
115 this.IncludePoint(this.xCoordinate, this.yCoordinate);
116 }
117 }
118
122 protected float xCoordinate;
123
127 protected float yCoordinate;
128
133 public override void ExportStateAttributes(XmlWriter Output)
134 {
135 base.ExportStateAttributes(Output);
136
137 this.x?.ExportState(Output);
138 this.y?.ExportState(Output);
139 this.@ref?.ExportState(Output);
140 }
141
142 }
143}
Contains a 2D layout document.
void Export(XmlWriter Output)
Exports the attribute.
Definition: Attribute.cs:187
void ExportState(XmlWriter Output)
Exports the state of the attribute.
Definition: Attribute.cs:199
LengthAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
StringAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Abstract base class for figures
Definition: Figure.cs:14
Abstract base class for figures based on a point.
Definition: FigurePoint.cs:11
FigurePoint(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class for figures based on a point.
Definition: FigurePoint.cs:21
LengthAttribute XAttribute
X-coordinate
Definition: FigurePoint.cs:30
LengthAttribute YAttribute
Y-coordinate
Definition: FigurePoint.cs:39
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
Definition: FigurePoint.cs:70
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: FigurePoint.cs:57
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
Definition: FigurePoint.cs:133
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
Definition: FigurePoint.cs:100
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: FigurePoint.cs:83
void IncludePoint(float X, float Y, float RX, float RY, float Angle)
Includes a point in the area measurement.
Layout2DDocument Document
Layout document.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.
Represents a calculated point.
bool Ok
If point is successfully evaluated