Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HorizontalCells.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 x = 0;
15 private float maxHeight = 0;
16
21 public HorizontalCells(Variables Session)
22 {
23 this.session = Session;
24 }
25
30 public Task Add(ILayoutElement Element)
31 {
32 this.measured.Add(new Padding(Element, this.x, 0));
33 this.x += Element.Width ?? 0;
34
35 float Height = Element.Height ?? 0;
36 if (Height > this.maxHeight)
37 this.maxHeight = Height;
38
39 return Task.CompletedTask;
40 }
41
45 public void Flush()
46 {
47 }
48
53 public void MeasurePositions(DrawingState State)
54 {
55 ILayoutElement Element;
56
57 foreach (Padding P in this.measured)
58 {
59 Element = P.Element;
60
61 Element.MeasurePositions(State);
62 P.OffsetX -= Element.Left ?? 0;
63 P.OffsetY -= Element.Top ?? 0;
64 }
65 }
66
70 public float TotWidth => this.x;
71
75 public float TotHeight => this.maxHeight;
76
81 public void Distribute(bool SetPosition)
82 {
83 foreach (Padding P in this.measured)
84 P.Distribute(null, this.maxHeight, this.session, SetPosition);
85 }
86
91 public Padding[] Align()
92 {
93 return this.measured.ToArray();
94 }
95 }
96}
void Distribute(bool SetPosition)
Distributes cells in layout.
HorizontalCells(Variables Session)
Lays ut cells horizontally
Task Add(ILayoutElement Element)
Adds a cell to the 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.
Padding[] Align()
Aligns cells and returns an array of padded cells.
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.