Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Padding.cs
1using System.Text;
2using System.Threading.Tasks;
3using Waher.Script;
4
6{
10 public class Padding
11 {
12 private readonly ILayoutElement element;
13 private readonly Cell cell;
14 private readonly bool isCell;
15 private float offsetX;
16 private float offsetY;
17
24 public Padding(ILayoutElement Element, float OffsetX, float OffsetY)
25 {
26 this.element = Element;
27 this.cell = Element as Cell;
28 this.isCell = !(this.cell is null);
29 this.offsetX = OffsetX;
30 this.offsetY = OffsetY;
31 }
32
36 public ILayoutElement Element => this.element;
37
41 public Cell Cell => this.cell;
42
46 public bool IsCell => this.isCell;
47
51 public float OffsetX
52 {
53 get => this.offsetX;
54 set => this.offsetX = value;
55 }
56
60 public float OffsetY
61 {
62 get => this.offsetY;
63 set => this.offsetY = value;
64 }
65
73 public Task Distribute(float? MaxWidth, float? MaxHeight, Variables Session, bool SetPosition)
74 {
75 if (this.isCell)
76 return this.cell.Distribute(MaxWidth, MaxHeight, Session, SetPosition);
77 else
78 return Task.CompletedTask;
79 }
80
82 public override string ToString()
83 {
84 StringBuilder sb = new StringBuilder();
85
86 sb.Append('(');
87 sb.Append(this.offsetX.ToString());
88 sb.Append(", ");
89 sb.Append(this.offsetY.ToString());
90 sb.Append("): ");
91 sb.Append(this.element?.ToString() ?? "null");
92
93 return sb.ToString();
94 }
95 }
96}
Defines a cell in a grid.
Definition: Cell.cs:61
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
Padding(ILayoutElement Element, float OffsetX, float OffsetY)
Provides padding for a cell in a group contruct.
Definition: Padding.cs:24
bool IsCell
If the embedded element is a Cell.
Definition: Padding.cs:46
Collection of variables.
Definition: Variables.cs:25
Base interface for all layout elements.