Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OneCoordinate.cs
1using System;
2using SkiaSharp;
3using System.Xml;
4using System.Threading.Tasks;
5
7{
11 public abstract class OneCoordinate : CanvasOperation
12 {
13 private float x;
14 private float y;
15
20 {
21 }
22
28 public OneCoordinate(float X, float Y)
29 {
30 this.x = X;
31 this.y = Y;
32 }
33
37 public float X => this.x;
38
42 public float Y => this.y;
43
45 public override bool Equals(object obj)
46 {
47 return (obj is OneCoordinate Obj &&
48 this.x == Obj.x &&
49 this.y == Obj.y);
50 }
51
53 public override int GetHashCode()
54 {
55 int Result = this.x.GetHashCode();
56 Result ^= Result << 5 ^ this.y.GetHashCode();
57 return Result;
58 }
59
61 public override void ExportGraph(XmlWriter Output)
62 {
63 Output.WriteAttributeString("x", Expression.ToString(this.x));
64 Output.WriteAttributeString("y", Expression.ToString(this.y));
65 }
66
68 public override Task ImportGraph(XmlElement Xml, Variables _)
69 {
70 foreach (XmlAttribute Attr in Xml.Attributes)
71 {
72 switch (Attr.Name)
73 {
74 case "x":
75 if (Expression.TryParse(Attr.Value, out float Value))
76 this.x = Value;
77 break;
78
79 case "y":
80 if (Expression.TryParse(Attr.Value, out Value))
81 this.y = Value;
82 break;
83 }
84 }
85
86 return Task.CompletedTask;
87 }
88 }
89}
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 canvas operations.
Abstract base class for operations using one coordinate
override void ExportGraph(XmlWriter Output)
Exports graph specifics to XML.
override Task ImportGraph(XmlElement Xml, Variables _)
Imports graph specifics from XML.
OneCoordinate()
Abstract base class for operations using one coordinate
OneCoordinate(float X, float Y)
Abstract base class for operations using one coordinate
Collection of variables.
Definition: Variables.cs:25