Files
@ 65c134a3d619
Branch filter:
Location: seniordesign-ui/GMap.NET.Core/GMap.NET/GSize.cs
65c134a3d619
2.6 KiB
text/x-csharp
Initial import of mapping source (huge commit)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
namespace GMap.NET
{
using System.Globalization;
/// <summary>
/// the size
/// </summary>
public struct GSize
{
public static readonly GSize Empty = new GSize();
private long width;
private long height;
public GSize(GPoint pt)
{
width = pt.X;
height = pt.Y;
}
public GSize(long width, long height)
{
this.width = width;
this.height = height;
}
public static GSize operator +(GSize sz1, GSize sz2)
{
return Add(sz1, sz2);
}
public static GSize operator -(GSize sz1, GSize sz2)
{
return Subtract(sz1, sz2);
}
public static bool operator ==(GSize sz1, GSize sz2)
{
return sz1.Width == sz2.Width && sz1.Height == sz2.Height;
}
public static bool operator !=(GSize sz1, GSize sz2)
{
return !(sz1 == sz2);
}
public static explicit operator GPoint(GSize size)
{
return new GPoint(size.Width, size.Height);
}
public bool IsEmpty
{
get
{
return width == 0 && height == 0;
}
}
public long Width
{
get
{
return width;
}
set
{
width = value;
}
}
public long Height
{
get
{
return height;
}
set
{
height = value;
}
}
public static GSize Add(GSize sz1, GSize sz2)
{
return new GSize(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
}
public static GSize Subtract(GSize sz1, GSize sz2)
{
return new GSize(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
}
public override bool Equals(object obj)
{
if(!(obj is GSize))
return false;
GSize comp = (GSize)obj;
// Note value types can't have derived classes, so we don't need to
//
return (comp.width == this.width) &&
(comp.height == this.height);
}
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (Width.GetHashCode() ^ Height.GetHashCode());
}
public override string ToString()
{
return "{Width=" + width.ToString(CultureInfo.CurrentCulture) + ", Height=" + height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}
|