32using System.Runtime.InteropServices;
33using System.Xml.Serialization;
43 [StructLayout(LayoutKind.Sequential, Size = Point2D.Size)]
44 [AdvBrowsableOrder(
"X,Y")]
45#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
49 public struct Point2D : IEquatable<Point2D>
61 #region readonly fields
69 #region static methods
80 result.
X = left.
X + right.
X;
81 result.
Y = left.
Y + right.
Y;
86 result.X = left.X + right.X;
87 result.Y = left.Y + right.Y;
99 result.
X = left.
X - right.
X;
100 result.
Y = left.
Y - right.
Y;
105 result.X = left.X - right.X;
106 result.Y = left.Y - right.Y;
118 result.
X = source.
X * scalar;
119 result.
Y = source.
Y * scalar;
124 result.X = source.X * scalar;
125 result.Y = source.Y * scalar;
131 result.
X = scalar * source.
X;
132 result.
Y = scalar * source.
Y;
137 result.X = scalar * source.X;
138 result.Y = scalar * source.Y;
149 result.
X = -source.
X;
150 result.
Y = -source.
Y;
155 Negate(ref source, out source);
159 result.X = -source.X;
160 result.Y = -source.Y;
166 Max(ref value1, ref value2, out result);
171 result.X = (value1.X < value2.X) ? (value2.X) : (value1.X);
172 result.Y = (value1.Y < value2.Y) ? (value2.Y) : (value1.Y);
178 Min(ref value1, ref value2, out result);
183 result.X = (value1.X > value2.X) ? (value2.X) : (value1.X);
184 result.Y = (value1.Y > value2.Y) ? (value2.Y) : (value1.Y);
195 [
System.ComponentModel.Description(
"The Magnitude on the X-Axis")]
204 [
System.ComponentModel.Description(
"The Magnitude on the Y-Axis")]
214 [InstanceConstructor(
"X,Y")]
232 result.
X = left.
X + right.
X;
233 result.
Y = left.
Y + right.
Y;
246 result.
X = left.
X - right.
X;
247 result.
Y = left.
Y - right.
Y;
260 result.
X = source.
X * scalar;
261 result.
Y = source.
Y * scalar;
274 result.
X = scalar * source.
X;
275 result.
Y = scalar * source.
Y;
286 result.
X = -source.
X;
287 result.
Y = -source.
Y;
299 return left.
X == right.
X && left.
Y == right.
Y;
309 return !(left.
X == right.
X && left.
Y == right.
Y);
335#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
344 if (vals.Length !=
Count)
349 if (
int.
TryParse(vals[0], out result.X) &&
350 int.TryParse(vals[1], out result.Y))
366 throw new ArgumentNullException(
"s");
369 if (vals.Length !=
Count)
374 value.
X =
int.Parse(vals[0]);
375 value.
Y =
int.Parse(vals[1]);
389 return X.GetHashCode() ^
Y.GetHashCode();
403 return Equals(ref
this, ref other);
static string CreateVectorFormatableString(int Count)
static string CreateVectorFormatString(int Count)
static string[] SplitStringVector(string s)
static void ThrowVectorFormatException(string value, int count, string format)
This is the Vector Class.
static Point2D operator*(Point2D source, int scalar)
Does Scaler Multiplication on a Point.
static void Multiply(ref int scalar, ref Point2D source, out Point2D result)
static Point2D Negate(Point2D source)
Negates a Point.
static void Multiply(ref Point2D source, ref int scalar, out Point2D result)
static void Negate(ref Point2D source, out Point2D result)
static Point2D Multiply(Point2D source, int scalar)
Does Scaler Multiplication on a Point.
bool Equals(Point2D other)
static Point2D Add(Point2D left, Point2D right)
Adds 2 Vectors2Ds.
string ToString(string format)
Converts the numeric value of this instance to its equivalent string representation,...
Point2D(int X, int Y)
Creates a New Point Instance on the Stack.
static bool operator==(Point2D left, Point2D right)
Specifies whether the Points contain the same coordinates.
static bool Equals(ref Point2D left, ref Point2D right)
static bool operator!=(Point2D left, Point2D right)
Specifies whether the Points do not contain the same coordinates.
const int Size
The Size of the class in bytes;
static Point2D Min(Point2D value1, Point2D value2)
static void Negate(ref Point2D source)
static void Min(ref Point2D value1, ref Point2D value2, out Point2D result)
static Point2D Parse(string s)
static Point2D operator-(Point2D left, Point2D right)
Subtracts 2 Points.
override bool Equals(object obj)
Compares this Vector to another object. This should be done because the equality operators (==,...
static Point2D Multiply(int scalar, Point2D source)
override int GetHashCode()
Provides a unique hash code based on the member variables of this class. This should be done because ...
override string ToString()
string ToStringInternal(string FormatString)
static Point2D operator+(Point2D left, Point2D right)
Adds 2 Vectors2Ds.
static readonly string FormatString
const int Count
The number of int values in the class.
int Y
This is the Y value. (Usually represents a vertical position or direction.)
static bool TryParse(string s, out Point2D result)
static void Max(ref Point2D value1, ref Point2D value2, out Point2D result)
static Point2D Max(Point2D value1, Point2D value2)
static readonly Point2D Zero
Point(0,0)
int X
This is the X value. (Usually represents a horizontal position or direction.)
static void Add(ref Point2D left, ref Point2D right, out Point2D result)
static readonly string FormatableString
static Point2D Subtract(Point2D left, Point2D right)
Subtracts 2 Points.
static void Subtract(ref Point2D left, ref Point2D right, out Point2D result)
static bool Equals(Point2D left, Point2D right)