2using System.Collections.Generic;
3using System.Threading.Tasks;
25 : base(Document, Parent)
35 set => this.children = value;
41 public bool HasChildren => !(this.children is
null) && this.children.Length > 0;
61 public override async Task
FromXml(XmlElement Input)
63 await base.FromXml(Input);
65 List<ILayoutElement>
Children =
null;
67 foreach (XmlNode Node
in Input.ChildNodes)
69 if (Node is XmlElement E)
72 Children =
new List<ILayoutElement>();
87 base.ExportChildren(Output);
102 base.CopyContents(Destination);
106 if (this.HasChildren)
108 int i, c = this.children.Length;
112 for (i = 0; i < c; i++)
113 Children[i] = this.children[i].
Copy(Dest);
115 Dest.children = Children;
126 this.left0 = this.right0 = this.top0 = this.bottom0 = this.width0 = this.height0 =
null;
136 await base.DoMeasureDimensions(State);
160 if (this.left0.HasValue &&
this.right0.HasValue)
162 f = this.right0.Value - this.left0.Value;
164 if (!this.width0.HasValue || f >
this.width0.Value)
168 if (this.top0.HasValue &&
this.bottom0.HasValue)
170 f = this.bottom0.Value - this.top0.Value;
172 if (!this.height0.HasValue || f >
this.height0.Value)
176 this.Left = this.Right = this.Width =
null;
177 this.Top = this.Bottom = this.Height =
null;
179 if (this.width0.HasValue ||
this.ExplicitWidth.HasValue)
181 this.Width = this.ExplicitWidth ?? this.width0;
182 if (this.left0.HasValue)
183 this.Left = this.left0;
185 this.Right = this.right0;
189 this.Right = this.right0;
190 this.Left = this.left0;
193 if (this.height0.HasValue ||
this.ExplicitHeight.HasValue)
195 this.Height = this.ExplicitHeight ?? this.height0;
196 if (this.top0.HasValue)
197 this.Top = this.top0;
199 this.Bottom = this.bottom0;
203 this.Bottom = this.bottom0;
204 this.Top = this.top0;
207 return Task.CompletedTask;
210 private float? left0;
211 private float? right0;
213 private float? bottom0;
214 private float? width0;
215 private float? height0;
223 float? X = Element.
Left;
224 float? Y = Element.
Top;
227 if (X.HasValue && Y.HasValue)
231 if (!this.width0.HasValue || (V.HasValue && V.Value >
this.width0.Value))
237 if (X.HasValue && Y.HasValue)
241 if (!this.height0.HasValue || (V.HasValue && V.Value >
this.height0.Value))
256 base.MeasurePositions(State);
281 float Py = (float)(Y + RY * Math.Sin(
Angle * DegreesToRadians));
293 if (!this.left0.HasValue || X <
this.left0.Value)
296 if (!this.right0.HasValue || X >
this.right0.Value)
299 if (!this.top0.HasValue || Y <
this.top0.Value)
302 if (!this.bottom0.HasValue || Y >
this.bottom0.Value)
332 if (this.HasChildren)
348 await base.RegisterIDs(Session);
350 if (this.HasChildren)
363 base.ExportStateChildren(Output);
365 if (this.HasChildren)
Contains a 2D layout document.
Abstract base class for angle elements.
Abstract base class for layout elements with an implicit area.
Abstract base class for layout containers (area elements containing embedded layout elements).
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
void IncludePoint(float X, float Y, float RX, float RY, float Angle)
Includes a point in the area measurement.
bool HasChildren
If the element has children or not.
override void ExportStateChildren(XmlWriter Output)
Exports the current state of child nodes of the current element.
override async Task RegisterIDs(Variables Session)
Registers any IDs defined with the encapsulating document.
override void BeforeMeasureDimensions(DrawingState State)
Called before dimensions are measured.
virtual bool MeasureChildrenPositions
If children positions are to be measured.
virtual bool MeasureChildrenDimensions
If children dimensions are to be measured.
ILayoutElement[] Children
Child elements
override async Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
override void ExportChildren(XmlWriter Output)
Exports child elements to XML.
void IncludeElement(ILayoutElement Element)
Includes element in dimension measurement.
LayoutContainer(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class for layout containers (area elements containing embedded layout elements).
override void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
async Task< CalculatedPoint > IncludePoint(DrawingState State, LengthAttribute XAttribute, LengthAttribute YAttribute, StringAttribute RefAttribute, float X, float Y)
Includes a point in the area measurement.
override void Dispose()
IDisposable.Dispose
override async Task Draw(DrawingState State)
Draws layout entities.
override Task AfterMeasureDimensions(DrawingState State)
Called when dimensions have been measured.
void IncludePoint(float X, float Y)
Includes a point in the area measurement.
ILayoutElement Copy(ILayoutElement Parent)
Creates a copy of the layout element.
Layout2DDocument Document
Layout document.
const float DegreesToRadians
Pi / 180
async Task< CalculatedPoint > CalcPoint(DrawingState State, LengthAttribute XAttribute, LengthAttribute YAttribute, StringAttribute RefAttribute, float X, float Y)
Includes a point in the area measurement.
Base interface for all layout elements.
float? Bottom
Bottom coordinate of bounding box, after measurement.
float? Width
Width of element
Task RegisterIDs(Variables Session)
Registers any IDs defined with the encapsulating document.
float? Right
Right coordinate of bounding box, after measurement.
Task Draw(DrawingState State)
Draws layout entities.
void BeforeMeasureDimensions(DrawingState State)
Called before dimensions are measured.
bool IsVisible
If the element is visible or not.
float? Left
Left coordinate of bounding box, after measurement.
Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
float? Top
Top coordinate of bounding box, after measurement.
string ExportState()
Exports the internal state of the layout.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
Task AfterMeasureDimensions(DrawingState State)
Called when dimensions have been measured.
float? Height
Height of element
string ToXml()
Exports the element to XML.
Represents a calculated point.
bool Ok
If point is successfully evaluated