Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CommonUI / System / Drawing / Point.cs / 1 / Point.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing {
using System.Runtime.Serialization.Formatters;
using System.Diagnostics;
using System;
using System.IO;
using Microsoft.Win32;
using System.ComponentModel;
using System.Drawing.Internal;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
///
///
/// Represents an ordered pair of x and y coordinates that
/// define a point in a two-dimensional plane.
///
[
TypeConverterAttribute(typeof(PointConverter)),
]
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")]
public struct Point {
///
///
/// Creates a new instance of the class
/// with member data left uninitialized.
///
public static readonly Point Empty = new Point();
private int x;
private int y;
///
///
/// Initializes a new instance of the class
/// with the specified coordinates.
///
public Point(int x, int y) {
this.x = x;
this.y = y;
}
///
///
///
/// Initializes a new instance of the class
/// from a .
///
///
public Point(Size sz) {
this.x = sz.Width;
this.y = sz.Height;
}
///
///
/// Initializes a new instance of the Point class using
/// coordinates specified by an integer value.
///
public Point(int dw) {
this.x = (short)LOWORD(dw);
this.y = (short)HIWORD(dw);
}
///
///
///
/// Gets a value indicating whether this is empty.
///
///
[Browsable(false)]
public bool IsEmpty {
get {
return x == 0 && y == 0;
}
}
///
///
/// Gets the x-coordinate of this .
///
public int X {
get {
return x;
}
set {
x = value;
}
}
///
///
///
/// Gets the y-coordinate of this .
///
///
public int Y {
get {
return y;
}
set {
y = value;
}
}
///
///
///
/// Creates a with the coordinates of the specified
///
/// .
///
///
public static implicit operator PointF(Point p) {
return new PointF(p.X, p.Y);
}
///
///
///
/// Creates a with the coordinates of the specified .
///
///
public static explicit operator Size(Point p) {
return new Size(p.X, p.Y);
}
///
///
///
/// Translates a by a given .
///
///
public static Point operator +(Point pt, Size sz) {
return Add(pt, sz);
}
///
///
///
/// Translates a by the negative of a given .
///
///
public static Point operator -(Point pt, Size sz) {
return Subtract(pt, sz);
}
///
///
///
/// Compares two objects. The result specifies
/// whether the values of the and properties of the two
/// objects are equal.
///
///
public static bool operator ==(Point left, Point right) {
return left.X == right.X && left.Y == right.Y;
}
///
///
///
/// Compares two objects. The result specifies whether the values
/// of the or properties of the two
///
/// objects are unequal.
///
///
public static bool operator !=(Point left, Point right) {
return !(left == right);
}
///
///
/// Translates a by a given .
///
///
public static Point Add(Point pt, Size sz) {
return new Point(pt.X + sz.Width, pt.Y + sz.Height);
}
///
///
/// Translates a by the negative of a given .
///
///
public static Point Subtract(Point pt, Size sz) {
return new Point(pt.X - sz.Width, pt.Y - sz.Height);
}
///
///
/// Converts a PointF to a Point by performing a ceiling operation on
/// all the coordinates.
///
public static Point Ceiling(PointF value) {
return new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));
}
///
///
/// Converts a PointF to a Point by performing a truncate operation on
/// all the coordinates.
///
public static Point Truncate(PointF value) {
return new Point((int)value.X, (int)value.Y);
}
///
///
/// Converts a PointF to a Point by performing a round operation on
/// all the coordinates.
///
public static Point Round(PointF value) {
return new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));
}
///
///
///
/// Specifies whether this contains
/// the same coordinates as the specified .
///
///
public override bool Equals(object obj) {
if (!(obj is Point)) return false;
Point comp = (Point)obj;
// Note value types can't have derived classes, so we don't need
// to check the types of the objects here. -- [....], 2/21/2001
return comp.X == this.X && comp.Y == this.Y;
}
///
///
///
/// Returns a hash code.
///
///
public override int GetHashCode() {
return x ^ y;
}
/**
* Offset the current Point object by the given amount
*/
///
///
/// Translates this by the specified amount.
///
public void Offset(int dx, int dy) {
X += dx;
Y += dy;
}
///
///
/// Translates this by the specified amount.
///
public void Offset(Point p) {
Offset(p.X, p.Y);
}
///
///
///
/// Converts this
/// to a human readable
/// string.
///
///
public override string ToString() {
return "{X=" + X.ToString(CultureInfo.CurrentCulture) + ",Y=" + Y.ToString(CultureInfo.CurrentCulture) + "}";
}
private static int HIWORD(int n) {
return(n >> 16) & 0xffff;
}
private static int LOWORD(int n) {
return n & 0xffff;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing {
using System.Runtime.Serialization.Formatters;
using System.Diagnostics;
using System;
using System.IO;
using Microsoft.Win32;
using System.ComponentModel;
using System.Drawing.Internal;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
///
///
/// Represents an ordered pair of x and y coordinates that
/// define a point in a two-dimensional plane.
///
[
TypeConverterAttribute(typeof(PointConverter)),
]
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")]
public struct Point {
///
///
/// Creates a new instance of the class
/// with member data left uninitialized.
///
public static readonly Point Empty = new Point();
private int x;
private int y;
///
///
/// Initializes a new instance of the class
/// with the specified coordinates.
///
public Point(int x, int y) {
this.x = x;
this.y = y;
}
///
///
///
/// Initializes a new instance of the class
/// from a .
///
///
public Point(Size sz) {
this.x = sz.Width;
this.y = sz.Height;
}
///
///
/// Initializes a new instance of the Point class using
/// coordinates specified by an integer value.
///
public Point(int dw) {
this.x = (short)LOWORD(dw);
this.y = (short)HIWORD(dw);
}
///
///
///
/// Gets a value indicating whether this is empty.
///
///
[Browsable(false)]
public bool IsEmpty {
get {
return x == 0 && y == 0;
}
}
///
///
/// Gets the x-coordinate of this .
///
public int X {
get {
return x;
}
set {
x = value;
}
}
///
///
///
/// Gets the y-coordinate of this .
///
///
public int Y {
get {
return y;
}
set {
y = value;
}
}
///
///
///
/// Creates a with the coordinates of the specified
///
/// .
///
///
public static implicit operator PointF(Point p) {
return new PointF(p.X, p.Y);
}
///
///
///
/// Creates a with the coordinates of the specified .
///
///
public static explicit operator Size(Point p) {
return new Size(p.X, p.Y);
}
///
///
///
/// Translates a by a given .
///
///
public static Point operator +(Point pt, Size sz) {
return Add(pt, sz);
}
///
///
///
/// Translates a by the negative of a given .
///
///
public static Point operator -(Point pt, Size sz) {
return Subtract(pt, sz);
}
///
///
///
/// Compares two objects. The result specifies
/// whether the values of the and properties of the two
/// objects are equal.
///
///
public static bool operator ==(Point left, Point right) {
return left.X == right.X && left.Y == right.Y;
}
///
///
///
/// Compares two objects. The result specifies whether the values
/// of the or properties of the two
///
/// objects are unequal.
///
///
public static bool operator !=(Point left, Point right) {
return !(left == right);
}
///
///
/// Translates a by a given .
///
///
public static Point Add(Point pt, Size sz) {
return new Point(pt.X + sz.Width, pt.Y + sz.Height);
}
///
///
/// Translates a by the negative of a given .
///
///
public static Point Subtract(Point pt, Size sz) {
return new Point(pt.X - sz.Width, pt.Y - sz.Height);
}
///
///
/// Converts a PointF to a Point by performing a ceiling operation on
/// all the coordinates.
///
public static Point Ceiling(PointF value) {
return new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));
}
///
///
/// Converts a PointF to a Point by performing a truncate operation on
/// all the coordinates.
///
public static Point Truncate(PointF value) {
return new Point((int)value.X, (int)value.Y);
}
///
///
/// Converts a PointF to a Point by performing a round operation on
/// all the coordinates.
///
public static Point Round(PointF value) {
return new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));
}
///
///
///
/// Specifies whether this contains
/// the same coordinates as the specified .
///
///
public override bool Equals(object obj) {
if (!(obj is Point)) return false;
Point comp = (Point)obj;
// Note value types can't have derived classes, so we don't need
// to check the types of the objects here. -- [....], 2/21/2001
return comp.X == this.X && comp.Y == this.Y;
}
///
///
///
/// Returns a hash code.
///
///
public override int GetHashCode() {
return x ^ y;
}
/**
* Offset the current Point object by the given amount
*/
///
///
/// Translates this by the specified amount.
///
public void Offset(int dx, int dy) {
X += dx;
Y += dy;
}
///
///
/// Translates this by the specified amount.
///
public void Offset(Point p) {
Offset(p.X, p.Y);
}
///
///
///
/// Converts this
/// to a human readable
/// string.
///
///
public override string ToString() {
return "{X=" + X.ToString(CultureInfo.CurrentCulture) + ",Y=" + Y.ToString(CultureInfo.CurrentCulture) + "}";
}
private static int HIWORD(int n) {
return(n >> 16) & 0xffff;
}
private static int LOWORD(int n) {
return n & 0xffff;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NumberAction.cs
- RectangleGeometry.cs
- CodeRegionDirective.cs
- XmlSchemaCollection.cs
- SignedXml.cs
- ConfigXmlElement.cs
- TaskHelper.cs
- ProcessProtocolHandler.cs
- Exceptions.cs
- ContextInformation.cs
- MethodAccessException.cs
- Pointer.cs
- HijriCalendar.cs
- NumericUpDown.cs
- ConfigurationException.cs
- CaseCqlBlock.cs
- SqlHelper.cs
- SettingsPropertyIsReadOnlyException.cs
- HwndHostAutomationPeer.cs
- ApplicationSecurityInfo.cs
- ConfigurationStrings.cs
- _SpnDictionary.cs
- ParameterExpression.cs
- ClusterRegistryConfigurationProvider.cs
- ColorMap.cs
- NoClickablePointException.cs
- Variant.cs
- AddressingProperty.cs
- ClientTargetCollection.cs
- IsolatedStorageFile.cs
- OleDbSchemaGuid.cs
- PathFigureCollection.cs
- TextTreeTextBlock.cs
- LookupBindingPropertiesAttribute.cs
- coordinatorfactory.cs
- _ConnectStream.cs
- RelationshipEndMember.cs
- ImageDrawing.cs
- SrgsGrammarCompiler.cs
- CultureInfoConverter.cs
- SafeFileHandle.cs
- SqlException.cs
- XmlSchemaInferenceException.cs
- Rect.cs
- ProfilePropertyNameValidator.cs
- DataRelation.cs
- GridViewDeletedEventArgs.cs
- BreakRecordTable.cs
- AbandonedMutexException.cs
- HtmlShim.cs
- SecureConversationServiceCredential.cs
- TextEndOfLine.cs
- DependencyObjectPropertyDescriptor.cs
- Control.cs
- GridView.cs
- ContextMarshalException.cs
- FloaterParaClient.cs
- BitmapEffectState.cs
- XmlCharCheckingWriter.cs
- SqlNodeTypeOperators.cs
- AppDomainManager.cs
- SrgsSubset.cs
- SecurityTokenProvider.cs
- Repeater.cs
- DocumentApplication.cs
- ReflectionUtil.cs
- XmlArrayItemAttributes.cs
- XPathExpr.cs
- StringCollection.cs
- BackStopAuthenticationModule.cs
- PlainXmlDeserializer.cs
- HitTestParameters.cs
- TextEditorTyping.cs
- FontFamily.cs
- ACE.cs
- DetailsViewModeEventArgs.cs
- Separator.cs
- TextContainerHelper.cs
- Item.cs
- SystemIPGlobalStatistics.cs
- InputLanguageEventArgs.cs
- Int32RectConverter.cs
- VariableBinder.cs
- TextChange.cs
- WSSecureConversationDec2005.cs
- HierarchicalDataBoundControlAdapter.cs
- MarkupCompilePass2.cs
- ConstraintCollection.cs
- TextSpanModifier.cs
- SemaphoreSecurity.cs
- StateMachineAction.cs
- columnmapfactory.cs
- DiffuseMaterial.cs
- UserMapPath.cs
- DomainLiteralReader.cs
- ArrayElementGridEntry.cs
- DataRowView.cs
- ContextMenu.cs
- TextTreeInsertUndoUnit.cs
- SingleStorage.cs