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
- HtmlEmptyTagControlBuilder.cs
- JsonFormatReaderGenerator.cs
- StatusBarDesigner.cs
- ReceiveActivityValidator.cs
- DiagnosticsConfigurationHandler.cs
- ControlCollection.cs
- IxmlLineInfo.cs
- RegistryKey.cs
- StatusBarPanelClickEvent.cs
- AdvancedBindingPropertyDescriptor.cs
- FontCacheLogic.cs
- EntityPropertyMappingAttribute.cs
- QueryOperationResponseOfT.cs
- EdmError.cs
- ConvertEvent.cs
- TerminateWorkflow.cs
- TypeSource.cs
- XLinq.cs
- Point3DConverter.cs
- Module.cs
- ConfigXmlElement.cs
- SmtpMail.cs
- CheckedListBox.cs
- ZoomingMessageFilter.cs
- PassportAuthentication.cs
- XslTransformFileEditor.cs
- RSAPKCS1SignatureFormatter.cs
- Shape.cs
- InsufficientMemoryException.cs
- WindowsUpDown.cs
- ThrowHelper.cs
- Resources.Designer.cs
- SoapTransportImporter.cs
- Crc32Helper.cs
- ScrollViewerAutomationPeer.cs
- ActivationServices.cs
- TimeIntervalCollection.cs
- LineSegment.cs
- PathGeometry.cs
- ButtonFieldBase.cs
- dbenumerator.cs
- ReadOnlyCollection.cs
- DataSourceHelper.cs
- X509UI.cs
- SliderAutomationPeer.cs
- StatusBar.cs
- RuleSettingsCollection.cs
- ChildChangedEventArgs.cs
- StringStorage.cs
- SqlNodeAnnotation.cs
- PointHitTestParameters.cs
- MenuTracker.cs
- Formatter.cs
- DataControlCommands.cs
- CqlGenerator.cs
- HtmlTableRowCollection.cs
- CaseStatementSlot.cs
- SelectionPattern.cs
- IPCCacheManager.cs
- ExcludeFromCodeCoverageAttribute.cs
- GlyphCache.cs
- CfgSemanticTag.cs
- Light.cs
- FolderNameEditor.cs
- KeyValuePair.cs
- QueryContinueDragEventArgs.cs
- Scripts.cs
- BamlReader.cs
- ClosableStream.cs
- MachineKeySection.cs
- ModelService.cs
- BooleanFunctions.cs
- SoapIgnoreAttribute.cs
- GridViewColumn.cs
- Floater.cs
- GeometryDrawing.cs
- SynchronizedInputHelper.cs
- X509CertificateCollection.cs
- BitArray.cs
- Region.cs
- FtpWebRequest.cs
- MSAAWinEventWrap.cs
- _BaseOverlappedAsyncResult.cs
- ObjectDataSourceStatusEventArgs.cs
- DuplexChannelFactory.cs
- TextEditorTyping.cs
- Vector.cs
- RuntimeHelpers.cs
- CompositeKey.cs
- LocalFileSettingsProvider.cs
- NamespaceCollection.cs
- FormsAuthenticationModule.cs
- CallbackBehaviorAttribute.cs
- SafeReversePInvokeHandle.cs
- SqlRowUpdatingEvent.cs
- wmiprovider.cs
- SqlCharStream.cs
- QueryHandler.cs
- XmlCharacterData.cs
- FixedSOMSemanticBox.cs