Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OverlayCells.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
3using Waher.Script;
4
6{
11 {
12 private readonly List<Padding> measured = new List<Padding>();
13 private readonly Variables session;
14 private float maxWidth = 0;
15 private float maxHeight = 0;
16
21 public OverlayCells(Variables Session)
22 {
23 this.session = Session;
24 }
25
30 public Task Add(ILayoutElement Element)
31 {
32 this.measured.Add(new Padding(Element, 0, 0));
33
34 float Width = Element.Width ?? 0;
35 if (Width > this.maxWidth)
36 this.maxWidth = Width;
37
38 float Height = Element.Height ?? 0;
39 if (Height > this.maxHeight)
40 this.maxHeight = Height;
41
42 return Task.CompletedTask;
43 }
44
48 public void Flush()
49 {
50 }
51
56 public void MeasurePositions(DrawingState State)
57 {
58 ILayoutElement Element;
59
60 foreach (Padding P in this.measured)
61 {
62 Element = P.Element;
63
64 Element.MeasurePositions(State);
65 P.OffsetX -= Element.Left ?? 0;
66 P.OffsetY -= Element.Top ?? 0;
67 }
68 }
69
73 public float TotWidth => this.maxWidth;
74
78 public float TotHeight => this.maxHeight;
79
84 public void Distribute(bool SetPosition)
85 {
86 foreach (Padding P in this.measured)
87 P.Distribute(this.maxWidth, this.maxHeight, this.session, SetPosition);
88 }
89
94 public Padding[] Align()
95 {
96 return this.measured.ToArray();
97 }
98 }
99}
Lays ut cells one on-top of another
Definition: OverlayCells.cs:11
OverlayCells(Variables Session)
Lays ut cells one on-top of another
Definition: OverlayCells.cs:21
Padding[] Align()
Aligns cells and returns an array of padded cells.
Definition: OverlayCells.cs:94
void Distribute(bool SetPosition)
Distributes cells in layout.
Definition: OverlayCells.cs:84
void Flush()
Flushes any waiting elements int he layout pipeline.
Definition: OverlayCells.cs:48
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
Definition: OverlayCells.cs:56
Task Add(ILayoutElement Element)
Adds a cell to the layout.
Definition: OverlayCells.cs:30
Provides padding for a layout element in a group contruct.
Definition: Padding.cs:11
Task Distribute(float? MaxWidth, float? MaxHeight, Variables Session, bool SetPosition)
Aligns a measured cell
Definition: Padding.cs:73
ILayoutElement Element
Embedded element
Definition: Padding.cs:36
Collection of variables.
Definition: Variables.cs:25
Basic interface for cell layout objects.
Definition: ICellLayout.cs:9
Base interface for all layout elements.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.