Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Point2Weight.cs
1using System.Threading.Tasks;
2using System.Xml;
4
6{
10 public abstract class Point2Weight : Point2
11 {
12 private FloatAttribute w;
13
20 : base(Document, Parent)
21 {
22 }
23
28 {
29 get => this.w;
30 set => this.w = value;
31 }
32
37 public override Task FromXml(XmlElement Input)
38 {
39 this.w = new FloatAttribute(Input, "w", this.Document);
40 return base.FromXml(Input);
41 }
42
47 public override void ExportAttributes(XmlWriter Output)
48 {
49 base.ExportAttributes(Output);
50
51 this.w?.Export(Output);
52 }
53
58 public override void CopyContents(ILayoutElement Destination)
59 {
60 base.CopyContents(Destination);
61
62 if (Destination is Point2Weight Dest)
63 Dest.w = this.w?.CopyIfNotPreset(Destination.Document);
64 }
65
71 public override async Task DoMeasureDimensions(DrawingState State)
72 {
73 await base.DoMeasureDimensions(State);
74
75 EvaluationResult<float> Weight = await this.w.TryEvaluate(State.Session);
76 if (Weight.Ok)
77 this.weight = Weight.Result;
78 else
79 this.defined = false;
80 }
81
85 protected float weight;
86
91 public override void ExportStateAttributes(XmlWriter Output)
92 {
93 base.ExportStateAttributes(Output);
94
95 this.w?.ExportState(Output);
96 }
97
98 }
99}
Contains a 2D layout document.
void Export(XmlWriter Output)
Exports the attribute.
Definition: Attribute.cs:187
void ExportState(XmlWriter Output)
Exports the state of the attribute.
Definition: Attribute.cs:199
static async Task< EvaluationResult< T > > TryEvaluate(Attribute< T > Attribute, Variables Session)
Tries to evaluate the attribute value.
Definition: Attribute.cs:256
FloatAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Variables Session
Current session.
Definition: DrawingState.cs:91
Layout2DDocument Document
Layout document.
Abstract base class for layout elements with two points.
Definition: Point2.cs:11
Abstract base class for layout elements with two points and a weight.
Definition: Point2Weight.cs:11
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
Definition: Point2Weight.cs:71
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: Point2Weight.cs:58
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
Definition: Point2Weight.cs:47
Point2Weight(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class for layout elements with two points and a weight.
Definition: Point2Weight.cs:19
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
Definition: Point2Weight.cs:91
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: Point2Weight.cs:37
Base interface for all layout elements.
Layout2DDocument Document
Layout document.