Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2ColorConverter.cs / 1 / COM2ColorConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ComponentModel.Com2Interop { using System.Runtime.Serialization.Formatters; using System.ComponentModel; using System.Diagnostics; using System; using System.Drawing; using System.Collections; using Microsoft.Win32; ////// /// This class maps an OLE_COLOR to a managed Color editor. /// internal class Com2ColorConverter : Com2DataTypeToManagedDataTypeConverter{ ////// /// Returns the managed type that this editor maps the property type to. /// public override Type ManagedType{ get{ return typeof(Color); } } ////// /// Converts the native value into a managed value /// public override object ConvertNativeToManaged(object nativeValue, Com2PropertyDescriptor pd){ object baseValue = nativeValue; int intVal = 0; // get the integer value out of the native... // if (nativeValue is UInt32){ intVal = (int)(UInt32)nativeValue; } else if (nativeValue is Int32){ intVal = (int)nativeValue; } return ColorTranslator.FromOle(intVal); } ////// /// Converts the managed value into a native value /// public override object ConvertManagedToNative(object managedValue, Com2PropertyDescriptor pd, ref bool cancelSet){ // don't cancel the set cancelSet = false; // we default to black. // if (managedValue == null){ managedValue = Color.Black; } if (managedValue is Color){ return ColorTranslator.ToOle(((Color)managedValue)); } Debug.Fail("Don't know how to set type:" + managedValue.GetType().Name); return 0; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObjectStorage.cs
- URI.cs
- ExceptionHelpers.cs
- ViewValidator.cs
- HttpModuleCollection.cs
- ThaiBuddhistCalendar.cs
- WS2007FederationHttpBindingCollectionElement.cs
- ConnectionPool.cs
- ContextTokenTypeConverter.cs
- AssertHelper.cs
- ReachFixedPageSerializer.cs
- PageVisual.cs
- SizeConverter.cs
- EventProperty.cs
- DataGridViewLinkCell.cs
- CheckPair.cs
- PageContentAsyncResult.cs
- MatrixAnimationBase.cs
- MediaTimeline.cs
- ListParagraph.cs
- FlowLayoutPanelDesigner.cs
- XmlSchemaFacet.cs
- BinaryObjectReader.cs
- CardSpacePolicyElement.cs
- CheckBoxStandardAdapter.cs
- XPathDocumentIterator.cs
- SchemaCollectionCompiler.cs
- Char.cs
- Encoding.cs
- AbsoluteQuery.cs
- SafeCoTaskMem.cs
- VisualStyleInformation.cs
- GlobalizationSection.cs
- DayRenderEvent.cs
- HtmlElementEventArgs.cs
- InfocardInteractiveChannelInitializer.cs
- SyncOperationState.cs
- CommunicationObjectManager.cs
- MetadataArtifactLoaderResource.cs
- DocumentDesigner.cs
- SmtpFailedRecipientException.cs
- OdbcHandle.cs
- TypeContext.cs
- DataRelationCollection.cs
- PropertyValue.cs
- ForEachAction.cs
- RefExpr.cs
- CAGDesigner.cs
- XslCompiledTransform.cs
- SqlCacheDependencySection.cs
- SettingsPropertyValue.cs
- ClipboardData.cs
- _UriSyntax.cs
- ConfigurationProperty.cs
- X509CertificateRecipientClientCredential.cs
- StreamGeometry.cs
- ModelFunction.cs
- SqlTrackingService.cs
- ReadOnlyPropertyMetadata.cs
- SqlBinder.cs
- SqlUnionizer.cs
- SqlDataSourceConfigureSortForm.cs
- LinearGradientBrush.cs
- keycontainerpermission.cs
- Switch.cs
- Privilege.cs
- IPipelineRuntime.cs
- MimePart.cs
- PresentationTraceSources.cs
- UInt32Converter.cs
- WindowsRichEditRange.cs
- GeneralTransform3DCollection.cs
- UmAlQuraCalendar.cs
- Zone.cs
- InstanceCreationEditor.cs
- InheritanceAttribute.cs
- ParallelTimeline.cs
- CopyOfAction.cs
- InfocardClientCredentials.cs
- MSG.cs
- ApplicationDirectory.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- LogicalTreeHelper.cs
- FormCollection.cs
- Dynamic.cs
- XmlCharCheckingReader.cs
- DecimalAnimation.cs
- WsatEtwTraceListener.cs
- GiveFeedbackEvent.cs
- GuidTagList.cs
- RecognizerInfo.cs
- InterleavedZipPartStream.cs
- SingleKeyFrameCollection.cs
- ImageButton.cs
- WindowHideOrCloseTracker.cs
- Pen.cs
- AttributeSetAction.cs
- DefaultHttpHandler.cs
- SqlUtils.cs
- GridView.cs