Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / TreeViewImageKeyConverter.cs / 1305376 / 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
- ValidationErrorCollection.cs
- DivideByZeroException.cs
- XmlCDATASection.cs
- StaticContext.cs
- RunInstallerAttribute.cs
- IssuedSecurityTokenProvider.cs
- IisTraceWebEventProvider.cs
- PtsHost.cs
- Pair.cs
- ColumnPropertiesGroup.cs
- SimpleFileLog.cs
- EventProviderBase.cs
- CookieProtection.cs
- ArrangedElement.cs
- DynamicControlParameter.cs
- UnsafeNativeMethods.cs
- ServiceDocumentFormatter.cs
- QueryExpr.cs
- TypeForwardedToAttribute.cs
- GenericUriParser.cs
- SqlClientMetaDataCollectionNames.cs
- ProfileParameter.cs
- shaperfactoryquerycachekey.cs
- VisualStyleElement.cs
- SuppressMessageAttribute.cs
- PaperSize.cs
- ToolStripHighContrastRenderer.cs
- CatalogZone.cs
- ExceptQueryOperator.cs
- Journal.cs
- ClosableStream.cs
- PrtCap_Reader.cs
- ByteRangeDownloader.cs
- AssemblySettingAttributes.cs
- XmlWriterTraceListener.cs
- OdbcInfoMessageEvent.cs
- DataGridViewAccessibleObject.cs
- WebResourceAttribute.cs
- DataKeyArray.cs
- MatrixAnimationBase.cs
- CodeArrayCreateExpression.cs
- BackgroundFormatInfo.cs
- LayoutEditorPart.cs
- StatusBarAutomationPeer.cs
- ReadOnlyDataSource.cs
- Baml2006ReaderSettings.cs
- CalendarDataBindingHandler.cs
- FlowDocumentFormatter.cs
- XmlElementAttributes.cs
- PrimaryKeyTypeConverter.cs
- HwndKeyboardInputProvider.cs
- NamedPipeChannelListener.cs
- IdnElement.cs
- Util.cs
- DesignTable.cs
- activationcontext.cs
- PaintEvent.cs
- SelectionManager.cs
- QueueAccessMode.cs
- CodeDelegateCreateExpression.cs
- ConfigXmlWhitespace.cs
- QuerySettings.cs
- SqlBinder.cs
- EntityCommand.cs
- VisualStyleRenderer.cs
- TabControlEvent.cs
- SafeFileMapViewHandle.cs
- _IPv6Address.cs
- RectAnimation.cs
- CompilationLock.cs
- LinqDataSourceUpdateEventArgs.cs
- CryptoApi.cs
- CallbackHandler.cs
- TickBar.cs
- Button.cs
- FactoryMaker.cs
- RepeaterItem.cs
- CodeDirectoryCompiler.cs
- ProgressBar.cs
- AsymmetricSecurityBindingElement.cs
- TdsParserSafeHandles.cs
- SymLanguageType.cs
- PieceDirectory.cs
- HttpConfigurationSystem.cs
- CodeTypeParameter.cs
- columnmapfactory.cs
- ListenerElementsCollection.cs
- DiscoveryDocumentSearchPattern.cs
- SelectionItemPattern.cs
- WsdlContractConversionContext.cs
- DataView.cs
- ClientConfigurationHost.cs
- EntityDesignerUtils.cs
- ThicknessAnimationUsingKeyFrames.cs
- GeometryGroup.cs
- Double.cs
- exports.cs
- HMACSHA384.cs
- WindowPattern.cs
- ObjectItemAttributeAssemblyLoader.cs