Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / TreeViewImageKeyConverter.cs / 1305376 / 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
- XmlWrappingReader.cs
- MultipleViewProviderWrapper.cs
- OdbcDataReader.cs
- ThreadExceptionDialog.cs
- SerializationInfoEnumerator.cs
- MultipleCopiesCollection.cs
- DefaultExpressionVisitor.cs
- FlowDocumentView.cs
- BooleanProjectedSlot.cs
- ClaimTypeElementCollection.cs
- sqlnorm.cs
- XmlIncludeAttribute.cs
- DataShape.cs
- TextEncodedRawTextWriter.cs
- XmlElementList.cs
- SimpleMailWebEventProvider.cs
- Win32PrintDialog.cs
- NameValueConfigurationElement.cs
- LazyInitializer.cs
- CodeLabeledStatement.cs
- HashCodeCombiner.cs
- __ComObject.cs
- DataColumnCollection.cs
- DrawingBrush.cs
- HttpVersion.cs
- DataGridViewComboBoxCell.cs
- ArrayExtension.cs
- WebPartZoneBaseDesigner.cs
- ChooseAction.cs
- CompilerErrorCollection.cs
- ObjectStateFormatter.cs
- GetPageNumberCompletedEventArgs.cs
- UrlParameterReader.cs
- InputScope.cs
- DesignerSerializerAttribute.cs
- PageContentCollection.cs
- ACE.cs
- RemoteWebConfigurationHost.cs
- DEREncoding.cs
- ConnectionPoolManager.cs
- Condition.cs
- DesignerTextWriter.cs
- CommandArguments.cs
- Debug.cs
- GreenMethods.cs
- TracedNativeMethods.cs
- StringTraceRecord.cs
- DataControlPagerLinkButton.cs
- TagMapCollection.cs
- SelectionEditor.cs
- BigIntegerStorage.cs
- InvalidCastException.cs
- BitmapInitialize.cs
- TypeBuilder.cs
- ClientTargetSection.cs
- IPGlobalProperties.cs
- SvcMapFileSerializer.cs
- InvokeWebService.cs
- IMembershipProvider.cs
- BindToObject.cs
- SmiContext.cs
- RootBrowserWindowAutomationPeer.cs
- SafeNativeMethods.cs
- MasterPageBuildProvider.cs
- NetNamedPipeSecurityMode.cs
- DataGridViewComboBoxCell.cs
- WindowAutomationPeer.cs
- ProcessModelInfo.cs
- SafeFileMapViewHandle.cs
- DBCommandBuilder.cs
- SimpleType.cs
- DbMetaDataColumnNames.cs
- validationstate.cs
- CatalogPart.cs
- StringValidatorAttribute.cs
- ScriptResourceAttribute.cs
- QilBinary.cs
- UpdateTracker.cs
- FormatVersion.cs
- SiteMapNode.cs
- configsystem.cs
- DataGridViewRowConverter.cs
- XmlSchemaAttributeGroupRef.cs
- SmiTypedGetterSetter.cs
- sqlstateclientmanager.cs
- MulticastNotSupportedException.cs
- NonVisualControlAttribute.cs
- StorageSetMapping.cs
- IndependentAnimationStorage.cs
- PrimitiveXmlSerializers.cs
- StrokeFIndices.cs
- TargetConverter.cs
- EndpointDiscoveryMetadata.cs
- Tag.cs
- WebBrowsableAttribute.cs
- HttpStreamMessageEncoderFactory.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- SectionRecord.cs
- Screen.cs
- ObjectItemLoadingSessionData.cs