XAML-Map-Control/MapControl/WinUI/Point.WinUI.cs

77 lines
1.9 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2022-01-14 20:22:56 +01:00
// © 2022 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
namespace MapControl
{
2019-10-25 19:56:23 +02:00
/// <summary>
/// Replaces Windows.Foundation.Point to achieve necessary floating point precision.
/// </summary>
public struct Point
{
public Point(double x, double y)
{
X = x;
Y = y;
}
2022-12-01 23:01:06 +01:00
public double X { get; set; }
public double Y { get; set; }
2018-03-07 22:19:16 +01:00
public static implicit operator Windows.Foundation.Point(Point p)
{
return new Windows.Foundation.Point(p.X, p.Y);
}
public static implicit operator Point(Windows.Foundation.Point p)
{
return new Point(p.X, p.Y);
}
2018-03-07 22:19:16 +01:00
public static explicit operator Point(Vector v)
{
2018-03-07 22:19:16 +01:00
return new Point(v.X, v.Y);
}
public static Point operator -(Point p)
{
return new Point(-p.X, -p.Y);
}
public static Point operator +(Point p, Vector v)
{
return new Point(p.X + v.X, p.Y + v.Y);
}
public static Point operator -(Point p, Vector v)
{
return new Point(p.X - v.X, p.Y - v.Y);
}
public static Vector operator -(Point p1, Point p2)
{
return new Vector(p1.X - p2.X, p1.Y - p2.Y);
}
public static bool operator ==(Point p1, Point p2)
{
return p1.X == p2.X && p1.Y == p2.Y;
}
public static bool operator !=(Point p1, Point p2)
{
return !(p1 == p2);
}
public override bool Equals(object o)
{
return o is Point && this == (Point)o;
}
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode();
}
}
}