Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / TableLayoutPanelCellPosition.cs / 1 / TableLayoutPanelCellPosition.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; using System.Globalization; [TypeConverterAttribute(typeof(TableLayoutPanelCellPositionTypeConverter))] public struct TableLayoutPanelCellPosition { private int row; private int column; public TableLayoutPanelCellPosition(int column, int row) { if (row < -1) { throw new ArgumentOutOfRangeException("row", SR.GetString(SR.InvalidArgument, "row", (row).ToString(CultureInfo.CurrentCulture))); } if (column < -1) { throw new ArgumentOutOfRangeException("column", SR.GetString(SR.InvalidArgument, "column", (column).ToString(CultureInfo.CurrentCulture))); } this.row = row; this.column = column; } public int Row { get { return row; } set { row = value; } } public int Column { get { return column; } set { column = value; } } public override bool Equals(object other) { if(other is TableLayoutPanelCellPosition) { TableLayoutPanelCellPosition dpeOther = (TableLayoutPanelCellPosition) other; return (dpeOther.row == row && dpeOther.column == column); } return false; } public static bool operator ==(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2) { return p1.Row == p2.Row && p1.Column == p2.Column; } public static bool operator !=(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2) { return !(p1 == p2); } public override string ToString() { return Column.ToString(CultureInfo.CurrentCulture) + "," + Row.ToString(CultureInfo.CurrentCulture); } public override int GetHashCode() { // VSWhidbey #130081: structs should implement GetHashCode for perf return WindowsFormsUtils.GetCombinedHashCodes( this.row, this.column); } } internal class TableLayoutPanelCellPositionTypeConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); if (text.Length == 0) { return null; } else { // Parse 2 integer values. // if (culture == null) { culture = CultureInfo.CurrentCulture; } char sep = culture.TextInfo.ListSeparator[0]; string[] tokens = text.Split(new char[] {sep}); int[] values = new int[tokens.Length]; TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); for (int i = 0; i < values.Length; i++) { // Note: ConvertFromString will raise exception if value cannot be converted. values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]); } if (values.Length == 2) { return new TableLayoutPanelCellPosition(values[0], values[1]); } else { throw new ArgumentException(SR.GetString(SR.TextParseFailedFormat, text, "column, row")); } } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is TableLayoutPanelCellPosition) { TableLayoutPanelCellPosition cellPosition = (TableLayoutPanelCellPosition) value; return new InstanceDescriptor( typeof(TableLayoutPanelCellPosition).GetConstructor(new Type[] {typeof(int), typeof(int)}), new object[] {cellPosition.Column, cellPosition.Row}); } return base.ConvertTo(context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { return new TableLayoutPanelCellPosition( (int)propertyValues["Column"], (int)propertyValues["Row"] ); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(TableLayoutPanelCellPosition), attributes); return props.Sort(new string[] {"Column","Row"}); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; using System.Globalization; [TypeConverterAttribute(typeof(TableLayoutPanelCellPositionTypeConverter))] public struct TableLayoutPanelCellPosition { private int row; private int column; public TableLayoutPanelCellPosition(int column, int row) { if (row < -1) { throw new ArgumentOutOfRangeException("row", SR.GetString(SR.InvalidArgument, "row", (row).ToString(CultureInfo.CurrentCulture))); } if (column < -1) { throw new ArgumentOutOfRangeException("column", SR.GetString(SR.InvalidArgument, "column", (column).ToString(CultureInfo.CurrentCulture))); } this.row = row; this.column = column; } public int Row { get { return row; } set { row = value; } } public int Column { get { return column; } set { column = value; } } public override bool Equals(object other) { if(other is TableLayoutPanelCellPosition) { TableLayoutPanelCellPosition dpeOther = (TableLayoutPanelCellPosition) other; return (dpeOther.row == row && dpeOther.column == column); } return false; } public static bool operator ==(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2) { return p1.Row == p2.Row && p1.Column == p2.Column; } public static bool operator !=(TableLayoutPanelCellPosition p1, TableLayoutPanelCellPosition p2) { return !(p1 == p2); } public override string ToString() { return Column.ToString(CultureInfo.CurrentCulture) + "," + Row.ToString(CultureInfo.CurrentCulture); } public override int GetHashCode() { // VSWhidbey #130081: structs should implement GetHashCode for perf return WindowsFormsUtils.GetCombinedHashCodes( this.row, this.column); } } internal class TableLayoutPanelCellPositionTypeConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string text = ((string)value).Trim(); if (text.Length == 0) { return null; } else { // Parse 2 integer values. // if (culture == null) { culture = CultureInfo.CurrentCulture; } char sep = culture.TextInfo.ListSeparator[0]; string[] tokens = text.Split(new char[] {sep}); int[] values = new int[tokens.Length]; TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); for (int i = 0; i < values.Length; i++) { // Note: ConvertFromString will raise exception if value cannot be converted. values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]); } if (values.Length == 2) { return new TableLayoutPanelCellPosition(values[0], values[1]); } else { throw new ArgumentException(SR.GetString(SR.TextParseFailedFormat, text, "column, row")); } } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is TableLayoutPanelCellPosition) { TableLayoutPanelCellPosition cellPosition = (TableLayoutPanelCellPosition) value; return new InstanceDescriptor( typeof(TableLayoutPanelCellPosition).GetConstructor(new Type[] {typeof(int), typeof(int)}), new object[] {cellPosition.Column, cellPosition.Row}); } return base.ConvertTo(context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { return new TableLayoutPanelCellPosition( (int)propertyValues["Column"], (int)propertyValues["Row"] ); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(TableLayoutPanelCellPosition), attributes); return props.Sort(new string[] {"Column","Row"}); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } // 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
- XmlSignatureManifest.cs
- DbParameterCollectionHelper.cs
- ImageButton.cs
- OleStrCAMarshaler.cs
- ChainedAsyncResult.cs
- ClientTargetCollection.cs
- StagingAreaInputItem.cs
- CodeChecksumPragma.cs
- IPGlobalProperties.cs
- StreamWithDictionary.cs
- ProcessMonitor.cs
- Trace.cs
- MatrixTransform.cs
- RectangleConverter.cs
- StateItem.cs
- ImageListStreamer.cs
- LazyTextWriterCreator.cs
- LocalizationCodeDomSerializer.cs
- Win32PrintDialog.cs
- SByteStorage.cs
- ControllableStoryboardAction.cs
- Types.cs
- ApplicationHost.cs
- PipeSecurity.cs
- MsmqIntegrationReceiveParameters.cs
- TemplateColumn.cs
- PersonalizationStateInfo.cs
- ContractBase.cs
- ParentUndoUnit.cs
- QueuedDeliveryRequirementsMode.cs
- TableAutomationPeer.cs
- UnorderedHashRepartitionStream.cs
- ConfigXmlText.cs
- AccessKeyManager.cs
- CodeConditionStatement.cs
- NumberSubstitution.cs
- IPipelineRuntime.cs
- TransactionFlowAttribute.cs
- SoapAttributeOverrides.cs
- TraceContextRecord.cs
- EventLogPermissionAttribute.cs
- ObjectStorage.cs
- Viewport2DVisual3D.cs
- Literal.cs
- EpmCustomContentWriterNodeData.cs
- FilteredXmlReader.cs
- TextureBrush.cs
- DecoderBestFitFallback.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- WebColorConverter.cs
- NonParentingControl.cs
- SqlReferenceCollection.cs
- SkinBuilder.cs
- ZipIOBlockManager.cs
- SelectionItemPattern.cs
- AnimationClockResource.cs
- ConfigurationCollectionAttribute.cs
- VersionPair.cs
- ReaderWriterLock.cs
- GridViewColumnCollection.cs
- ZipIOBlockManager.cs
- PieceNameHelper.cs
- DeviceContext2.cs
- XXXOnTypeBuilderInstantiation.cs
- StatusBarPanel.cs
- SkinBuilder.cs
- HeaderCollection.cs
- CodeConditionStatement.cs
- WebReferenceCollection.cs
- ScriptManager.cs
- XmlProcessingInstruction.cs
- EditBehavior.cs
- ProviderIncompatibleException.cs
- ItemContainerGenerator.cs
- RegexWorker.cs
- ImageKeyConverter.cs
- ExecutedRoutedEventArgs.cs
- ArrayExtension.cs
- XmlSchemaGroupRef.cs
- LinearQuaternionKeyFrame.cs
- MarginsConverter.cs
- StorageComplexPropertyMapping.cs
- WeakReference.cs
- HtmlFormWrapper.cs
- JsonMessageEncoderFactory.cs
- TypeReference.cs
- Utils.cs
- wgx_exports.cs
- FolderLevelBuildProvider.cs
- ReachPageContentSerializer.cs
- PlainXmlSerializer.cs
- ComponentEvent.cs
- PageThemeParser.cs
- GPPOINT.cs
- HttpGetProtocolImporter.cs
- XmlDeclaration.cs
- PeerPresenceInfo.cs
- diagnosticsswitches.cs
- AppModelKnownContentFactory.cs
- GeneralTransform3D.cs