2 // System.Drawing.PointF.cs
5 // Mike Kestner (mkestner@speakeasy.net)
7 // (C) 2001 Mike Kestner
11 using System.Runtime.InteropServices;
13 namespace System.Drawing {
17 public struct PointF {
19 // Private x and y coordinate fields.
22 // -----------------------
23 // Public Shared Members
24 // -----------------------
27 /// Empty Shared Field
31 /// An uninitialized PointF Structure.
34 public static readonly PointF Empty;
41 /// Translates a PointF using the Width and Height
42 /// properties of the given Size.
45 public static PointF operator + (PointF pt, Size sz)
47 return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
55 /// Compares two PointF objects. The return value is
56 /// based on the equivalence of the X and Y properties
57 /// of the two points.
60 public static bool operator == (PointF pt_a, PointF pt_b)
62 return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
66 /// Inequality Operator
70 /// Compares two PointF objects. The return value is
71 /// based on the equivalence of the X and Y properties
72 /// of the two points.
75 public static bool operator != (PointF pt_a, PointF pt_b)
77 return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
81 /// Subtraction Operator
85 /// Translates a PointF using the negation of the Width
86 /// and Height properties of the given Size.
89 public static PointF operator - (PointF pt, Size sz)
91 return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
94 // -----------------------
96 // -----------------------
99 /// PointF Constructor
103 /// Creates a PointF from a specified x,y coordinate pair.
106 public PointF (float x, float y)
112 // -----------------------
113 // Public Instance Members
114 // -----------------------
121 /// Indicates if both X and Y are zero.
124 public bool IsEmpty {
126 return ((cx == 0.0) && (cy == 0.0));
135 /// The X coordinate of the PointF.
152 /// The Y coordinate of the PointF.
169 /// Checks equivalence of this PointF and another object.
172 public override bool Equals (object o)
177 return (this == (PointF) o);
181 /// GetHashCode Method
185 /// Calculates a hashing value.
188 public override int GetHashCode ()
190 return (int) cx ^ (int) cy;
198 /// Formats the PointF as a string in coordinate notation.
201 public override string ToString ()
203 return String.Format ("[{0},{1}]", cx, cy);