Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TwoCoordinates.cs
1using System;
2using SkiaSharp;
3using System.Xml;
4using System.Threading.Tasks;
5
7{
11 public abstract class TwoCoordinates : OneCoordinate
12 {
13 private float x2;
14 private float y2;
15
20 : base()
21 {
22 }
23
31 public TwoCoordinates(float X1, float Y1, float X2, float Y2)
32 : base(X1, Y1)
33 {
34 this.x2 = X2;
35 this.y2 = Y2;
36 }
37
41 public float X2 => this.x2;
42
46 public float Y2 => this.y2;
47
51 public float Width => this.x2 - this.X;
52
56 public float Height => this.y2 - this.Y;
57
59 public override bool Equals(object obj)
60 {
61 return (obj is TwoCoordinates Obj &&
62 this.x2 == Obj.x2 &&
63 this.y2 == Obj.y2 &&
64 base.Equals(Obj));
65 }
66
68 public override int GetHashCode()
69 {
70 int Result = this.x2.GetHashCode();
71 Result ^= Result << 5 ^ this.y2.GetHashCode();
72 Result ^= Result << 5 ^ base.GetHashCode();
73 return Result;
74 }
75
77 public override void ExportGraph(XmlWriter Output)
78 {
79 Output.WriteAttributeString("x2", Expression.ToString(this.x2));
80 Output.WriteAttributeString("y2", Expression.ToString(this.y2));
81 base.ExportGraph(Output);
82 }
83
85 public override Task ImportGraph(XmlElement Xml, Variables _)
86 {
87 foreach (XmlAttribute Attr in Xml.Attributes)
88 {
89 switch (Attr.Name)
90 {
91 case "x2":
92 if (Expression.TryParse(Attr.Value, out float Value))
93 this.x2 = Value;
94 break;
95
96 case "y2":
97 if (Expression.TryParse(Attr.Value, out Value))
98 this.y2 = Value;
99 break;
100 }
101 }
102
103 return Task.CompletedTask;
104 }
105 }
106}
Class managing a script expression.
Definition: Expression.cs:39
static bool TryParse(string s, out double Value)
Tries to parse a double-precision floating-point value.
Definition: Expression.cs:4517
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496
Abstract base class for operations using one coordinate
Abstract base class for operations using two coordinates
TwoCoordinates(float X1, float Y1, float X2, float Y2)
Abstract base class for operations using two coordinates
override Task ImportGraph(XmlElement Xml, Variables _)
Imports graph specifics from XML.
override void ExportGraph(XmlWriter Output)
Exports graph specifics to XML.
TwoCoordinates()
Abstract base class for operations using two coordinates
Collection of variables.
Definition: Variables.cs:25