2 // System.Drawing.PointF.cs
5 // Mike Kestner (mkestner@speakeasy.net)
7 // (C) 2001 Mike Kestner
12 namespace System.Drawing {
14 public struct PointF {
16 // Private x and y coordinate fields.
19 // -----------------------
20 // Public Shared Members
21 // -----------------------
24 /// Empty Shared Field
28 /// An uninitialized PointF Structure.
31 public static readonly PointF Empty;
38 /// Translates a PointF using the Width and Height
39 /// properties of the given Size.
42 public static PointF operator + (PointF pt, Size sz)
44 return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
52 /// Compares two PointF objects. The return value is
53 /// based on the equivalence of the X and Y properties
54 /// of the two points.
57 public static bool operator == (PointF pt_a, PointF pt_b)
59 return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
63 /// Inequality Operator
67 /// Compares two PointF objects. The return value is
68 /// based on the equivalence of the X and Y properties
69 /// of the two points.
72 public static bool operator != (PointF pt_a, PointF pt_b)
74 return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
78 /// Subtraction Operator
82 /// Translates a PointF using the negation of the Width
83 /// and Height properties of the given Size.
86 public static PointF operator - (PointF pt, Size sz)
88 return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
91 // -----------------------
93 // -----------------------
96 /// PointF Constructor
100 /// Creates a PointF from a specified x,y coordinate pair.
103 public PointF (float x, float y)
109 // -----------------------
110 // Public Instance Members
111 // -----------------------
118 /// Indicates if both X and Y are zero.
121 public bool IsEmpty {
123 return ((cx == 0.0) && (cy == 0.0));
132 /// The X coordinate of the PointF.
149 /// The Y coordinate of the PointF.
166 /// Checks equivalence of this PointF and another object.
169 public override bool Equals (object o)
174 return (this == (PointF) o);
178 /// GetHashCode Method
182 /// Calculates a hashing value.
185 public override int GetHashCode ()
187 return (int) cx ^ (int) cy;
195 /// Formats the PointF as a string in coordinate notation.
198 public override string ToString ()
200 return String.Format ("[{0},{1}]", cx, cy);