|
|
|
|
|
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 SizeD
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly SizeD Empty;
|
|
|
|
|
|
|
|
|
|
|
|
private double width;
|
|
|
|
|
|
|
|
|
|
|
|
private double height;
|
|
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public bool IsEmpty
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (width == 0f)
|
|
|
|
|
|
{
|
|
|
|
|
|
return height == 0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double Width
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return width;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
width = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double Height
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
height = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SizeD(SizeD size)
|
|
|
|
|
|
{
|
|
|
|
|
|
width = size.width;
|
|
|
|
|
|
height = size.height;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SizeD(PointD pt)
|
|
|
|
|
|
{
|
|
|
|
|
|
width = pt.X;
|
|
|
|
|
|
height = pt.Y;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SizeD(double width, double height)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.width = width;
|
|
|
|
|
|
this.height = height;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SizeD operator +(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Add(sz1, sz2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SizeD operator -(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Subtract(sz1, sz2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sz1.Width == sz2.Width)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sz1.Height == sz2.Height;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool operator !=(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return !(sz1 == sz2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static explicit operator PointD(SizeD size)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new PointD(size.Width, size.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SizeD Add(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SizeD(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SizeD Subtract(SizeD sz1, SizeD sz2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SizeD(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!(obj is SizeD))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
SizeD sizeF = (SizeD)obj;
|
|
|
|
|
|
if (sizeF.Width == Width && sizeF.Height == Height)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sizeF.GetType().Equals(GetType());
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PointD ToPointF()
|
|
|
|
|
|
{
|
|
|
|
|
|
return (PointD)this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//public Size ToSize()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return Size.Truncate(this);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return "{Width=" + width.ToString(CultureInfo.CurrentCulture) + ", Height=" + height.ToString(CultureInfo.CurrentCulture) + "}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|