Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- StorageSetMapping.cs
- AsyncPostBackErrorEventArgs.cs
- HttpDebugHandler.cs
- SelectionBorderGlyph.cs
- NamespaceListProperty.cs
- LineInfo.cs
- WorkflowEnvironment.cs
- _ConnectStream.cs
- TextFormattingConverter.cs
- FieldDescriptor.cs
- ObjectDisposedException.cs
- XmlWrappingReader.cs
- XmlSchemaObject.cs
- ZoneLinkButton.cs
- UnmanagedMemoryStreamWrapper.cs
- ApplicationId.cs
- HostProtectionPermission.cs
- TreeViewImageKeyConverter.cs
- TraceAsyncResult.cs
- AttachedAnnotation.cs
- WindowInteractionStateTracker.cs
- Constraint.cs
- FormatException.cs
- DataGridViewTopLeftHeaderCell.cs
- Graph.cs
- CodeTypeDeclarationCollection.cs
- UserPreferenceChangingEventArgs.cs
- WizardPanelChangingEventArgs.cs
- GenericTextProperties.cs
- FrameSecurityDescriptor.cs
- MexNamedPipeBindingElement.cs
- ParsedAttributeCollection.cs
- DesignerActionPanel.cs
- ClassicBorderDecorator.cs
- SchemaEntity.cs
- DynamicPropertyHolder.cs
- ToolStripItemRenderEventArgs.cs
- Gdiplus.cs
- OdbcConnectionHandle.cs
- RuntimeArgumentHandle.cs
- MultiAsyncResult.cs
- XslUrlEditor.cs
- WebPartManagerInternals.cs
- IPEndPointCollection.cs
- BaseCollection.cs
- IssuedTokenParametersElement.cs
- BitmapPalettes.cs
- MasterPageParser.cs
- StopStoryboard.cs
- ConsumerConnectionPointCollection.cs
- BulletedListEventArgs.cs
- webclient.cs
- DoubleLinkListEnumerator.cs
- CacheRequest.cs
- SetterBase.cs
- XmlSerializableServices.cs
- ECDsa.cs
- RSAOAEPKeyExchangeFormatter.cs
- LocatorManager.cs
- DataBoundControl.cs
- XmlAttributes.cs
- Evaluator.cs
- StrongName.cs
- EdmError.cs
- HttpCachePolicy.cs
- ETagAttribute.cs
- RootDesignerSerializerAttribute.cs
- _UriSyntax.cs
- ActivationArguments.cs
- FieldNameLookup.cs
- ColorTypeConverter.cs
- Size3D.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- DbXmlEnabledProviderManifest.cs
- BaseTransportHeaders.cs
- DesignerTransaction.cs
- XmlUrlResolver.cs
- DocumentPageView.cs
- CqlQuery.cs
- GridViewColumnHeader.cs
- SystemMulticastIPAddressInformation.cs
- SudsParser.cs
- Scripts.cs
- ReceiveSecurityHeader.cs
- SharedStream.cs
- NameValueSectionHandler.cs
- AccessDataSourceView.cs
- TypedReference.cs
- APCustomTypeDescriptor.cs
- ButtonPopupAdapter.cs
- AstTree.cs
- SqlRowUpdatedEvent.cs
- MonitorWrapper.cs
- CryptographicAttribute.cs
- TiffBitmapDecoder.cs
- StylusDevice.cs
- FieldToken.cs
- HitTestParameters3D.cs
- MsmqTransportSecurity.cs
- HtmlEmptyTagControlBuilder.cs