Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / DataGridLength.cs / 1305600 / DataGridLength.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Globalization; using System.Windows; using MS.Internal; namespace System.Windows.Controls { ////// DataGridLength is the type used for various length properties in DataGrid /// that support a variety of descriptive sizing modes in addition to numerical /// values. /// [TypeConverter(typeof(DataGridLengthConverter))] public struct DataGridLength : IEquatable{ #region Constructors /// /// Initializes as an absolute value in pixels. /// /// /// Specifies the number of 'device-independent pixels' (96 pixels-per-inch). /// ////// If public DataGridLength(double pixels) : this(pixels, DataGridLengthUnitType.Pixel) { } ///pixels parameter isdouble.NaN /// orpixels parameter isdouble.NegativeInfinity /// orpixels parameter isdouble.PositiveInfinity . ////// Initializes to a specified value and unit. /// /// The value to hold. /// The unit ofvalue . ////// ///value is ignored unlesstype is ///DataGridLengthUnitType.Pixel or ///DataGridLengthUnitType.Star ////// If public DataGridLength(double value, DataGridLengthUnitType type) : this(value, type, (type == DataGridLengthUnitType.Pixel ? value : Double.NaN), (type == DataGridLengthUnitType.Pixel ? value : Double.NaN)) { } ///value parameter isdouble.NaN /// orvalue parameter isdouble.NegativeInfinity /// orvalue parameter isdouble.PositiveInfinity . ////// Initializes to a specified value and unit. /// /// The value to hold. /// The unit ofvalue . /// /// ////// ///value is ignored unlesstype is ///DataGridLengthUnitType.Pixel or ///DataGridLengthUnitType.Star ////// If public DataGridLength(double value, DataGridLengthUnitType type, double desiredValue, double displayValue) { if (DoubleUtil.IsNaN(value) || Double.IsInfinity(value)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "value"); } if (type != DataGridLengthUnitType.Auto && type != DataGridLengthUnitType.Pixel && type != DataGridLengthUnitType.Star && type != DataGridLengthUnitType.SizeToCells && type != DataGridLengthUnitType.SizeToHeader) { throw new ArgumentException( SR.Get(SRID.DataGridLength_InvalidType), "type"); } if (Double.IsInfinity(desiredValue)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "desiredValue"); } if (Double.IsInfinity(displayValue)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "displayValue"); } _unitValue = (type == DataGridLengthUnitType.Auto) ? AutoValue : value; _unitType = type; _desiredValue = desiredValue; _displayValue = displayValue; } #endregion Constructors #region Public Methods ///value parameter isdouble.NaN /// orvalue parameter isdouble.NegativeInfinity /// orvalue parameter isdouble.PositiveInfinity . ////// Overloaded operator, compares 2 DataGridLength's. /// /// first DataGridLength to compare. /// second DataGridLength to compare. ///true if specified DataGridLengths have same value /// and unit type. public static bool operator ==(DataGridLength gl1, DataGridLength gl2) { return gl1.UnitType == gl2.UnitType && gl1.Value == gl2.Value && ((gl1.DesiredValue == gl2.DesiredValue) || (DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) && ((gl1.DisplayValue == gl2.DisplayValue) || (DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))); } ////// Overloaded operator, compares 2 DataGridLength's. /// /// first DataGridLength to compare. /// second DataGridLength to compare. ///true if specified DataGridLengths have either different value or /// unit type. public static bool operator !=(DataGridLength gl1, DataGridLength gl2) { return gl1.UnitType != gl2.UnitType || gl1.Value != gl2.Value || ((gl1.DesiredValue != gl2.DesiredValue) && !(DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) || ((gl1.DisplayValue != gl2.DisplayValue) && !(DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))); } ////// Compares this instance of DataGridLength with another object. /// /// Reference to an object for comparison. ///public override bool Equals(object obj) { if (obj is DataGridLength) { DataGridLength l = (DataGridLength)obj; return this == l; } else { return false; } } /// true if this DataGridLength instance has the same value /// and unit type as oCompare./// Compares this instance of DataGridLength with another instance. /// /// Grid length instance to compare. ///public bool Equals(DataGridLength other) { return this == other; } /// true if this DataGridLength instance has the same value /// and unit type as gridLength./// ////// public override int GetHashCode() { return (int)_unitValue + (int)_unitType + (int)_desiredValue + (int)_displayValue; } /// /// Returns public bool IsAbsolute { get { return _unitType == DataGridLengthUnitType.Pixel; } } ///true if this DataGridLength instance holds /// an absolute (pixel) value. ////// Returns public bool IsAuto { get { return _unitType == DataGridLengthUnitType.Auto; } } ///true if this DataGridLength instance is /// automatic (not specified). ////// Returns public bool IsStar { get { return _unitType == DataGridLengthUnitType.Star; } } ///true if this DataGridLength instance holds a weighted proportion /// of available space. ////// Returns public bool IsSizeToCells { get { return _unitType == DataGridLengthUnitType.SizeToCells; } } ///true if this instance is to size to the cells of a column or row. ////// Returns public bool IsSizeToHeader { get { return _unitType == DataGridLengthUnitType.SizeToHeader; } } ///true if this instance is to size to the header of a column or row. ////// Returns value part of this DataGridLength instance. /// public double Value { get { return (_unitType == DataGridLengthUnitType.Auto) ? AutoValue : _unitValue; } } ////// Returns unit type of this DataGridLength instance. /// public DataGridLengthUnitType UnitType { get { return _unitType; } } ////// Returns the desired value of this instance. /// public double DesiredValue { get { return _desiredValue; } } ////// Returns the display value of this instance. /// public double DisplayValue { get { return _displayValue; } } ////// Returns the string representation of this object. /// public override string ToString() { return DataGridLengthConverter.ConvertToString(this, CultureInfo.InvariantCulture); } #endregion #region Pre-defined values ////// Returns a value initialized to mean "auto." /// public static DataGridLength Auto { get { return _auto; } } ////// Returns a value initialized to mean "size to cells." /// public static DataGridLength SizeToCells { get { return _sizeToCells; } } ////// Returns a value initialized to mean "size to header." /// public static DataGridLength SizeToHeader { get { return _sizeToHeader; } } #endregion #region Implicit Conversions ////// Allows for values of type double to be implicitly converted /// to DataGridLength. /// /// The number of pixels to represent. ///The DataGridLength representing the requested number of pixels. public static implicit operator DataGridLength(double value) { return new DataGridLength(value); } #endregion #region Fields private double _unitValue; // unit value storage private DataGridLengthUnitType _unitType; // unit type storage private double _desiredValue; // desired value storage private double _displayValue; // display value storage private const double AutoValue = 1.0; // static instance of Auto DataGridLength private static readonly DataGridLength _auto = new DataGridLength(AutoValue, DataGridLengthUnitType.Auto, 0d, 0d); private static readonly DataGridLength _sizeToCells = new DataGridLength(AutoValue, DataGridLengthUnitType.SizeToCells, 0d, 0d); private static readonly DataGridLength _sizeToHeader = new DataGridLength(AutoValue, DataGridLengthUnitType.SizeToHeader, 0d, 0d); #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Globalization; using System.Windows; using MS.Internal; namespace System.Windows.Controls { ////// DataGridLength is the type used for various length properties in DataGrid /// that support a variety of descriptive sizing modes in addition to numerical /// values. /// [TypeConverter(typeof(DataGridLengthConverter))] public struct DataGridLength : IEquatable{ #region Constructors /// /// Initializes as an absolute value in pixels. /// /// /// Specifies the number of 'device-independent pixels' (96 pixels-per-inch). /// ////// If public DataGridLength(double pixels) : this(pixels, DataGridLengthUnitType.Pixel) { } ///pixels parameter isdouble.NaN /// orpixels parameter isdouble.NegativeInfinity /// orpixels parameter isdouble.PositiveInfinity . ////// Initializes to a specified value and unit. /// /// The value to hold. /// The unit ofvalue . ////// ///value is ignored unlesstype is ///DataGridLengthUnitType.Pixel or ///DataGridLengthUnitType.Star ////// If public DataGridLength(double value, DataGridLengthUnitType type) : this(value, type, (type == DataGridLengthUnitType.Pixel ? value : Double.NaN), (type == DataGridLengthUnitType.Pixel ? value : Double.NaN)) { } ///value parameter isdouble.NaN /// orvalue parameter isdouble.NegativeInfinity /// orvalue parameter isdouble.PositiveInfinity . ////// Initializes to a specified value and unit. /// /// The value to hold. /// The unit ofvalue . /// /// ////// ///value is ignored unlesstype is ///DataGridLengthUnitType.Pixel or ///DataGridLengthUnitType.Star ////// If public DataGridLength(double value, DataGridLengthUnitType type, double desiredValue, double displayValue) { if (DoubleUtil.IsNaN(value) || Double.IsInfinity(value)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "value"); } if (type != DataGridLengthUnitType.Auto && type != DataGridLengthUnitType.Pixel && type != DataGridLengthUnitType.Star && type != DataGridLengthUnitType.SizeToCells && type != DataGridLengthUnitType.SizeToHeader) { throw new ArgumentException( SR.Get(SRID.DataGridLength_InvalidType), "type"); } if (Double.IsInfinity(desiredValue)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "desiredValue"); } if (Double.IsInfinity(displayValue)) { throw new ArgumentException( SR.Get(SRID.DataGridLength_Infinity), "displayValue"); } _unitValue = (type == DataGridLengthUnitType.Auto) ? AutoValue : value; _unitType = type; _desiredValue = desiredValue; _displayValue = displayValue; } #endregion Constructors #region Public Methods ///value parameter isdouble.NaN /// orvalue parameter isdouble.NegativeInfinity /// orvalue parameter isdouble.PositiveInfinity . ////// Overloaded operator, compares 2 DataGridLength's. /// /// first DataGridLength to compare. /// second DataGridLength to compare. ///true if specified DataGridLengths have same value /// and unit type. public static bool operator ==(DataGridLength gl1, DataGridLength gl2) { return gl1.UnitType == gl2.UnitType && gl1.Value == gl2.Value && ((gl1.DesiredValue == gl2.DesiredValue) || (DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) && ((gl1.DisplayValue == gl2.DisplayValue) || (DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))); } ////// Overloaded operator, compares 2 DataGridLength's. /// /// first DataGridLength to compare. /// second DataGridLength to compare. ///true if specified DataGridLengths have either different value or /// unit type. public static bool operator !=(DataGridLength gl1, DataGridLength gl2) { return gl1.UnitType != gl2.UnitType || gl1.Value != gl2.Value || ((gl1.DesiredValue != gl2.DesiredValue) && !(DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) || ((gl1.DisplayValue != gl2.DisplayValue) && !(DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))); } ////// Compares this instance of DataGridLength with another object. /// /// Reference to an object for comparison. ///public override bool Equals(object obj) { if (obj is DataGridLength) { DataGridLength l = (DataGridLength)obj; return this == l; } else { return false; } } /// true if this DataGridLength instance has the same value /// and unit type as oCompare./// Compares this instance of DataGridLength with another instance. /// /// Grid length instance to compare. ///public bool Equals(DataGridLength other) { return this == other; } /// true if this DataGridLength instance has the same value /// and unit type as gridLength./// ////// public override int GetHashCode() { return (int)_unitValue + (int)_unitType + (int)_desiredValue + (int)_displayValue; } /// /// Returns public bool IsAbsolute { get { return _unitType == DataGridLengthUnitType.Pixel; } } ///true if this DataGridLength instance holds /// an absolute (pixel) value. ////// Returns public bool IsAuto { get { return _unitType == DataGridLengthUnitType.Auto; } } ///true if this DataGridLength instance is /// automatic (not specified). ////// Returns public bool IsStar { get { return _unitType == DataGridLengthUnitType.Star; } } ///true if this DataGridLength instance holds a weighted proportion /// of available space. ////// Returns public bool IsSizeToCells { get { return _unitType == DataGridLengthUnitType.SizeToCells; } } ///true if this instance is to size to the cells of a column or row. ////// Returns public bool IsSizeToHeader { get { return _unitType == DataGridLengthUnitType.SizeToHeader; } } ///true if this instance is to size to the header of a column or row. ////// Returns value part of this DataGridLength instance. /// public double Value { get { return (_unitType == DataGridLengthUnitType.Auto) ? AutoValue : _unitValue; } } ////// Returns unit type of this DataGridLength instance. /// public DataGridLengthUnitType UnitType { get { return _unitType; } } ////// Returns the desired value of this instance. /// public double DesiredValue { get { return _desiredValue; } } ////// Returns the display value of this instance. /// public double DisplayValue { get { return _displayValue; } } ////// Returns the string representation of this object. /// public override string ToString() { return DataGridLengthConverter.ConvertToString(this, CultureInfo.InvariantCulture); } #endregion #region Pre-defined values ////// Returns a value initialized to mean "auto." /// public static DataGridLength Auto { get { return _auto; } } ////// Returns a value initialized to mean "size to cells." /// public static DataGridLength SizeToCells { get { return _sizeToCells; } } ////// Returns a value initialized to mean "size to header." /// public static DataGridLength SizeToHeader { get { return _sizeToHeader; } } #endregion #region Implicit Conversions ////// Allows for values of type double to be implicitly converted /// to DataGridLength. /// /// The number of pixels to represent. ///The DataGridLength representing the requested number of pixels. public static implicit operator DataGridLength(double value) { return new DataGridLength(value); } #endregion #region Fields private double _unitValue; // unit value storage private DataGridLengthUnitType _unitType; // unit type storage private double _desiredValue; // desired value storage private double _displayValue; // display value storage private const double AutoValue = 1.0; // static instance of Auto DataGridLength private static readonly DataGridLength _auto = new DataGridLength(AutoValue, DataGridLengthUnitType.Auto, 0d, 0d); private static readonly DataGridLength _sizeToCells = new DataGridLength(AutoValue, DataGridLengthUnitType.SizeToCells, 0d, 0d); private static readonly DataGridLength _sizeToHeader = new DataGridLength(AutoValue, DataGridLengthUnitType.SizeToHeader, 0d, 0d); #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpRequestCacheValidator.cs
- ClrPerspective.cs
- WizardStepBase.cs
- ReferenceList.cs
- Errors.cs
- UnsafeNativeMethods.cs
- AssemblyAttributesGoHere.cs
- WindowsTreeView.cs
- DynamicAttribute.cs
- EdmMember.cs
- VarRemapper.cs
- XmlSchemaComplexType.cs
- InkCanvasSelectionAdorner.cs
- ModifierKeysValueSerializer.cs
- WebException.cs
- TileModeValidation.cs
- ContextInformation.cs
- StorageEntitySetMapping.cs
- ExtendedProperty.cs
- AuthenticationServiceManager.cs
- DesignerTransaction.cs
- UnmanagedMemoryStreamWrapper.cs
- InputLanguageProfileNotifySink.cs
- DataSourceControlBuilder.cs
- GenericsInstances.cs
- DispatcherProcessingDisabled.cs
- ReadOnlyDictionary.cs
- Byte.cs
- ISAPIApplicationHost.cs
- srgsitem.cs
- httpserverutility.cs
- MDIClient.cs
- ApplicationServiceHelper.cs
- SecUtil.cs
- MultipleViewProviderWrapper.cs
- GraphicsPathIterator.cs
- CategoryNameCollection.cs
- ByteStream.cs
- NamedPipeConnectionPoolSettingsElement.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- GotoExpression.cs
- SystemWebExtensionsSectionGroup.cs
- ReceiveContent.cs
- Adorner.cs
- XPathNavigatorKeyComparer.cs
- AxisAngleRotation3D.cs
- Selector.cs
- GraphicsState.cs
- TextPattern.cs
- IndicCharClassifier.cs
- baseshape.cs
- SqlInfoMessageEvent.cs
- linebase.cs
- StandardCommandToolStripMenuItem.cs
- _OverlappedAsyncResult.cs
- StringResourceManager.cs
- SchemaMapping.cs
- UpdateTranslator.cs
- SchemaConstraints.cs
- UIElementCollection.cs
- MissingSatelliteAssemblyException.cs
- InvalidateEvent.cs
- CDSCollectionETWBCLProvider.cs
- CryptoConfig.cs
- CngProperty.cs
- Point3DConverter.cs
- SmtpReplyReader.cs
- KnownIds.cs
- NTAccount.cs
- DataGridViewToolTip.cs
- NonBatchDirectoryCompiler.cs
- ByteStorage.cs
- FormsAuthenticationCredentials.cs
- SocketConnection.cs
- ItemCheckEvent.cs
- CssTextWriter.cs
- EdmFunction.cs
- DetailsViewInsertEventArgs.cs
- Utils.cs
- SchemaImporterExtensionElementCollection.cs
- GridViewRowPresenter.cs
- QueryResults.cs
- EventProxy.cs
- TextBoxAutoCompleteSourceConverter.cs
- HMACSHA256.cs
- PersonalizableTypeEntry.cs
- IItemContainerGenerator.cs
- RawKeyboardInputReport.cs
- AnnotationHelper.cs
- RectangleGeometry.cs
- ProtocolsConfigurationHandler.cs
- OutOfMemoryException.cs
- XmlTextEncoder.cs
- Win32MouseDevice.cs
- DbLambda.cs
- RootDesignerSerializerAttribute.cs
- Select.cs
- HtmlAnchor.cs
- ChangeTracker.cs
- Baml2006Reader.cs