Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Angle.cs
1using System.Threading.Tasks;
2using System.Xml;
4
6{
10 public abstract class Angle : LayoutElement
11 {
12 private FloatAttribute degrees;
13
19 public Angle(Layout2DDocument Document, ILayoutElement Parent)
20 : base(Document, Parent)
21 {
22 }
23
28 {
29 get => this.degrees;
30 set => this.degrees = value;
31 }
32
37 public override Task FromXml(XmlElement Input)
38 {
39 this.degrees = new FloatAttribute(Input, "degrees", this.Document);
40 return base.FromXml(Input);
41 }
42
47 public override void ExportAttributes(XmlWriter Output)
48 {
49 base.ExportAttributes(Output);
50
51 this.degrees?.Export(Output);
52 }
53
58 public override void CopyContents(ILayoutElement Destination)
59 {
60 base.CopyContents(Destination);
61
62 if (Destination is Angle Dest)
63 Dest.degrees = this.degrees?.CopyIfNotPreset(Destination.Document);
64 }
65
71 public override async Task DoMeasureDimensions(DrawingState State)
72 {
73 await base.DoMeasureDimensions(State);
74
75 EvaluationResult<float> Degrees = await this.degrees.TryEvaluate(State.Session);
76 this.angle = Degrees.Result;
77 this.defined &= Degrees.Ok;
78 }
79
83 protected float angle;
84
89 public override void ExportStateAttributes(XmlWriter Output)
90 {
91 base.ExportStateAttributes(Output);
92
93 this.degrees?.ExportState(Output);
94 }
95
96 }
97}
Contains a 2D layout document.
Abstract base class for angle elements.
Definition: Angle.cs:11
FloatAttribute DegreesAttribute
Degrees
Definition: Angle.cs:28
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
Definition: Angle.cs:47
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: Angle.cs:58
Angle(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class for distance elements.
Definition: Angle.cs:19
float angle
Measured distance
Definition: Angle.cs:83
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
Definition: Angle.cs:89
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: Angle.cs:37
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
Definition: Angle.cs:71
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
Abstract base class for layout elements.
Layout2DDocument Document
Layout document.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.