Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FigurePoint2.cs
1using System.Threading.Tasks;
2using System.Xml;
4
6{
10 public abstract class FigurePoint2 : FigurePoint
11 {
12 private LengthAttribute x2;
13 private LengthAttribute y2;
14 private StringAttribute ref2;
15
22 : base(Document, Parent)
23 {
24 }
25
30 {
31 get => this.x2;
32 set => this.x2 = value;
33 }
34
39 {
40 get => this.y2;
41 set => this.y2 = value;
42 }
43
48 {
49 get => this.ref2;
50 set => this.ref2 = value;
51 }
52
57 public override Task FromXml(XmlElement Input)
58 {
59 this.x2 = new LengthAttribute(Input, "x2", this.Document);
60 this.y2 = new LengthAttribute(Input, "y2", this.Document);
61 this.ref2 = new StringAttribute(Input, "ref2", 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.x2?.Export(Output);
75 this.y2?.Export(Output);
76 this.ref2?.Export(Output);
77 }
78
83 public override void CopyContents(ILayoutElement Destination)
84 {
85 base.CopyContents(Destination);
86
87 if (Destination is FigurePoint2 Dest)
88 {
89 Dest.x2 = this.x2?.CopyIfNotPreset(Destination.Document);
90 Dest.y2 = this.y2?.CopyIfNotPreset(Destination.Document);
91 Dest.ref2 = this.ref2?.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.x2, this.y2, this.@ref2, this.xCoordinate2, this.yCoordinate2);
105 if (P.Ok)
106 {
107 this.xCoordinate2 = P.X;
108 this.yCoordinate2 = P.Y;
109 }
110 else
111 {
112 float? Value = this.ExplicitWidth;
113 float? Temp;
114
115 if (!Value.HasValue)
116 {
117 Value = this.PotentialWidth;
118 if ((Temp = this.Width).HasValue && (!Value.HasValue || Temp.Value > Value.Value))
119 Value = Temp.Value;
120 }
121
122 if (Value.HasValue)
123 {
124 float X = this.xCoordinate + Value.Value;
125 if (X != this.xCoordinate2)
126 {
127 State.ReportMeasureRelative(this);
128 this.xCoordinate2 = X;
129 }
130 }
131
132 Value = this.ExplicitHeight;
133 if (!Value.HasValue)
134 {
135 Value = this.PotentialHeight;
136 if ((Temp = this.Height).HasValue && (!Value.HasValue || Temp.Value > Value.Value))
137 Value = Temp.Value;
138 }
139
140 if (Value.HasValue)
141 {
142 float Y = this.yCoordinate + Value.Value;
143 if (Y != this.yCoordinate2)
144 {
145 State.ReportMeasureRelative(this);
146 this.yCoordinate2 = Y;
147 }
148 }
149
150 this.IncludePoint(this.xCoordinate2, this.yCoordinate2);
151 }
152 }
153
157 protected float xCoordinate2;
158
162 protected float yCoordinate2;
163
168 public override void ExportStateAttributes(XmlWriter Output)
169 {
170 base.ExportStateAttributes(Output);
171
172 this.x2?.ExportState(Output);
173 this.y2?.ExportState(Output);
174 this.ref2?.ExportState(Output);
175 }
176
177 }
178}
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,...
void ReportMeasureRelative(ILayoutElement Element)
Reports an element as having relative measurements.
Abstract base class for figures with two points.
Definition: FigurePoint2.cs:11
FigurePoint2(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class for figures with two points.
Definition: FigurePoint2.cs:21
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: FigurePoint2.cs:83
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
Definition: FigurePoint2.cs:70
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: FigurePoint2.cs:57
LengthAttribute Y2Attribute
Y-coordinate 2
Definition: FigurePoint2.cs:39
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
StringAttribute Reference2Attribute
Reference 2
Definition: FigurePoint2.cs:48
LengthAttribute X2Attribute
X-coordinate 2
Definition: FigurePoint2.cs:30
Abstract base class for figures based on a point.
Definition: FigurePoint.cs:11
void IncludePoint(float X, float Y, float RX, float RY, float Angle)
Includes a point in the area measurement.
Layout2DDocument Document
Layout document.
virtual ? float PotentialHeight
Potential Height of element
virtual ? float PotentialWidth
Potential Width of element
float? ExplicitHeight
Explicit set height of element, if defined.
float? ExplicitWidth
Explicit set width of element, if defined.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.
Represents a calculated point.
bool Ok
If point is successfully evaluated