Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2ColorConverter.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BaseCollection.cs
- PropertyChangeTracker.cs
- ContentPropertyAttribute.cs
- InsufficientMemoryException.cs
- ManifestBasedResourceGroveler.cs
- HMACRIPEMD160.cs
- Label.cs
- ResizeGrip.cs
- InvokePatternIdentifiers.cs
- XmlSchemaSearchPattern.cs
- EntitySet.cs
- NetNamedPipeBindingCollectionElement.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- HWStack.cs
- RoutedEvent.cs
- HtmlTextBoxAdapter.cs
- LiteralSubsegment.cs
- ProxyWebPartConnectionCollection.cs
- TextControl.cs
- MergeFilterQuery.cs
- _BaseOverlappedAsyncResult.cs
- IriParsingElement.cs
- MemberRelationshipService.cs
- KeyPullup.cs
- RequestCacheManager.cs
- DetailsViewPagerRow.cs
- AuthenticationSection.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- FindCompletedEventArgs.cs
- ProviderIncompatibleException.cs
- SimpleWorkerRequest.cs
- Matrix.cs
- ProtectedConfiguration.cs
- ArgumentElement.cs
- LoginUtil.cs
- EventTrigger.cs
- EmptyEnumerator.cs
- TextBoxDesigner.cs
- XmlDataCollection.cs
- LoginAutoFormat.cs
- TransformCryptoHandle.cs
- Soap.cs
- HttpVersion.cs
- HttpApplicationFactory.cs
- DataGridLength.cs
- Expression.cs
- ItemsControlAutomationPeer.cs
- Site.cs
- IIS7ConfigurationLoader.cs
- VectorCollection.cs
- IisTraceListener.cs
- RegexTypeEditor.cs
- InheritanceContextHelper.cs
- DesignParameter.cs
- ComPersistableTypeElement.cs
- XPathScanner.cs
- SkipQueryOptionExpression.cs
- CopyAction.cs
- TabControlEvent.cs
- String.cs
- Avt.cs
- UpDownEvent.cs
- CanonicalizationDriver.cs
- DataObjectMethodAttribute.cs
- TrustManagerPromptUI.cs
- ApplicationFileCodeDomTreeGenerator.cs
- XmlLoader.cs
- BitStream.cs
- GeometryHitTestResult.cs
- XmlBinaryReader.cs
- ToolBarButtonClickEvent.cs
- DiffuseMaterial.cs
- Rijndael.cs
- SignatureGenerator.cs
- StreamWriter.cs
- DescendantBaseQuery.cs
- ImpersonateTokenRef.cs
- SettingsPropertyValueCollection.cs
- ClientProxyGenerator.cs
- Timer.cs
- ServiceReference.cs
- X509Certificate2.cs
- VisualStyleInformation.cs
- UserControlCodeDomTreeGenerator.cs
- Size3DConverter.cs
- Expression.cs
- ToolStripSystemRenderer.cs
- GridLength.cs
- TextSelection.cs
- XmlNodeChangedEventArgs.cs
- TextContainerChangeEventArgs.cs
- DataControlFieldCollection.cs
- HttpResponse.cs
- WebServiceHandlerFactory.cs
- CanonicalFontFamilyReference.cs
- BehaviorService.cs
- MethodBody.cs
- Message.cs
- SqlXml.cs
- PlanCompilerUtil.cs