|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeoSigmaDrawLib
|
|
|
|
|
|
{
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
[ComVisible(true)]
|
|
|
|
|
|
public struct PointD
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly PointD Empty;
|
|
|
|
|
|
|
|
|
|
|
|
private double x;
|
|
|
|
|
|
|
|
|
|
|
|
private double y;
|
|
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public bool IsEmpty
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (x == 0f)
|
|
|
|
|
|
{
|
|
|
|
|
|
return y == 0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double X
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return x;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
x = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double Y
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return y;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
y = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PointD(double x, double y)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.x = x;
|
|
|
|
|
|
this.y = y;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//public static PointD operator +(PointD pt, Size sz)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return Add(pt, sz);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//public static PointD operator -(PointD pt, Size sz)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return Subtract(pt, sz);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public static PointD operator +(PointD pt, SizeD sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Add(pt, sz);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static PointD operator -(PointD pt, SizeD sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Subtract(pt, sz);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(PointD left, PointD right)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (left.X == right.X)
|
|
|
|
|
|
{
|
|
|
|
|
|
return left.Y == right.Y;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator !=(PointD left, PointD right)
|
|
|
|
|
|
{
|
|
|
|
|
|
return !(left == right);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//public static PointD Add(PointD pt, SizeD sz)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return new PointD(pt.X + (double)sz.Width, pt.Y + (double)sz.Height);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//public static PointD Subtract(PointD pt, SizeD sz)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return new PointD(pt.X - (double)sz.Width, pt.Y - (double)sz.Height);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public static PointD Add(PointD pt, SizeD sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new PointD(pt.X + sz.Width, pt.Y + sz.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static PointD Subtract(PointD pt, SizeD sz)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new PointD(pt.X - sz.Width, pt.Y - sz.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!(obj is PointD))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
PointD pointD = (PointD)obj;
|
|
|
|
|
|
if (pointD.X == X && pointD.Y == Y)
|
|
|
|
|
|
{
|
|
|
|
|
|
return pointD.GetType().Equals(GetType());
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format(CultureInfo.CurrentCulture, "{{X={0}, Y={1}}}", new object[2] { x, y });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|