forked from judero01col/GMap.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGSize.cs
More file actions
107 lines (89 loc) · 2.42 KB
/
Copy pathGSize.cs
File metadata and controls
107 lines (89 loc) · 2.42 KB
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
using System.Globalization;
namespace GMap.NET
{
/// <summary>
/// the size
/// </summary>
public struct GSize
{
public static readonly GSize Empty = new GSize();
public GSize(GPoint pt)
{
Width = pt.X;
Height = pt.Y;
}
public GSize(long width, long height)
{
Width = width;
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;
set;
}
public long Height
{
get;
set;
}
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 == Width &&
comp.Height == Height;
}
public override int GetHashCode()
{
if (IsEmpty)
{
return 0;
}
return Width.GetHashCode() ^ Height.GetHashCode();
}
public override string ToString()
{
return "{Width=" + Width.ToString(CultureInfo.CurrentCulture) + ", Height=" +
Height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}