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
- SmiEventSink_DeferedProcessing.cs
- DrawingContextWalker.cs
- Int16.cs
- Serializer.cs
- QueryComponents.cs
- SHA256.cs
- IgnoreFlushAndCloseStream.cs
- Rotation3DKeyFrameCollection.cs
- BlurBitmapEffect.cs
- VarRemapper.cs
- Nullable.cs
- PeerSecurityManager.cs
- Dispatcher.cs
- MenuEventArgs.cs
- Misc.cs
- TraceHandler.cs
- CDSsyncETWBCLProvider.cs
- DBCSCodePageEncoding.cs
- UIElement3DAutomationPeer.cs
- PropertyPushdownHelper.cs
- ContextMenu.cs
- ServiceModelEnumValidator.cs
- ThreadInterruptedException.cs
- CompilerParameters.cs
- Invariant.cs
- xsdvalidator.cs
- TextParagraphProperties.cs
- SqlVisitor.cs
- CorePropertiesFilter.cs
- GACMembershipCondition.cs
- ToolBar.cs
- DiagnosticTraceSource.cs
- RolePrincipal.cs
- WindowsNonControl.cs
- Trustee.cs
- LayoutDump.cs
- Cursors.cs
- DiagnosticTrace.cs
- BitSet.cs
- ElementFactory.cs
- SerializationStore.cs
- Lasso.cs
- BitSet.cs
- LambdaCompiler.Statements.cs
- XmlSchemaComplexType.cs
- ElementAtQueryOperator.cs
- DropShadowBitmapEffect.cs
- LookupBindingPropertiesAttribute.cs
- WebBrowserContainer.cs
- SqlNamer.cs
- peernodeimplementation.cs
- SectionInformation.cs
- ArrangedElementCollection.cs
- TemplatePagerField.cs
- PipeStream.cs
- Zone.cs
- AlternateViewCollection.cs
- FontFaceLayoutInfo.cs
- BooleanProjectedSlot.cs
- X509CertificateCollection.cs
- SubclassTypeValidatorAttribute.cs
- MissingMethodException.cs
- MonthChangedEventArgs.cs
- DataSourceDesigner.cs
- TaiwanLunisolarCalendar.cs
- ColorContextHelper.cs
- XPathMessageContext.cs
- _NTAuthentication.cs
- SspiHelper.cs
- PackagingUtilities.cs
- SqlCacheDependencyDatabaseCollection.cs
- WSHttpSecurityElement.cs
- IsolationInterop.cs
- DbModificationCommandTree.cs
- SecurityState.cs
- CipherData.cs
- DiscoveryClient.cs
- TreeViewCancelEvent.cs
- AlternateViewCollection.cs
- WebReferenceOptions.cs
- ControlUtil.cs
- OracleCommand.cs
- TextDecorationCollectionConverter.cs
- BindToObject.cs
- Shape.cs
- IconBitmapDecoder.cs
- HandledMouseEvent.cs
- PointConverter.cs
- IncrementalReadDecoders.cs
- ProfileEventArgs.cs
- PropertyChangedEventManager.cs
- OleDbTransaction.cs
- ReadOnlyNameValueCollection.cs
- Msmq3PoisonHandler.cs
- ValueQuery.cs
- CustomCredentialPolicy.cs
- DesignColumn.cs
- ContextProperty.cs
- EmbeddedMailObjectCollectionEditor.cs
- DataControlReferenceCollection.cs