Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / SizeF.cs / 1305376 / SizeF.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing {
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.
///
///
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
[TypeConverter(typeof(SizeFConverter))]
[SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates")]
public struct SizeF {
///
///
/// Initializes a new instance of the class.
///
public static readonly SizeF Empty = new SizeF();
private float width;
private float height;
/**
* Create a new SizeF object from another size object
*/
///
///
/// Initializes a new instance of the class
/// from the specified existing .
///
public SizeF(SizeF size) {
width = size.width;
height = size.height;
}
/**
* Create a new SizeF object from a point
*/
///
///
///
/// Initializes a new instance of the class from
/// the specified .
///
///
public SizeF(PointF pt) {
width = pt.X;
height = pt.Y;
}
/**
* Create a new SizeF object of the specified dimension
*/
///
///
///
/// Initializes a new instance of the class from
/// the specified dimensions.
///
///
public SizeF(float width, float height) {
this.width = width;
this.height = height;
}
///
///
///
/// Performs vector addition of two objects.
///
///
public static SizeF operator +(SizeF sz1, SizeF sz2) {
return Add(sz1, sz2);
}
///
///
///
/// Contracts a by another
/// .
///
///
public static SizeF operator -(SizeF sz1, SizeF sz2) {
return Subtract(sz1, sz2);
}
///
///
/// Tests whether two objects
/// are identical.
///
public static bool operator ==(SizeF sz1, SizeF sz2) {
return sz1.Width == sz2.Width && sz1.Height == sz2.Height;
}
///
///
///
/// Tests whether two objects are different.
///
///
public static bool operator !=(SizeF sz1, SizeF sz2) {
return !(sz1 == sz2);
}
///
///
///
/// Converts the specified to a
/// .
///
///
public static explicit operator PointF(SizeF size) {
return new PointF(size.Width, size.Height);
}
///
///
///
/// Tests whether this has zero
/// width and height.
///
///
[Browsable(false)]
public bool IsEmpty {
[System.Runtime.TargetedPatchingOptOutAttribute("Performance critical to inline across NGen image boundaries")]
get {
return width == 0 && height == 0;
}
}
/**
* Horizontal dimension
*/
///
///
///
/// Represents the horizontal component of this
/// .
///
///
public float Width {
get {
return width;
}
set {
width = value;
}
}
/**
* Vertical dimension
*/
///
///
///
/// Represents the vertical component of this
/// .
///
///
public float Height {
get {
return height;
}
set {
height = value;
}
}
///
///
/// Performs vector addition of two objects.
///
///
public static SizeF Add(SizeF sz1, SizeF sz2) {
return new SizeF(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
}
///
///
///
/// Contracts a by another
/// .
///
///
public static SizeF Subtract(SizeF sz1, SizeF sz2) {
return new SizeF(sz1.Width - sz2.Width, sz1.Height - sz2.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 SizeF))
return false;
SizeF comp = (SizeF)obj;
return(comp.Width == this.Width) &&
(comp.Height == this.Height) &&
(comp.GetType().Equals(GetType()));
}
///
///
/// [To be supplied.]
///
public override int GetHashCode() {
return base.GetHashCode();
}
///
///
/// [To be supplied.]
///
public PointF ToPointF() {
return (PointF) this;
}
///
///
/// [To be supplied.]
///
public Size ToSize() {
return Size.Truncate(this);
}
///
///
///
/// 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
- TraceData.cs
- Preprocessor.cs
- CfgRule.cs
- InkCanvasAutomationPeer.cs
- SerializationInfoEnumerator.cs
- SimpleApplicationHost.cs
- SqlUserDefinedTypeAttribute.cs
- TimeoutHelper.cs
- ThemeConfigurationDialog.cs
- WeakReadOnlyCollection.cs
- ValidationService.cs
- IssuedSecurityTokenParameters.cs
- SessionStateModule.cs
- GridViewCancelEditEventArgs.cs
- SqlDataRecord.cs
- AsmxEndpointPickerExtension.cs
- EntityRecordInfo.cs
- WindowsBrush.cs
- SaveFileDialog.cs
- HandleDictionary.cs
- BaseTreeIterator.cs
- GridViewDeleteEventArgs.cs
- DPCustomTypeDescriptor.cs
- FolderBrowserDialog.cs
- MyContact.cs
- UpdateTranslator.cs
- FontSizeConverter.cs
- SegmentInfo.cs
- SubpageParaClient.cs
- DataGridViewCellMouseEventArgs.cs
- DynamicILGenerator.cs
- TextSearch.cs
- MsmqIntegrationSecurityElement.cs
- OperationDescription.cs
- SHA256Managed.cs
- ListBoxItemAutomationPeer.cs
- ReliableSessionBindingElement.cs
- RIPEMD160Managed.cs
- DataGridViewEditingControlShowingEventArgs.cs
- TTSEngineTypes.cs
- CompositeActivityTypeDescriptor.cs
- SafeThemeHandle.cs
- EntitySqlQueryCacheEntry.cs
- ValidatingPropertiesEventArgs.cs
- Input.cs
- StructuredTypeEmitter.cs
- SetStateDesigner.cs
- CodeAccessSecurityEngine.cs
- GenericTypeParameterBuilder.cs
- TextCharacters.cs
- XPathAncestorQuery.cs
- CompositeTypefaceMetrics.cs
- ScrollEventArgs.cs
- GregorianCalendarHelper.cs
- TimelineGroup.cs
- DataQuery.cs
- SpanIndex.cs
- SAPIEngineTypes.cs
- WebHeaderCollection.cs
- TextDecoration.cs
- InitializingNewItemEventArgs.cs
- MSG.cs
- RequestNavigateEventArgs.cs
- EnumerableWrapperWeakToStrong.cs
- LookupNode.cs
- RotateTransform3D.cs
- SurrogateChar.cs
- ColumnReorderedEventArgs.cs
- Matrix3DConverter.cs
- HMACRIPEMD160.cs
- InstalledVoice.cs
- NestedContainer.cs
- AnnotationComponentManager.cs
- QilScopedVisitor.cs
- FieldNameLookup.cs
- sapiproxy.cs
- BridgeDataReader.cs
- WebPartUtil.cs
- XmlEncoding.cs
- XmlNavigatorStack.cs
- BasePropertyDescriptor.cs
- FixedSOMTableCell.cs
- WebPartConnectionsDisconnectVerb.cs
- RemoteCryptoRsaServiceProvider.cs
- Base64WriteStateInfo.cs
- WebRequestModuleElementCollection.cs
- EntityContainerEmitter.cs
- RouteTable.cs
- ProtocolReflector.cs
- WorkflowDefinitionDispenser.cs
- TextElementCollectionHelper.cs
- SafeFindHandle.cs
- RangeExpression.cs
- InvokeHandlers.cs
- XmlSchemaObject.cs
- ListItemCollection.cs
- _Semaphore.cs
- PerformanceCounterPermissionAttribute.cs
- TemplateContainer.cs
- SslStreamSecurityElement.cs