Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- MemberRelationshipService.cs
- BulletedListDesigner.cs
- ScriptControlManager.cs
- TextEditorMouse.cs
- ByteStack.cs
- smtppermission.cs
- GeneralTransform2DTo3D.cs
- ParameterReplacerVisitor.cs
- XmlNotation.cs
- DirectoryInfo.cs
- StatusBarAutomationPeer.cs
- PropertyGridView.cs
- ObjectHelper.cs
- IBuiltInEvidence.cs
- BamlRecordReader.cs
- X509CertificateValidator.cs
- DataGridViewLayoutData.cs
- ResourcesChangeInfo.cs
- DataSetFieldSchema.cs
- ThemeableAttribute.cs
- CqlWriter.cs
- _BufferOffsetSize.cs
- CredentialCache.cs
- KeyValuePair.cs
- AuthenticationServiceManager.cs
- ListDesigner.cs
- Workspace.cs
- CachedFontFamily.cs
- XmlSchemaCollection.cs
- WindowsTooltip.cs
- OdbcParameterCollection.cs
- BinarySecretKeyIdentifierClause.cs
- DataMemberAttribute.cs
- X509Certificate2Collection.cs
- RequestCacheValidator.cs
- ControlTemplate.cs
- ListGeneralPage.cs
- TreeNode.cs
- RuntimeHandles.cs
- Msec.cs
- ReceiveContent.cs
- UIHelper.cs
- DataStreams.cs
- RuleInfoComparer.cs
- PathGeometry.cs
- DiscardableAttribute.cs
- RemotingConfigParser.cs
- Base64Encoder.cs
- CopyNamespacesAction.cs
- TableCellCollection.cs
- SQLDoubleStorage.cs
- PingOptions.cs
- FormatConvertedBitmap.cs
- TaskFormBase.cs
- PreProcessInputEventArgs.cs
- SQLChars.cs
- StateManagedCollection.cs
- Expr.cs
- InputLanguageEventArgs.cs
- SqlResolver.cs
- _Rfc2616CacheValidators.cs
- Rect.cs
- CommandLibraryHelper.cs
- ClientSideQueueItem.cs
- ReflectTypeDescriptionProvider.cs
- DependencyObjectProvider.cs
- VoiceChangeEventArgs.cs
- Pool.cs
- SaveFileDialog.cs
- HierarchicalDataBoundControlAdapter.cs
- WindowsToolbarAsMenu.cs
- ConnectionManager.cs
- DeviceContext2.cs
- FormatConvertedBitmap.cs
- FontFamilyConverter.cs
- BinaryReader.cs
- AutomationInteropProvider.cs
- DatatypeImplementation.cs
- TextTrailingCharacterEllipsis.cs
- X509CertificateCollection.cs
- CompilerLocalReference.cs
- ProcessHostFactoryHelper.cs
- HandlerFactoryWrapper.cs
- ForceCopyBuildProvider.cs
- DataKeyArray.cs
- RelatedPropertyManager.cs
- HMACSHA512.cs
- XmlComplianceUtil.cs
- ConfigurationManagerHelperFactory.cs
- DynamicValueConverter.cs
- MimeTypeMapper.cs
- XmlDesigner.cs
- Image.cs
- UndirectedGraph.cs
- UIPropertyMetadata.cs
- Operand.cs
- XPathNavigatorReader.cs
- ScrollProperties.cs
- BulletedList.cs
- ResetableIterator.cs