using MS.Internal; using System; using System.ComponentModel; using System.Runtime; namespace System.Windows { /// Represents an x- and y-coordinate pair in two-dimensional space. [Serializable] public struct Point : IFormattable { internal double _x; internal double _y; /// Gets or sets the -coordinate value of this structure. /// The -coordinate value of this structure. The default value is 0. public double X { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get { return this._x; } [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set { this._x = value; } } /// Gets or sets the -coordinate value of this . /// The -coordinate value of this structure. The default value is 0. public double Y { [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get { return this._y; } [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set { this._y = value; } } /// Compares two structures for equality. /// true if both the and coordinates of and are equal; otherwise, false. /// The first structure to compare. /// The second structure to compare. public static bool operator ==(Point point1, Point point2) { return point1.X == point2.X && point1.Y == point2.Y; } /// Compares two structures for inequality. /// true if and have different or coordinates; false if and have the same and coordinates. /// The first point to compare. /// The second point to compare. public static bool operator !=(Point point1, Point point2) { return !(point1 == point2); } /// Compares two structures for equality. /// true if and contain the same and values; otherwise, false. /// The first point to compare. /// The second point to compare. public static bool Equals(Point point1, Point point2) { return point1.X.Equals(point2.X) && point1.Y.Equals(point2.Y); } /// Determines whether the specified is a and whether it contains the same coordinates as this . /// true if is a and contains the same and values as this ; otherwise, false. /// The to compare. public override bool Equals(object o) { if (o == null || !(o is Point)) { return false; } Point point = (Point)o; return Point.Equals(this, point); } /// Compares two structures for equality. /// true if both structures contain the same and values; otherwise, false. /// The point to compare to this instance. public bool Equals(Point value) { return Point.Equals(this, value); } /// Returns the hash code for this . /// The hash code for this structure. public override int GetHashCode() { return this.X.GetHashCode() ^ this.Y.GetHashCode(); } /// Constructs a from the specified . /// The equivalent structure. /// A string representation of a point. /// /// is not composed of two comma- or space-delimited double values. /// /// does not contain two numbers.-or- contains too many delimiters. public static Point Parse(string source) { Point result = new Point(); return result; } /// Creates a representation of this . /// A containing the and values of this structure. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public override string ToString() { return this.ConvertToString(null, null); } /// Creates a representation of this . /// A containing the and values of this structure. /// Culture-specific formatting information. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public string ToString(IFormatProvider provider) { return this.ConvertToString(null, provider); } /// This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. For a description of this member, see . /// A string containing the value of the current instance in the specified format. /// The string specifying the format to use. -or- null to use the default format defined for the type of the implementation. /// The IFormatProvider to use to format the value. -or- null to obtain the numeric format information from the current locale setting of the operating system. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] string IFormattable.ToString(string format, IFormatProvider provider) { return this.ConvertToString(format, provider); } internal string ConvertToString(string format, IFormatProvider provider) { return string.Format(provider, string.Concat(new string[] { "{1:", format, "}{0}{2:", format, "}" }), new object[] { ",", this._x, this._y }); } /// Creates a new structure that contains the specified coordinates. /// The x-coordinate of the new structure. /// The y-coordinate of the new structure. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public Point(double x, double y) { this._x = x; this._y = y; } /// Offsets a point's and coordinates by the specified amounts. /// The amount to offset the point's coordinate. /// The amount to offset thepoint's coordinate. public void Offset(double offsetX, double offsetY) { this._x += offsetX; this._y += offsetY; } } }