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
- URI.cs
- CharAnimationUsingKeyFrames.cs
- MaterialGroup.cs
- WebPartTransformerAttribute.cs
- TextRangeAdaptor.cs
- DropTarget.cs
- ReferenceSchema.cs
- EnglishPluralizationService.cs
- WebZone.cs
- Claim.cs
- WsatServiceAddress.cs
- BindingMemberInfo.cs
- AdapterUtil.cs
- XPathNavigatorKeyComparer.cs
- BindingEditor.xaml.cs
- MarkerProperties.cs
- WebCategoryAttribute.cs
- MergeFilterQuery.cs
- KeyFrames.cs
- XmlChildNodes.cs
- PathTooLongException.cs
- Speller.cs
- LayoutUtils.cs
- DataBoundControlHelper.cs
- PropertyDescriptorComparer.cs
- PermissionSetTriple.cs
- ObjectSecurity.cs
- COSERVERINFO.cs
- IsolatedStorageFile.cs
- DbTransaction.cs
- LocalValueEnumerator.cs
- FilterUserControlBase.cs
- ExpressionConverter.cs
- BitmapSourceSafeMILHandle.cs
- Int64Storage.cs
- CapabilitiesAssignment.cs
- DataGridViewHitTestInfo.cs
- SmiTypedGetterSetter.cs
- MemberHolder.cs
- OuterGlowBitmapEffect.cs
- ViewStateModeByIdAttribute.cs
- CellCreator.cs
- ServiceDescriptions.cs
- CompilerScope.cs
- WeakReadOnlyCollection.cs
- ExtensionWindowHeader.cs
- IOThreadTimer.cs
- XPathMessageContext.cs
- QuaternionAnimationBase.cs
- SerialErrors.cs
- MimeAnyImporter.cs
- Rect3D.cs
- ApplicationBuildProvider.cs
- List.cs
- DataBindingHandlerAttribute.cs
- SiteMapDataSourceView.cs
- TypedElement.cs
- BrowsableAttribute.cs
- Win32.cs
- LogicalExpr.cs
- PageRanges.cs
- ScriptBehaviorDescriptor.cs
- Int32Rect.cs
- TextRunCacheImp.cs
- SizeAnimationClockResource.cs
- SqlRowUpdatedEvent.cs
- EventMappingSettings.cs
- NativeMethods.cs
- CompilerLocalReference.cs
- RefreshEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- WebBrowserUriTypeConverter.cs
- StateMachineExecutionState.cs
- WSFederationHttpBindingCollectionElement.cs
- OrderedDictionary.cs
- EntityTypeEmitter.cs
- WebPartTransformer.cs
- CodeDomDecompiler.cs
- DirectoryNotFoundException.cs
- ConfigXmlElement.cs
- GenericEnumerator.cs
- VariableDesigner.xaml.cs
- TagPrefixInfo.cs
- Transactions.cs
- FormConverter.cs
- ErrorFormatterPage.cs
- DelegatingTypeDescriptionProvider.cs
- ActiveXSite.cs
- ExpandCollapseProviderWrapper.cs
- DiscoveryProxy.cs
- ThreadNeutralSemaphore.cs
- ReservationNotFoundException.cs
- OLEDB_Util.cs
- NoResizeSelectionBorderGlyph.cs
- DesignerForm.cs
- CapabilitiesPattern.cs
- InterleavedZipPartStream.cs
- IisTraceWebEventProvider.cs
- ToolStripPanelDesigner.cs
- IntegrationExceptionEventArgs.cs