Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ServerValidateEventArgs.cs
- _ChunkParse.cs
- CommonRemoteMemoryBlock.cs
- VisualTreeHelper.cs
- HiddenFieldPageStatePersister.cs
- PixelShader.cs
- TerminatorSinks.cs
- DataGridPageChangedEventArgs.cs
- WindowsImpersonationContext.cs
- FixedPage.cs
- XmlSchemaValidator.cs
- EntityClientCacheEntry.cs
- FacetDescriptionElement.cs
- _ConnectStream.cs
- WebPartEditorOkVerb.cs
- ObjectTag.cs
- TimeSpanMinutesConverter.cs
- ErrorStyle.cs
- EventBindingService.cs
- TransactionManager.cs
- PropertyTabChangedEvent.cs
- DataGridViewCellEventArgs.cs
- PauseStoryboard.cs
- DuplicateWaitObjectException.cs
- XslNumber.cs
- EventLogPermissionEntry.cs
- FactoryRecord.cs
- SqlCachedBuffer.cs
- ProfileGroupSettings.cs
- TextEffectResolver.cs
- TraceUtils.cs
- SQLSingleStorage.cs
- AttributeCollection.cs
- LiteralControl.cs
- Point3DAnimation.cs
- TdsParameterSetter.cs
- ComponentResourceKey.cs
- PointConverter.cs
- ZipFileInfo.cs
- XmlSchemaNotation.cs
- StubHelpers.cs
- RowBinding.cs
- RemotingException.cs
- Facet.cs
- SyndicationItem.cs
- Set.cs
- SQLByteStorage.cs
- HttpContextServiceHost.cs
- ZipArchive.cs
- ToolStripContainer.cs
- CodeTypeMember.cs
- ThicknessConverter.cs
- IfJoinedCondition.cs
- CodeDomSerializerBase.cs
- ListChunk.cs
- DuplexSecurityProtocolFactory.cs
- ExpressionVisitorHelpers.cs
- DNS.cs
- SafeNativeMethods.cs
- uribuilder.cs
- CacheRequest.cs
- EventLogPermissionAttribute.cs
- UriSectionReader.cs
- ValueOfAction.cs
- TextBoxBase.cs
- HtmlTableCellCollection.cs
- XmlSchemaIdentityConstraint.cs
- TableRow.cs
- UnsafeNativeMethods.cs
- SHA256Managed.cs
- TaskForm.cs
- WinEventTracker.cs
- SqlConnectionStringBuilder.cs
- SerializationHelper.cs
- _StreamFramer.cs
- ClientSettingsProvider.cs
- FileChangesMonitor.cs
- SessionEndingEventArgs.cs
- Win32SafeHandles.cs
- ByteAnimationBase.cs
- MailMessageEventArgs.cs
- ConnectionManagementElementCollection.cs
- TextTreeTextElementNode.cs
- ToolTip.cs
- COM2PropertyPageUITypeConverter.cs
- CompilerInfo.cs
- IncrementalHitTester.cs
- SystemIcmpV6Statistics.cs
- newinstructionaction.cs
- ThreadSafeList.cs
- ItemList.cs
- ServiceOperationInvoker.cs
- AssemblyName.cs
- ConditionChanges.cs
- _DigestClient.cs
- Font.cs
- NoResizeSelectionBorderGlyph.cs
- DesigntimeLicenseContext.cs
- XamlTemplateSerializer.cs
- FrameworkReadOnlyPropertyMetadata.cs