using System;

namespace CrossCutting
{
    public struct PointF
    {
        public PointF(float x, float y)
        {
            X = x;
            Y = y;
        }

        public float X;
        public float Y;


        public static bool operator ==(PointF point1, PointF point2)
        {
            return point1.X == point2.X && point1.Y == point2.Y;
        }

        public static implicit operator PointF(System.Drawing.PointF source)
        {
            return new PointF(source.X, source.Y);
        }

        public static implicit operator System.Drawing.PointF(PointF source)
        {
            return new System.Drawing.PointF(source.X, source.Y);
        }

        public static bool operator !=(PointF line1, PointF line2)
        {
            return !(line1 == line2);
        }

        public float DistanceTo(PointF start)
        {
            return (float)Math.Sqrt((X - start.X) * (X - start.X) + (Y - start.Y) * (Y - start.Y));
        }

        public override string ToString()
        {
            return $"({X}, {Y})";
        }

        public override bool Equals(object obj)
        {
            if (!(obj is PointF))
            {
                return false;
            }

            var f = (PointF)obj;
            return X == f.X &&
                   Y == f.Y;
        }

        public override int GetHashCode()
        {
            var hashCode = 1861411795;
            hashCode = hashCode * -1521134295 + base.GetHashCode();
            hashCode = hashCode * -1521134295 + X.GetHashCode();
            hashCode = hashCode * -1521134295 + Y.GetHashCode();
            return hashCode;
        }
    }
}
