Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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;
///
///
///
/// Specifies the margins of a printed page.
///
///
[
Serializable,
TypeConverterAttribute(typeof(MarginsConverter))
]
public class Margins : ICloneable {
private int left;
private int right;
private int top;
private int bottom;
///
///
///
/// Initializes a new instance of a the class with one-inch margins.
///
///
public Margins() : this(100, 100, 100, 100) {
}
///
///
///
/// Initializes a new instance of a the class with the specified left, right, top, and bottom
/// 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;
}
///
///
///
/// Gets or sets the left margin, in hundredths of an inch.
///
///
public int Left {
get { return left;}
set {
CheckMargin(value, "Left");
left = value;
}
}
///
///
///
/// Gets or sets the right margin, in hundredths of an inch.
///
///
public int Right {
get { return right;}
set {
CheckMargin(value, "Right");
right = value;
}
}
///
///
///
/// Gets or sets the top margin, in hundredths of an inch.
///
///
public int Top {
get { return top;}
set {
CheckMargin(value, "Top");
top = value;
}
}
///
///
///
/// Gets or sets the bottom 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"));
}
///
///
///
/// Retrieves a duplicate of this object, member by member.
///
///
public object Clone() {
return MemberwiseClone();
}
///
///
///
/// Compares this to a specified to see whether they
/// are equal.
///
///
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;
}
///
///
///
/// Calculates and retrieves a hash code based on the left, right, top, and bottom
/// margins.
///
///
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;
}
///
///
/// Tests whether two objects
/// are identical.
///
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;
}
///
///
///
/// Tests whether two objects are different.
///
///
public static bool operator !=(Margins m1, Margins m2) {
return !(m1 == m2);
}
///
///
///
///
/// Provides some interesting information for the Margins in
/// String form.
///
///
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.
//
//-----------------------------------------------------------------------------
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;
///
///
///
/// Specifies the margins of a printed page.
///
///
[
Serializable,
TypeConverterAttribute(typeof(MarginsConverter))
]
public class Margins : ICloneable {
private int left;
private int right;
private int top;
private int bottom;
///
///
///
/// Initializes a new instance of a the class with one-inch margins.
///
///
public Margins() : this(100, 100, 100, 100) {
}
///
///
///
/// Initializes a new instance of a the class with the specified left, right, top, and bottom
/// 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;
}
///
///
///
/// Gets or sets the left margin, in hundredths of an inch.
///
///
public int Left {
get { return left;}
set {
CheckMargin(value, "Left");
left = value;
}
}
///
///
///
/// Gets or sets the right margin, in hundredths of an inch.
///
///
public int Right {
get { return right;}
set {
CheckMargin(value, "Right");
right = value;
}
}
///
///
///
/// Gets or sets the top margin, in hundredths of an inch.
///
///
public int Top {
get { return top;}
set {
CheckMargin(value, "Top");
top = value;
}
}
///
///
///
/// Gets or sets the bottom 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"));
}
///
///
///
/// Retrieves a duplicate of this object, member by member.
///
///
public object Clone() {
return MemberwiseClone();
}
///
///
///
/// Compares this to a specified to see whether they
/// are equal.
///
///
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;
}
///
///
///
/// Calculates and retrieves a hash code based on the left, right, top, and bottom
/// margins.
///
///
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;
}
///
///
/// Tests whether two objects
/// are identical.
///
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;
}
///
///
///
/// Tests whether two objects are different.
///
///
public static bool operator !=(Margins m1, Margins m2) {
return !(m1 == m2);
}
///
///
///
///
/// Provides some interesting information for the Margins in
/// String form.
///
///
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UInt64Converter.cs
- RootProfilePropertySettingsCollection.cs
- UpdateManifestForBrowserApplication.cs
- HttpGetProtocolReflector.cs
- FrameDimension.cs
- HtmlForm.cs
- ArraySortHelper.cs
- X509Extension.cs
- PreProcessInputEventArgs.cs
- Hash.cs
- ConnectionStringsExpressionBuilder.cs
- DesignObjectWrapper.cs
- IconBitmapDecoder.cs
- LayoutTable.cs
- ExpressionPrefixAttribute.cs
- ComEventsHelper.cs
- EncoderNLS.cs
- Pipe.cs
- XmlDocumentSerializer.cs
- XPathChildIterator.cs
- ImageMapEventArgs.cs
- GridPattern.cs
- CodeAttachEventStatement.cs
- TrackingAnnotationCollection.cs
- ExpressionReplacer.cs
- WebPartCloseVerb.cs
- CookieParameter.cs
- CopyAction.cs
- SqlDataSourceQueryEditor.cs
- EventLogger.cs
- IntPtr.cs
- TreeViewTemplateSelector.cs
- DataAdapter.cs
- PanelDesigner.cs
- StrokeNodeOperations2.cs
- WithStatement.cs
- EntityDesignerDataSourceView.cs
- OdbcTransaction.cs
- HandleValueEditor.cs
- TreeViewCancelEvent.cs
- StackBuilderSink.cs
- DBCommand.cs
- DecoderNLS.cs
- DetailsViewRowCollection.cs
- LocalizationParserHooks.cs
- FormsAuthenticationTicket.cs
- RuleRef.cs
- PropertyReference.cs
- FixedSOMTableRow.cs
- SqlNotificationRequest.cs
- DirectoryNotFoundException.cs
- ComEventsInfo.cs
- StreamGeometryContext.cs
- TTSEvent.cs
- TextDecorations.cs
- FlowchartDesigner.xaml.cs
- SAPIEngineTypes.cs
- CompositeDesignerAccessibleObject.cs
- WebConfigurationHost.cs
- CodeIdentifiers.cs
- TextProviderWrapper.cs
- XmlCollation.cs
- HtmlString.cs
- HttpValueCollection.cs
- PinProtectionHelper.cs
- Translator.cs
- ConfigurationElementProperty.cs
- SizeFConverter.cs
- updatecommandorderer.cs
- UnitySerializationHolder.cs
- UxThemeWrapper.cs
- AlphaSortedEnumConverter.cs
- ObjectReferenceStack.cs
- ServiceDescription.cs
- XmlDictionaryReaderQuotas.cs
- CollectionChangedEventManager.cs
- EmptyImpersonationContext.cs
- SemanticTag.cs
- OLEDB_Enum.cs
- PropertyGeneratedEventArgs.cs
- MetaType.cs
- BitmapDecoder.cs
- CompilerError.cs
- StringFormat.cs
- StructuredTypeEmitter.cs
- EntityRecordInfo.cs
- OpacityConverter.cs
- WebPartActionVerb.cs
- Setter.cs
- SchemaNamespaceManager.cs
- XmlDataSource.cs
- RequestUriProcessor.cs
- FontStyleConverter.cs
- FileDialogCustomPlacesCollection.cs
- EditorZoneBase.cs
- _FtpDataStream.cs
- XamlPathDataSerializer.cs
- HttpCacheParams.cs
- VirtualDirectoryMappingCollection.cs
- X509AudioLogo.cs