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
- GridViewRow.cs
- XamlHostingConfiguration.cs
- Timer.cs
- COM2Enum.cs
- DnsEndpointIdentity.cs
- DesignerActionService.cs
- MetadataUtilsSmi.cs
- MarshalByValueComponent.cs
- ActivityIdHeader.cs
- CallbackValidator.cs
- SmiRecordBuffer.cs
- MeasureItemEvent.cs
- MILUtilities.cs
- IssuedTokenServiceCredential.cs
- Int16.cs
- BaseCAMarshaler.cs
- WebPartConnectVerb.cs
- PreviewPageInfo.cs
- ListBox.cs
- NumberAction.cs
- BindingCollection.cs
- CommentAction.cs
- DoubleStorage.cs
- ContainerSelectorActiveEvent.cs
- KeyInstance.cs
- Executor.cs
- BatchServiceHost.cs
- DataGridViewCheckBoxColumn.cs
- HtmlObjectListAdapter.cs
- FixedTextView.cs
- _AuthenticationState.cs
- PreviewControlDesigner.cs
- DNS.cs
- HttpPostProtocolReflector.cs
- FindSimilarActivitiesVerb.cs
- Currency.cs
- ProjectionNode.cs
- ListMarkerLine.cs
- XmlReflectionMember.cs
- SqlClientPermission.cs
- ResourceReferenceExpression.cs
- EntityDesignerDataSourceView.cs
- ProfileManager.cs
- Operators.cs
- NameValuePair.cs
- MetadataCollection.cs
- WindowsListViewScroll.cs
- FormViewUpdatedEventArgs.cs
- StylusEditingBehavior.cs
- DataRowView.cs
- URLAttribute.cs
- TextElementEnumerator.cs
- HandoffBehavior.cs
- TextClipboardData.cs
- ToggleProviderWrapper.cs
- ComponentResourceKeyConverter.cs
- KeyConstraint.cs
- DependencyPropertyConverter.cs
- Scene3D.cs
- TargetControlTypeAttribute.cs
- SchemaMerger.cs
- BindingObserver.cs
- UIElement3D.cs
- Freezable.cs
- LexicalChunk.cs
- DocumentReference.cs
- DefaultDiscoveryServiceExtension.cs
- SmtpReplyReaderFactory.cs
- MailDefinition.cs
- COM2PictureConverter.cs
- StandardRuntimeEnumValidatorAttribute.cs
- BCryptHashAlgorithm.cs
- DesignerUtils.cs
- DataGridViewCellConverter.cs
- DataSourceComponent.cs
- ExpiredSecurityTokenException.cs
- ObjectViewQueryResultData.cs
- ZoneButton.cs
- ReflectionHelper.cs
- ServicePointManagerElement.cs
- ComIntegrationManifestGenerator.cs
- HTMLTagNameToTypeMapper.cs
- EventWaitHandleSecurity.cs
- WebPart.cs
- SplitterCancelEvent.cs
- ShadowGlyph.cs
- MetadataArtifactLoader.cs
- CompilerHelpers.cs
- DataObjectFieldAttribute.cs
- FactoryMaker.cs
- FileSystemWatcher.cs
- GlyphRunDrawing.cs
- CardSpacePolicyElement.cs
- ColorAnimationUsingKeyFrames.cs
- MachineKeyConverter.cs
- ObjectView.cs
- ToolStripDropDownItem.cs
- ClickablePoint.cs
- ContainerControl.cs
- Binding.cs