Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CommonUI / System / Drawing / Size.cs / 1 / Size.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.Diagnostics.CodeAnalysis;
using System.Globalization;
/**
* Represents a dimension in 2D coordinate space
*/
///
///
/// Represents the size of a rectangular region
/// with an ordered pair of width and height.
///
[
TypeConverterAttribute(typeof(SizeConverter)),
]
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")]
public struct Size {
///
///
/// Initializes a new instance of the class.
///
public static readonly Size Empty = new Size();
private int width;
private int height;
/**
* Create a new Size object from a point
*/
///
///
///
/// Initializes a new instance of the class from
/// the specified .
///
///
public Size(Point pt) {
width = pt.X;
height = pt.Y;
}
/**
* Create a new Size object of the specified dimension
*/
///
///
/// Initializes a new instance of the class from
/// the specified dimensions.
///
public Size(int width, int height) {
this.width = width;
this.height = height;
}
///
///
/// Converts the specified to a
/// .
///
public static implicit operator SizeF(Size p) {
return new SizeF(p.Width, p.Height);
}
///
///
///
/// Performs vector addition of two objects.
///
///
public static Size operator +(Size sz1, Size sz2) {
return Add(sz1, sz2);
}
///
///
///
/// Contracts a by another
/// .
///
///
public static Size operator -(Size sz1, Size sz2) {
return Subtract(sz1, sz2);
}
///
///
/// Tests whether two objects
/// are identical.
///
public static bool operator ==(Size sz1, Size sz2) {
return sz1.Width == sz2.Width && sz1.Height == sz2.Height;
}
///
///
///
/// Tests whether two objects are different.
///
///
public static bool operator !=(Size sz1, Size sz2) {
return !(sz1 == sz2);
}
///
///
/// Converts the specified to a
/// .
///
public static explicit operator Point(Size size) {
return new Point(size.Width, size.Height);
}
///
///
/// Tests whether this has zero
/// width and height.
///
[Browsable(false)]
public bool IsEmpty {
get {
return width == 0 && height == 0;
}
}
/**
* Horizontal dimension
*/
///
///
///
/// Represents the horizontal component of this
/// .
///
///
public int Width {
get {
return width;
}
set {
width = value;
}
}
/**
* Vertical dimension
*/
///
///
/// Represents the vertical component of this
/// .
///
public int Height {
get {
return height;
}
set {
height = value;
}
}
///
///
/// Performs vector addition of two objects.
///
///
public static Size Add(Size sz1, Size sz2) {
return new Size(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
}
///
///
/// Converts a SizeF to a Size by performing a ceiling operation on
/// all the coordinates.
///
public static Size Ceiling(SizeF value) {
return new Size((int)Math.Ceiling(value.Width), (int)Math.Ceiling(value.Height));
}
///
///
/// Contracts a by another .
///
///
public static Size Subtract(Size sz1, Size sz2) {
return new Size(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
}
///
///
/// Converts a SizeF to a Size by performing a truncate operation on
/// all the coordinates.
///
public static Size Truncate(SizeF value) {
return new Size((int)value.Width, (int)value.Height);
}
///
///
/// Converts a SizeF to a Size by performing a round operation on
/// all the coordinates.
///
public static Size Round(SizeF value) {
return new Size((int)Math.Round(value.Width), (int)Math.Round(value.Height));
}
///
///
///
/// Tests to see whether the specified object is a
///
/// with the same dimensions as this .
///
///
public override bool Equals(object obj) {
if (!(obj is Size))
return false;
Size comp = (Size)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.width == this.width) &&
(comp.height == this.height);
}
///
///
///
/// Returns a hash code.
///
///
public override int GetHashCode() {
return width ^ height;
}
///
///
///
/// Creates a human-readable string that represents this
/// .
///
///
public override string ToString() {
return "{Width=" + width.ToString(CultureInfo.CurrentCulture) + ", Height=" + height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}
// 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.Diagnostics.CodeAnalysis;
using System.Globalization;
/**
* Represents a dimension in 2D coordinate space
*/
///
///
/// Represents the size of a rectangular region
/// with an ordered pair of width and height.
///
[
TypeConverterAttribute(typeof(SizeConverter)),
]
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")]
public struct Size {
///
///
/// Initializes a new instance of the class.
///
public static readonly Size Empty = new Size();
private int width;
private int height;
/**
* Create a new Size object from a point
*/
///
///
///
/// Initializes a new instance of the class from
/// the specified .
///
///
public Size(Point pt) {
width = pt.X;
height = pt.Y;
}
/**
* Create a new Size object of the specified dimension
*/
///
///
/// Initializes a new instance of the class from
/// the specified dimensions.
///
public Size(int width, int height) {
this.width = width;
this.height = height;
}
///
///
/// Converts the specified to a
/// .
///
public static implicit operator SizeF(Size p) {
return new SizeF(p.Width, p.Height);
}
///
///
///
/// Performs vector addition of two objects.
///
///
public static Size operator +(Size sz1, Size sz2) {
return Add(sz1, sz2);
}
///
///
///
/// Contracts a by another
/// .
///
///
public static Size operator -(Size sz1, Size sz2) {
return Subtract(sz1, sz2);
}
///
///
/// Tests whether two objects
/// are identical.
///
public static bool operator ==(Size sz1, Size sz2) {
return sz1.Width == sz2.Width && sz1.Height == sz2.Height;
}
///
///
///
/// Tests whether two objects are different.
///
///
public static bool operator !=(Size sz1, Size sz2) {
return !(sz1 == sz2);
}
///
///
/// Converts the specified to a
/// .
///
public static explicit operator Point(Size size) {
return new Point(size.Width, size.Height);
}
///
///
/// Tests whether this has zero
/// width and height.
///
[Browsable(false)]
public bool IsEmpty {
get {
return width == 0 && height == 0;
}
}
/**
* Horizontal dimension
*/
///
///
///
/// Represents the horizontal component of this
/// .
///
///
public int Width {
get {
return width;
}
set {
width = value;
}
}
/**
* Vertical dimension
*/
///
///
/// Represents the vertical component of this
/// .
///
public int Height {
get {
return height;
}
set {
height = value;
}
}
///
///
/// Performs vector addition of two objects.
///
///
public static Size Add(Size sz1, Size sz2) {
return new Size(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
}
///
///
/// Converts a SizeF to a Size by performing a ceiling operation on
/// all the coordinates.
///
public static Size Ceiling(SizeF value) {
return new Size((int)Math.Ceiling(value.Width), (int)Math.Ceiling(value.Height));
}
///
///
/// Contracts a by another .
///
///
public static Size Subtract(Size sz1, Size sz2) {
return new Size(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
}
///
///
/// Converts a SizeF to a Size by performing a truncate operation on
/// all the coordinates.
///
public static Size Truncate(SizeF value) {
return new Size((int)value.Width, (int)value.Height);
}
///
///
/// Converts a SizeF to a Size by performing a round operation on
/// all the coordinates.
///
public static Size Round(SizeF value) {
return new Size((int)Math.Round(value.Width), (int)Math.Round(value.Height));
}
///
///
///
/// Tests to see whether the specified object is a
///
/// with the same dimensions as this .
///
///
public override bool Equals(object obj) {
if (!(obj is Size))
return false;
Size comp = (Size)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.width == this.width) &&
(comp.height == this.height);
}
///
///
///
/// Returns a hash code.
///
///
public override int GetHashCode() {
return width ^ height;
}
///
///
///
/// Creates a human-readable string that represents this
/// .
///
///
public override string ToString() {
return "{Width=" + width.ToString(CultureInfo.CurrentCulture) + ", Height=" + height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}
// 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
- SerialPinChanges.cs
- namescope.cs
- PerformanceCounterPermission.cs
- TableHeaderCell.cs
- DefaultTraceListener.cs
- MetaModel.cs
- TreeNode.cs
- ThicknessConverter.cs
- ValueSerializer.cs
- CodeTypeMember.cs
- SelectManyQueryOperator.cs
- StackSpiller.Generated.cs
- JsonFormatReaderGenerator.cs
- BatchServiceHost.cs
- Baml2006KnownTypes.cs
- OverflowException.cs
- StorageScalarPropertyMapping.cs
- ISAPIRuntime.cs
- LockCookie.cs
- Span.cs
- DataGrid.cs
- DefaultTraceListener.cs
- Exceptions.cs
- DependencyPropertyChangedEventArgs.cs
- ControlBuilder.cs
- UICuesEvent.cs
- PathSegmentCollection.cs
- QilParameter.cs
- UnaryOperationBinder.cs
- oledbmetadatacolumnnames.cs
- TemplateControlParser.cs
- MimeMultiPart.cs
- EntitySqlQueryBuilder.cs
- MaterialGroup.cs
- Parser.cs
- DownloadProgressEventArgs.cs
- IndexerNameAttribute.cs
- PreviewKeyDownEventArgs.cs
- SingleAnimationBase.cs
- WebScriptMetadataInstanceContextProvider.cs
- OleDbRowUpdatedEvent.cs
- HttpsHostedTransportConfiguration.cs
- WebPartDescription.cs
- QueueProcessor.cs
- cookie.cs
- PenLineCapValidation.cs
- LinqDataSourceDisposeEventArgs.cs
- DependencySource.cs
- SelectionRange.cs
- SimpleParser.cs
- UnmanagedHandle.cs
- AlternationConverter.cs
- CustomValidator.cs
- ConfigurationValue.cs
- TransportManager.cs
- SmtpException.cs
- InternalSafeNativeMethods.cs
- TableCell.cs
- RtfControls.cs
- BidOverLoads.cs
- DependencyStoreSurrogate.cs
- UMPAttributes.cs
- XmlElement.cs
- ConfigXmlComment.cs
- WebConfigurationFileMap.cs
- WebServicesDescriptionAttribute.cs
- ArrangedElementCollection.cs
- ViewStateModeByIdAttribute.cs
- EventHandlerService.cs
- WebPartTransformerAttribute.cs
- SourceChangedEventArgs.cs
- Synchronization.cs
- RegexTree.cs
- securestring.cs
- DataSysAttribute.cs
- ObjectListShowCommandsEventArgs.cs
- ObfuscateAssemblyAttribute.cs
- GuidelineCollection.cs
- DocumentReference.cs
- LicenseManager.cs
- TextAnchor.cs
- ConnectionOrientedTransportChannelListener.cs
- X509CertificateTokenFactoryCredential.cs
- DataGridTextBox.cs
- XhtmlBasicCommandAdapter.cs
- ToolboxItemAttribute.cs
- CollectionType.cs
- PrinterSettings.cs
- DependencyObject.cs
- ItemChangedEventArgs.cs
- PeerName.cs
- TypeLibraryHelper.cs
- SurrogateDataContract.cs
- dbenumerator.cs
- CodeMethodReturnStatement.cs
- DLinqDataModelProvider.cs
- XPathEmptyIterator.cs
- COM2ComponentEditor.cs
- ToolStripItemTextRenderEventArgs.cs
- COM2PropertyPageUITypeConverter.cs