Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / TreeViewImageKeyConverter.cs / 1 / TreeViewImageKeyConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Collections.Specialized; ////// /// ImageIndexConverter is a class that can be used to convert /// image index values one data type to another. /// public class TreeViewImageKeyConverter : ImageKeyConverter { ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && (value == null)) { return SR.GetString(SR.toStringDefault); } else { string strValue = value as string; if (strValue != null && (strValue.Length == 0)) { return SR.GetString(SR.toStringDefault); } } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using Microsoft.Win32; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Collections.Specialized; ////// /// ImageIndexConverter is a class that can be used to convert /// image index values one data type to another. /// public class TreeViewImageKeyConverter : ImageKeyConverter { ////// /// Converts the given object to another type. The most common types to convert /// are to and from a string object. The default implementation will make a call /// to ToString on the object if the object is valid and if the destination /// type is string. If this cannot convert to the desitnation type, this will /// throw a NotSupportedException. /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && (value == null)) { return SR.GetString(SR.toStringDefault); } else { string strValue = value as string; if (strValue != null && (strValue.Length == 0)) { return SR.GetString(SR.toStringDefault); } } return base.ConvertTo(context, culture, value, destinationType); } } } // 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
- regiisutil.cs
- DataException.cs
- TypedDataSetSchemaImporterExtension.cs
- SynchronizedDisposablePool.cs
- HttpProfileGroupBase.cs
- SmiMetaDataProperty.cs
- DesignTimeVisibleAttribute.cs
- ConfigXmlAttribute.cs
- PopupEventArgs.cs
- DynamicFilter.cs
- TerminateDesigner.cs
- TextRangeSerialization.cs
- XmlSortKeyAccumulator.cs
- RoutedEvent.cs
- DelegateSerializationHolder.cs
- DynamicEndpointElement.cs
- HttpWriter.cs
- Rfc2898DeriveBytes.cs
- HelpEvent.cs
- MouseGestureValueSerializer.cs
- TimerElapsedEvenArgs.cs
- DocumentCollection.cs
- Border.cs
- RightsManagementInformation.cs
- ByteStreamMessage.cs
- LinkConverter.cs
- IdnMapping.cs
- IncrementalHitTester.cs
- OpCodes.cs
- Shape.cs
- DuplicateWaitObjectException.cs
- Assign.cs
- Int64Storage.cs
- VirtualPath.cs
- WebException.cs
- CompositeClientFormatter.cs
- CriticalFinalizerObject.cs
- XmlNodeList.cs
- ConnectionManagementSection.cs
- ValidationResult.cs
- ColumnMap.cs
- ServerIdentity.cs
- SkipStoryboardToFill.cs
- TagPrefixCollection.cs
- WebPartExportVerb.cs
- Int32Converter.cs
- SymDocumentType.cs
- MailHeaderInfo.cs
- EncodingStreamWrapper.cs
- SqlDataSourceFilteringEventArgs.cs
- RTTrackingProfile.cs
- RectangleF.cs
- ColumnClickEvent.cs
- DataGridViewColumnHeaderCell.cs
- SoapSchemaExporter.cs
- _MultipleConnectAsync.cs
- ISFTagAndGuidCache.cs
- ViewStateException.cs
- HtmlInputButton.cs
- StrokeNodeData.cs
- WhitespaceRuleLookup.cs
- MsmqProcessProtocolHandler.cs
- DynamicQueryStringParameter.cs
- SrgsNameValueTag.cs
- ProxySimple.cs
- EndpointAddressAugust2004.cs
- WebDescriptionAttribute.cs
- QilTargetType.cs
- TreeNode.cs
- BaseCodePageEncoding.cs
- Domain.cs
- CollectionExtensions.cs
- XmlNodeList.cs
- ButtonFieldBase.cs
- DataGridViewRowEventArgs.cs
- WriteFileContext.cs
- MergeFailedEvent.cs
- CommonXSendMessage.cs
- SecurityTokenTypes.cs
- InlinedAggregationOperator.cs
- TextEditor.cs
- RichTextBox.cs
- DataGridViewToolTip.cs
- MDIWindowDialog.cs
- PromptStyle.cs
- LayoutDump.cs
- Composition.cs
- ModelVisual3D.cs
- __Filters.cs
- SchemaCollectionPreprocessor.cs
- TypeToStringValueConverter.cs
- InputScopeManager.cs
- TreeViewBindingsEditor.cs
- AccessedThroughPropertyAttribute.cs
- FamilyMap.cs
- ObjectDataSourceStatusEventArgs.cs
- ElementMarkupObject.cs
- DiscoveryClientReferences.cs
- PrimitiveXmlSerializers.cs
- XmlQualifiedName.cs