Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Rotate.cs
1using System.Threading.Tasks;
2using System.Xml;
3using SkiaSharp;
5
7{
12 {
13 private FloatAttribute degrees;
14
20 public Rotate(Layout2DDocument Document, ILayoutElement Parent)
21 : base(Document, Parent)
22 {
23 }
24
28 public override string LocalName => "Rotate";
29
34 {
35 get => this.degrees;
36 set => this.degrees = value;
37 }
38
43 public override Task FromXml(XmlElement Input)
44 {
45 this.degrees = new FloatAttribute(Input, "degrees", this.Document);
46 return base.FromXml(Input);
47 }
48
53 public override void ExportAttributes(XmlWriter Output)
54 {
55 base.ExportAttributes(Output);
56
57 this.degrees?.Export(Output);
58 }
59
66 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
67 {
68 return new Rotate(Document, Parent);
69 }
70
75 public override void CopyContents(ILayoutElement Destination)
76 {
77 base.CopyContents(Destination);
78
79 if (Destination is Rotate Dest)
80 Dest.degrees = this.degrees?.CopyIfNotPreset(Destination.Document);
81 }
82
87 public override async Task AfterMeasureDimensions(DrawingState State)
88 {
89 await base.AfterMeasureDimensions(State);
90
91 this.angle = await this.degrees.Evaluate(State.Session, 0);
92
93 SKMatrix M = SKMatrix.CreateRotationDegrees(this.angle, this.xCoordinate, this.yCoordinate);
95 }
96
97 private float angle;
98
103 public override async Task Draw(DrawingState State)
104 {
105 SKMatrix M = State.Canvas.TotalMatrix;
106 State.Canvas.RotateDegrees(this.angle, this.xCoordinate, this.yCoordinate);
107
108 await base.Draw(State);
109
110 State.Canvas.SetMatrix(M);
111 }
112
117 public override void ExportStateAttributes(XmlWriter Output)
118 {
119 base.ExportStateAttributes(Output);
120
121 this.degrees?.ExportState(Output);
122 }
123 }
124}
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
FloatAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
SKCanvas Canvas
Current drawing canvas.
Variables Session
Current session.
Definition: DrawingState.cs:91
Layout2DDocument Document
Layout document.
void TransformBoundingBox(SKMatrix M)
Transforms the measured bounding box.
Base abstract class for transformations using an optional pivot point.
override string LocalName
Local name of type of element.
Definition: Rotate.cs:28
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
Definition: Rotate.cs:117
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: Rotate.cs:43
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
Definition: Rotate.cs:53
FloatAttribute DegreesAttribute
Degrees
Definition: Rotate.cs:34
Rotate(Layout2DDocument Document, ILayoutElement Parent)
A rotation transform
Definition: Rotate.cs:20
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: Rotate.cs:66
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: Rotate.cs:75
override async Task AfterMeasureDimensions(DrawingState State)
Called when dimensions have been measured.
Definition: Rotate.cs:87
override async Task Draw(DrawingState State)
Draws layout entities.
Definition: Rotate.cs:103
Base interface for all layout elements.
Layout2DDocument Document
Layout document.