This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathPoint.custom
94 lines (81 loc) · 2.09 KB
/
Point.custom
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
// Gdk.Point.custom - Gdk Point class customizations
//
// Authors:
// Jasper van Putten <[email protected]>
// Martin Willemoes Hansen <[email protected]>
// Ben Maurer <[email protected]>
// Contains lots of c&p from System.Drawing
//
// Copyright (c) 2002 Jasper van Putten
// Copyright (c) 2003 Martin Willemoes Hansen
// Copyright (c) 2005 Novell, Inc
//
// This code is inserted after the automatically generated code.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
public override string ToString ()
{
return String.Format ("({0},{1})", X, Y);
}
public Point (int x, int y)
{
this.X = x;
this.Y = y;
}
public Point (Size sz)
{
this.X = sz.Width;
this.Y = sz.Height;
}
public override bool Equals (object o)
{
if (!(o is Point))
return false;
return (this == (Point) o);
}
public override int GetHashCode ()
{
return X ^ Y;
}
public void Offset (int dx, int dy)
{
X += dx;
Y += dy;
}
public bool IsEmpty {
get {
return ((X == 0) && (Y == 0));
}
}
public static explicit operator Size (Point pt)
{
return new Size (pt.X, pt.Y);
}
public static Point operator + (Point pt, Size sz)
{
return new Point (pt.X + sz.Width, pt.Y + sz.Height);
}
public static Point operator - (Point pt, Size sz)
{
return new Point (pt.X - sz.Width, pt.Y - sz.Height);
}
public static bool operator == (Point pt_a, Point pt_b)
{
return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
}
public static bool operator != (Point pt_a, Point pt_b)
{
return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
}