Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Printing / Margins.cs / 1 / Margins.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Printing { using System.Runtime.Serialization.Formatters; using System.Diagnostics; using System; using System.Runtime.InteropServices; using System.Drawing; using Microsoft.Win32; using System.ComponentModel; using System.Globalization; ////// /// [ Serializable, TypeConverterAttribute(typeof(MarginsConverter)) ] public class Margins : ICloneable { private int left; private int right; private int top; private int bottom; ////// Specifies the margins of a printed page. /// ////// /// public Margins() : this(100, 100, 100, 100) { } ////// Initializes a new instance of a the ///class with one-inch margins. /// /// /// public Margins(int left, int right, int top, int bottom) { CheckMargin(left, "left"); CheckMargin(right, "right"); CheckMargin(top, "top"); CheckMargin(bottom, "bottom"); this.left = left; this.right = right; this.top = top; this.bottom = bottom; } ////// Initializes a new instance of a the ///class with the specified left, right, top, and bottom /// margins. /// /// /// public int Left { get { return left;} set { CheckMargin(value, "Left"); left = value; } } ////// Gets or sets the left margin, in hundredths of an inch. /// ////// /// public int Right { get { return right;} set { CheckMargin(value, "Right"); right = value; } } ////// Gets or sets the right margin, in hundredths of an inch. /// ////// /// public int Top { get { return top;} set { CheckMargin(value, "Top"); top = value; } } ////// Gets or sets the top margin, in hundredths of an inch. /// ////// /// public int Bottom { get { return bottom;} set { CheckMargin(value, "Bottom"); bottom = value; } } private void CheckMargin(int margin, string name) { if (margin < 0) throw new ArgumentException(SR.GetString(SR.InvalidLowBoundArgumentEx, name, margin, "0")); } ////// Gets or sets the bottom margin, in hundredths of an inch. /// ////// /// public object Clone() { return MemberwiseClone(); } ////// Retrieves a duplicate of this object, member by member. /// ////// /// public override bool Equals(object obj) { Margins margins = obj as Margins; if (margins == this) return true; if (margins == null) return false; return margins.left == this.left && margins.right == this.right && margins.top == this.top && margins.bottom == this.bottom; } ////// Compares this ///to a specified to see whether they /// are equal. /// /// /// public override int GetHashCode() { // return HashCodes.Combine(left, right, top, bottom); uint left = (uint) this.left; uint right = (uint) this.right; uint top = (uint) this.top; uint bottom = (uint) this.bottom; uint result = left ^ ((right << 13) | (right >> 19)) ^ ((top << 26) | (top >> 6)) ^ ((bottom << 7) | (bottom >> 25)); return(int) result; } ////// Calculates and retrieves a hash code based on the left, right, top, and bottom /// margins. /// ////// /// Tests whether two public static bool operator ==(Margins m1, Margins m2) { if (object.ReferenceEquals(m1, null) != object.ReferenceEquals(m2, null)) { return false; } if (!object.ReferenceEquals(m1, null)) { return m1.Left == m2.Left && m1.Top == m2.Top && m1.Right == m2.Right && m1.Bottom == m2.Bottom; } return true; } ///objects /// are identical. /// /// /// public static bool operator !=(Margins m1, Margins m2) { return !(m1 == m2); } ////// Tests whether two ///objects are different. /// /// /// /// public override string ToString() { return "[Margins" + " Left=" + Left.ToString(CultureInfo.InvariantCulture) + " Right=" + Right.ToString(CultureInfo.InvariantCulture) + " Top=" + Top.ToString(CultureInfo.InvariantCulture) + " Bottom=" + Bottom.ToString(CultureInfo.InvariantCulture) + "]"; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved./// Provides some interesting information for the Margins in /// String form. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- sapiproxy.cs
- EdmFunction.cs
- SqlClientPermission.cs
- SmuggledIUnknown.cs
- ContainerSelectorGlyph.cs
- SuppressMergeCheckAttribute.cs
- DataBindingCollection.cs
- PackageDigitalSignatureManager.cs
- ADMembershipProvider.cs
- SubMenuStyleCollection.cs
- TextTreeRootNode.cs
- CustomSignedXml.cs
- RTLAwareMessageBox.cs
- ConstructorNeedsTagAttribute.cs
- RemotingSurrogateSelector.cs
- RangeValuePatternIdentifiers.cs
- TextMarkerSource.cs
- SchemaDeclBase.cs
- SerializationSectionGroup.cs
- XmlWriter.cs
- ImportRequest.cs
- PrintingPermission.cs
- RegexReplacement.cs
- VolatileResourceManager.cs
- FontFamilyValueSerializer.cs
- CollectionContainer.cs
- Visual3D.cs
- TreeViewImageKeyConverter.cs
- _ConnectOverlappedAsyncResult.cs
- RelatedCurrencyManager.cs
- RestClientProxyHandler.cs
- CodeArrayCreateExpression.cs
- XsltArgumentList.cs
- Parameter.cs
- Rule.cs
- SynchronizationContext.cs
- EventProviderWriter.cs
- BlobPersonalizationState.cs
- Clause.cs
- GeneralTransform3DGroup.cs
- XmlReaderSettings.cs
- ObjectKeyFrameCollection.cs
- DocumentXmlWriter.cs
- ToolStripContentPanelRenderEventArgs.cs
- XmlHierarchyData.cs
- ScheduleChanges.cs
- exports.cs
- HostingEnvironment.cs
- CopyAttributesAction.cs
- RtfFormatStack.cs
- TypeCodeDomSerializer.cs
- Vector3DAnimationBase.cs
- OperatingSystem.cs
- SettingsBase.cs
- ReadOnlyCollectionBuilder.cs
- SourceFileBuildProvider.cs
- DrawingAttributesDefaultValueFactory.cs
- ColorTransform.cs
- ResourceAssociationSetEnd.cs
- DataGridCell.cs
- SQLInt32Storage.cs
- WebPartMovingEventArgs.cs
- PathGradientBrush.cs
- MessageProperties.cs
- WindowsGraphicsCacheManager.cs
- XmlJsonReader.cs
- StoreAnnotationsMap.cs
- TextContainer.cs
- AvTraceDetails.cs
- MultiView.cs
- SoapHeaders.cs
- CustomWebEventKey.cs
- FormatSettings.cs
- Control.cs
- RoleGroupCollectionEditor.cs
- GeneralTransformGroup.cs
- ProjectionPruner.cs
- ControlPropertyNameConverter.cs
- RequestCacheEntry.cs
- XmlSchemaGroup.cs
- UrlPropertyAttribute.cs
- IDReferencePropertyAttribute.cs
- SizeAnimationClockResource.cs
- SamlAudienceRestrictionCondition.cs
- DataContractSerializerFaultFormatter.cs
- SmtpDigestAuthenticationModule.cs
- ToolStripContentPanel.cs
- panel.cs
- NativeMethods.cs
- SystemIPGlobalProperties.cs
- XmlWrappingWriter.cs
- Exceptions.cs
- DecimalAnimationBase.cs
- RequestNavigateEventArgs.cs
- QueryStringParameter.cs
- DataGridViewTextBoxCell.cs
- TdsParserHelperClasses.cs
- DiscoveryServerProtocol.cs
- FormViewDeleteEventArgs.cs
- _DomainName.cs