Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PivotTrasformation.cs
1using System.Threading.Tasks;
2using System.Xml;
4
6{
11 {
12 private LengthAttribute x;
13 private LengthAttribute y;
14 private StringAttribute @ref;
15
22 : base(Document, Parent)
23 {
24 }
25
30 {
31 get => this.x;
32 set => this.x = value;
33 }
34
39 {
40 get => this.y;
41 set => this.y = value;
42 }
43
48 {
49 get => this.@ref;
50 set => this.@ref = value;
51 }
52
57 public override Task FromXml(XmlElement Input)
58 {
59 this.x = new LengthAttribute(Input, "x", this.Document);
60 this.y = new LengthAttribute(Input, "y", this.Document);
61 this.@ref = new StringAttribute(Input, "ref", this.Document);
62
63 return base.FromXml(Input);
64 }
65
70 public override void ExportAttributes(XmlWriter Output)
71 {
72 base.ExportAttributes(Output);
73
74 this.x?.Export(Output);
75 this.y?.Export(Output);
76 this.@ref?.Export(Output);
77 }
78
83 public override void CopyContents(ILayoutElement Destination)
84 {
85 base.CopyContents(Destination);
86
87 if (Destination is PivotTrasformation Dest)
88 {
89 Dest.x = this.x?.CopyIfNotPreset(Destination.Document);
90 Dest.y = this.y?.CopyIfNotPreset(Destination.Document);
91 Dest.@ref = this.@ref?.CopyIfNotPreset(Destination.Document);
92 }
93 }
94
100 public override async Task DoMeasureDimensions(DrawingState State)
101 {
102 await base.DoMeasureDimensions(State);
103
104 CalculatedPoint P = await this.CalcPoint(State, this.x, this.y, this.@ref, this.xCoordinate, this.yCoordinate);
105 if (P.Ok)
106 {
107 this.xCoordinate = P.X;
108 this.yCoordinate = P.Y;
109 }
110 else
111 this.xCoordinate = this.yCoordinate = 0;
112 }
113
117 protected float xCoordinate;
118
122 protected float yCoordinate;
123
128 public override void ExportStateAttributes(XmlWriter Output)
129 {
130 base.ExportStateAttributes(Output);
131
132 this.x?.ExportState(Output);
133 this.y?.ExportState(Output);
134 this.@ref?.ExportState(Output);
135 }
136 }
137}
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
LengthAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
StringAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Layout2DDocument Document
Layout document.
async Task< CalculatedPoint > CalcPoint(DrawingState State, LengthAttribute XAttribute, LengthAttribute YAttribute, StringAttribute RefAttribute, float X, float Y)
Includes a point in the area measurement.
Base abstract class for transformations using an optional pivot point.
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
PivotTrasformation(Layout2DDocument Document, ILayoutElement Parent)
Base abstract class for transformations using an optional pivot point.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.
Represents a calculated point.
bool Ok
If point is successfully evaluated