Implement more IStringEncodable

This commit is contained in:
Yoshi Askharoun
2024-02-19 13:10:24 -06:00
parent b0d5209f07
commit 3050703ab1
5 changed files with 18 additions and 5 deletions
+3 -1
View File
@@ -9,7 +9,7 @@ using System;
namespace Microsoft.Iris.Render
{
[Serializable]
public struct Point
public struct Point : IStringEncodable
{
private int m_x;
private int m_y;
@@ -84,5 +84,7 @@ namespace Microsoft.Iris.Render
public Size ToSize() => new Size(this.X, this.Y);
public static Point Negate(Point point) => new Point(-point.X, -point.Y);
public string EncodeString() => $"{X}, {Y}";
}
}
@@ -11,7 +11,7 @@ using System.Text;
namespace Microsoft.Iris.Render
{
[Serializable]
public struct Vector2
public struct Vector2 : IStringEncodable
{
private float m_x;
private float m_y;
@@ -107,5 +107,7 @@ namespace Microsoft.Iris.Render
}
public bool IsApproximate(Vector2 vector) => Math2.WithinEpsilon(this.m_x, vector.m_x) && Math2.WithinEpsilon(this.m_y, vector.m_y);
public string EncodeString() => $"{X}, {Y}";
}
}
@@ -11,7 +11,7 @@ using System.Text;
namespace Microsoft.Iris.Render
{
[Serializable]
public struct Vector3
public struct Vector3 : IStringEncodable
{
private float m_x;
private float m_y;
@@ -130,5 +130,7 @@ namespace Microsoft.Iris.Render
}
public bool IsApproximate(Vector3 vector) => Math2.WithinEpsilon(this.m_x, vector.m_x) && Math2.WithinEpsilon(this.m_y, vector.m_y) && Math2.WithinEpsilon(this.m_z, vector.m_z);
public string EncodeString() => $"{X}, {Y}, {Z}";
}
}
+6 -1
View File
@@ -9,7 +9,7 @@ using System.Text;
namespace Microsoft.Iris.Drawing
{
public struct Rotation
public struct Rotation : IStringEncodable
{
private Vector3 _axis;
private float _angleRad;
@@ -62,5 +62,10 @@ namespace Microsoft.Iris.Drawing
stringBuilder.Append(")");
return stringBuilder.ToString();
}
public string EncodeString()
{
return $"{AngleRadians}rad;{Axis.EncodeString()}";
}
}
}
@@ -9,7 +9,7 @@ using Microsoft.Iris.Library;
namespace Microsoft.Iris.Layouts
{
internal class DockLayoutInput : ILayoutInput
internal class DockLayoutInput : ILayoutInput, IStringEncodable
{
public static readonly DockLayoutInput Left = new DockLayoutInput();
public static readonly DockLayoutInput Top = new DockLayoutInput();
@@ -40,5 +40,7 @@ namespace Microsoft.Iris.Layouts
}
public override string ToString() => InvariantString.Format("{0}(Position={1})", GetType().Name, PositionString);
public string EncodeString() => PositionString;
}
}