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
- RequestTimeoutManager.cs
- GifBitmapEncoder.cs
- KeyboardDevice.cs
- XmlSchemaGroupRef.cs
- ReverseInheritProperty.cs
- XamlPointCollectionSerializer.cs
- ProjectedSlot.cs
- ScrollViewerAutomationPeer.cs
- NativeMethods.cs
- ListManagerBindingsCollection.cs
- XmlSchemaValidationException.cs
- AuthorizationSection.cs
- EntityStoreSchemaGenerator.cs
- DataBindEngine.cs
- JavaScriptObjectDeserializer.cs
- SevenBitStream.cs
- Validator.cs
- MultiBindingExpression.cs
- VariantWrapper.cs
- ImageCodecInfoPrivate.cs
- Int32AnimationBase.cs
- NameGenerator.cs
- CultureInfo.cs
- MailWriter.cs
- CompilerWrapper.cs
- XmlEventCache.cs
- TreeBuilder.cs
- FolderBrowserDialogDesigner.cs
- hresults.cs
- CellTreeNode.cs
- Privilege.cs
- DatagridviewDisplayedBandsData.cs
- safePerfProviderHandle.cs
- XmlDocumentSchema.cs
- StylusPointCollection.cs
- NetStream.cs
- SmtpCommands.cs
- Dynamic.cs
- FileCodeGroup.cs
- _ProxyRegBlob.cs
- DefaultSerializationProviderAttribute.cs
- CharacterBufferReference.cs
- Cursor.cs
- DependencyObject.cs
- TimerElapsedEvenArgs.cs
- BindingMemberInfo.cs
- IPGlobalProperties.cs
- FontWeightConverter.cs
- ApplicationContext.cs
- MergePropertyDescriptor.cs
- ProfileEventArgs.cs
- DataGridCellEditEndingEventArgs.cs
- EdmItemCollection.cs
- StubHelpers.cs
- RtType.cs
- HttpListenerPrefixCollection.cs
- SqlCacheDependencyDatabase.cs
- ACE.cs
- SqlFileStream.cs
- AssemblySettingAttributes.cs
- PermissionSet.cs
- EventLogPermissionAttribute.cs
- Border.cs
- ProcessThread.cs
- ProgressBarAutomationPeer.cs
- Error.cs
- BitmapEffectGroup.cs
- TemplateKeyConverter.cs
- Storyboard.cs
- RepeatButtonAutomationPeer.cs
- CmsInterop.cs
- SwitchLevelAttribute.cs
- localization.cs
- Span.cs
- loginstatus.cs
- _NestedSingleAsyncResult.cs
- PenLineJoinValidation.cs
- ConnectionPoint.cs
- WCFBuildProvider.cs
- SettingsProperty.cs
- SplitterCancelEvent.cs
- PeerCustomResolverSettings.cs
- TextElement.cs
- SafeHandle.cs
- ListMarkerLine.cs
- LifetimeServices.cs
- TreeViewItemAutomationPeer.cs
- NumberFormatter.cs
- ComplexObject.cs
- CharacterString.cs
- WebPartConnectionsCancelEventArgs.cs
- InvalidBodyAccessException.cs
- SafePEFileHandle.cs
- KoreanCalendar.cs
- InputChannelBinder.cs
- Lock.cs
- LiteralTextParser.cs
- GatewayIPAddressInformationCollection.cs
- RegistryKey.cs
- DataGridViewTextBoxEditingControl.cs