Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Forward.cs
1using System.Threading.Tasks;
2using SkiaSharp;
3
5{
11 {
18 public Forward(Layout2DDocument Document, ILayoutElement Parent)
19 : base(Document, Parent)
20 {
21 }
22
26 public override string LocalName => "Forward";
27
34 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
35 {
36 return new Forward(Document, Parent);
37 }
38
45 {
46 if (this.defined)
48
49 return Task.CompletedTask;
50 }
51
58 public virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
59 {
60 if (this.defined)
61 {
62 this.P1 = Path.LastPoint;
63 Path.LineTo(this.P2 = PathState.Forward(this.dist));
64 }
65
66 return Task.CompletedTask;
67 }
68
72 protected SKPoint P1;
73
77 protected SKPoint P2;
78
86 public bool TryGetStart(out float X, out float Y, out float Direction)
87 {
88 X = this.P1.X;
89 Y = this.P1.Y;
90 Direction = CalcDirection(this.P1, this.P2);
91
92 return this.defined;
93 }
94
102 public bool TryGetEnd(out float X, out float Y, out float Direction)
103 {
104 X = this.P2.X;
105 Y = this.P2.Y;
106 Direction = CalcDirection(this.P1, this.P2);
107
108 return this.defined;
109 }
110 }
111}
Contains a 2D layout document.
Abstract base class for distance elements.
Definition: Distance.cs:11
float dist
Measured distance
Definition: Distance.cs:85
Draws a line to a point that lies a certain distance forward of the last point, in the current direct...
Definition: Forward.cs:11
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: Forward.cs:34
override string LocalName
Local name of type of element.
Definition: Forward.cs:26
virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
Draws layout entities.
Definition: Forward.cs:58
bool TryGetStart(out float X, out float Y, out float Direction)
Tries to get start position and initial direction.
Definition: Forward.cs:86
SKPoint P1
Line drawn from this point
Definition: Forward.cs:72
Task Measure(DrawingState State, PathState PathState)
Measures layout entities and defines unassigned properties.
Definition: Forward.cs:44
Forward(Layout2DDocument Document, ILayoutElement Parent)
Draws a line to a point that lies a certain distance forward of the last point, in the current direct...
Definition: Forward.cs:18
bool TryGetEnd(out float X, out float Y, out float Direction)
Tries to get end position and terminating direction.
Definition: Forward.cs:102
SKPoint Forward(float Distance)
Moves forward
Definition: PathState.cs:200
bool defined
If element is well-defined.
static float CalcDirection(float x1, float y1, float x2, float y2)
Calculates the direction of the pen when drawing from (x1,y1) to (x2,y2).
Interface for directed elements.
Base interface for all layout elements.