Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Size.cs / 1 / Size.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /*************************************************************************\ * * Copyright (c) 1998-1999, Microsoft Corp. All Rights Reserved. * * Module Name: * * Size.cs * * Abstract: * * Integer-point coordinate size class * * Revision History: * * 2/4/2k [....] * Created it. * \**************************************************************************/ 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 public static readonly Size Empty = new Size(); private int width; private int height; /** * Create a new Size object from a point */ ///class. /// /// /// 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 . /// /// /// Initializes a new instance of the public Size(int width, int height) { this.width = width; this.height = height; } ///class from /// the specified dimensions. /// /// /// Converts the specified public static implicit operator SizeF(Size p) { return new SizeF(p.Width, p.Height); } ///to a /// . /// /// /// public static Size operator +(Size sz1, Size sz2) { return Add(sz1, sz2); } ////// Performs vector addition of two ///objects. /// /// /// public static Size operator -(Size sz1, Size sz2) { return Subtract(sz1, sz2); } ////// Contracts a ///by another /// . /// /// /// Tests whether two public static bool operator ==(Size sz1, Size sz2) { return sz1.Width == sz2.Width && sz1.Height == sz2.Height; } ///objects /// are identical. /// /// /// public static bool operator !=(Size sz1, Size sz2) { return !(sz1 == sz2); } ////// Tests whether two ///objects are different. /// /// /// Converts the specified public static explicit operator Point(Size size) { return new Point(size.Width, size.Height); } ///to a /// . /// /// /// Tests whether this [Browsable(false)] public bool IsEmpty { get { return width == 0 && height == 0; } } /** * Horizontal dimension */ ///has zero /// width and height. /// /// /// public int Width { get { return width; } set { width = value; } } /** * Vertical dimension */ ////// Represents the horizontal component of this /// ///. /// /// /// Represents the vertical component of this /// public int Height { get { return height; } set { height = value; } } ///. /// /// public static Size Add(Size sz1, Size sz2) { return new Size(sz1.Width + sz2.Width, sz1.Height + sz2.Height); } ////// Performs vector addition of two ///objects. /// /// /// 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)); } ////// public static Size Subtract(Size sz1, Size sz2) { return new Size(sz1.Width - sz2.Width, sz1.Height - sz2.Height); } ////// Contracts a ///by another . /// /// /// 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)); } ////// /// 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); } ////// Tests to see whether the specified object is a /// ////// with the same dimensions as this . /// /// /// public override int GetHashCode() { return width ^ height; } ////// Returns a hash code. /// ////// /// 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./// Creates a human-readable string that represents this /// ///. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DesignerAutoFormat.cs
- MbpInfo.cs
- DocumentPaginator.cs
- PageThemeBuildProvider.cs
- RewritingValidator.cs
- XamlBuildTaskServices.cs
- SqlServer2KCompatibilityCheck.cs
- TargetParameterCountException.cs
- StylusPoint.cs
- SettingsPropertyCollection.cs
- XomlDesignerLoader.cs
- WhileDesigner.cs
- Path.cs
- Itemizer.cs
- PackagePart.cs
- RotationValidation.cs
- LocalizableResourceBuilder.cs
- HierarchicalDataBoundControl.cs
- PersonalizationDictionary.cs
- WorkflowWebService.cs
- ParameterCollection.cs
- HtmlToClrEventProxy.cs
- _SSPIWrapper.cs
- FontDifferentiator.cs
- WebConfigurationHostFileChange.cs
- X509ChainPolicy.cs
- HttpConfigurationContext.cs
- ImportCatalogPart.cs
- AuthenticationConfig.cs
- TextDecorationCollection.cs
- XmlNamespaceMapping.cs
- Triplet.cs
- CodeCommentStatementCollection.cs
- WorkerRequest.cs
- Lease.cs
- DesignerAttribute.cs
- ForwardPositionQuery.cs
- StatusBar.cs
- MarshalByRefObject.cs
- TemplateContainer.cs
- OciHandle.cs
- SimpleApplicationHost.cs
- Screen.cs
- XmlAttribute.cs
- DoubleStorage.cs
- CodeTypeDeclaration.cs
- InstanceDataCollection.cs
- Int32AnimationUsingKeyFrames.cs
- Keywords.cs
- IdentitySection.cs
- PersistenceTypeAttribute.cs
- CodeCommentStatement.cs
- OutputCacheSection.cs
- XmlSchemaComplexContent.cs
- Atom10FeedFormatter.cs
- SqlCacheDependencySection.cs
- AspNetHostingPermission.cs
- TraceUtility.cs
- XamlReaderHelper.cs
- CLRBindingWorker.cs
- LinqDataSourceDeleteEventArgs.cs
- ApplicationHost.cs
- ImageListStreamer.cs
- MonthCalendar.cs
- ProcessModelSection.cs
- DbSourceParameterCollection.cs
- ReadOnlyTernaryTree.cs
- RuleAction.cs
- ToolStripItemRenderEventArgs.cs
- StackBuilderSink.cs
- ExceptionRoutedEventArgs.cs
- SpecularMaterial.cs
- RoleBoolean.cs
- SqlReorderer.cs
- RelationshipConverter.cs
- UnhandledExceptionEventArgs.cs
- TextElementCollectionHelper.cs
- WebPartDescriptionCollection.cs
- BoundConstants.cs
- LocalValueEnumerator.cs
- ObjectSet.cs
- HMACMD5.cs
- MetaModel.cs
- DefaultEventAttribute.cs
- X509Certificate.cs
- DNS.cs
- ImportStoreException.cs
- ComboBoxHelper.cs
- WebPartTracker.cs
- AppDomainAttributes.cs
- RadioButtonBaseAdapter.cs
- XmlSchemaChoice.cs
- ArraySortHelper.cs
- DictionaryKeyPropertyAttribute.cs
- TypePropertyEditor.cs
- ResourceContainer.cs
- SqlPersistenceProviderFactory.cs
- TypeResolver.cs
- Quaternion.cs
- ContainerParaClient.cs