2using System.Collections.Generic;
3using System.Threading.Tasks;
13 private readonly List<Padding> currentColumn =
new List<Padding>();
14 private readonly List<Tuple<float, float, Padding[]>> columns =
new List<Tuple<float, float, Padding[]>>();
16 private readonly
float limitHeight;
20 private float maxWidth = 0;
21 private float maxHeight = 0;
37 this.session = Session;
38 this.limitHeight = WidthLimit;
50 float Width = Element.Width ?? 0;
51 float Height = Element.Height ?? 0;
53 if (this.y + Height > this.limitHeight)
56 this.currentColumn.Add(
new Padding(Element, 0, 0));
59 if (Width > this.maxWidth)
60 this.maxWidth = Width;
62 return Task.CompletedTask;
70 if (this.currentColumn.Count > 0)
72 this.columns.Add(
new Tuple<
float,
float,
Padding[]>(this.maxWidth, this.y, this.currentColumn.ToArray()));
73 this.currentColumn.Clear();
74 this.x += this.maxWidth;
76 if (this.y > this.maxHeight)
92 foreach (Tuple<
float,
float,
Padding[]> Row
in this.columns)
94 foreach (
Padding P
in Row.Item3)
99 P.OffsetX -= Element.Left ?? 0;
100 P.OffsetY -= Element.Top ?? 0;
121 foreach (Tuple<
float,
float,
Padding[]> Column
in this.columns)
123 foreach (
Padding P
in Column.Item3)
124 P.
Distribute(Column.Item1,
null,
this.session, SetPosition);
134 List<Padding> Result =
new List<Padding>();
135 float X = this.horizontalDirection == HorizontalDirection.LeftRight ? 0 : this.x;
139 foreach (Tuple<
float,
float,
Padding[]> Column
in this.columns)
141 Diff = this.maxHeight - Column.Item2;
142 switch (this.verticalAlignment)
149 Y = this.maxHeight - Diff;
156 Y = this.maxHeight - Diff / 2;
171 foreach (
Padding P
in Column.Item3)
173 float Height = P.Element.Height ?? 0;
190 return Result.ToArray();
Lays out elements flexibly, first vertically, then horizontally.
Padding[] Align()
Aligns cells and returns an array of padded cells.
float TotWidth
Total width of layout
FlexibleVerticalCells(Variables Session, float WidthLimit, HorizontalDirection HorizontalDirection, VerticalDirection VerticalDirection, VerticalAlignment VerticalAlignment)
Lays out elements flexibly, first vertically, then horizontally.
float TotHeight
Total height of layout
void Distribute(bool SetPosition)
Distributes cells in layout.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
void Flush()
Flushes any waiting elements int he layout pipeline.
Task Add(ILayoutElement Element)
Adds a cell to the layout.
Provides padding for a layout element in a group contruct.
Task Distribute(float? MaxWidth, float? MaxHeight, Variables Session, bool SetPosition)
Aligns a measured cell
ILayoutElement Element
Embedded element
Basic interface for cell layout objects.
Base interface for all layout elements.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
HorizontalDirection
Horizontal ordering
VerticalDirection
Vertical ordering
VerticalAlignment
Vertical alignment