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
- ConfigPathUtility.cs
- ColumnWidthChangedEvent.cs
- LinkLabel.cs
- ArraySubsetEnumerator.cs
- AutomationElementIdentifiers.cs
- BufferAllocator.cs
- DrawingContextWalker.cs
- DataColumnPropertyDescriptor.cs
- TemplateControlBuildProvider.cs
- FormViewPagerRow.cs
- StringFormat.cs
- XmlSchemaValidator.cs
- DataGridLength.cs
- AttachmentService.cs
- PaperSize.cs
- TokenBasedSet.cs
- UrlPropertyAttribute.cs
- FieldBuilder.cs
- SimpleWorkerRequest.cs
- FtpRequestCacheValidator.cs
- DoubleAnimationUsingPath.cs
- RubberbandSelector.cs
- BatchWriter.cs
- BrowserCapabilitiesFactoryBase.cs
- Filter.cs
- SqlReorderer.cs
- PackageRelationshipSelector.cs
- AnchorEditor.cs
- RegistryKey.cs
- SystemThemeKey.cs
- BamlTreeUpdater.cs
- DiagnosticTrace.cs
- QuotedStringFormatReader.cs
- XmlQueryContext.cs
- Set.cs
- UserControl.cs
- _BaseOverlappedAsyncResult.cs
- StyleCollection.cs
- EncoderFallback.cs
- PopupRootAutomationPeer.cs
- XmlNodeChangedEventArgs.cs
- SqlDataSourceStatusEventArgs.cs
- Label.cs
- InterleavedZipPartStream.cs
- BaseInfoTable.cs
- DecoderExceptionFallback.cs
- Block.cs
- InkCanvasSelectionAdorner.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- xsdvalidator.cs
- DesignTable.cs
- PocoEntityKeyStrategy.cs
- StorageModelBuildProvider.cs
- DataGridViewHeaderCell.cs
- TextRunProperties.cs
- RadioButtonFlatAdapter.cs
- Rect3DValueSerializer.cs
- ScrollBarRenderer.cs
- ClrProviderManifest.cs
- WeakReference.cs
- InkCanvasInnerCanvas.cs
- ApplicationSettingsBase.cs
- COM2IDispatchConverter.cs
- CodeEntryPointMethod.cs
- MembershipSection.cs
- DnsEndpointIdentity.cs
- Mapping.cs
- MultiView.cs
- SqlTriggerContext.cs
- DrawItemEvent.cs
- PropertyAccessVisitor.cs
- PartialList.cs
- ColumnPropertiesGroup.cs
- CodeComment.cs
- Rijndael.cs
- EUCJPEncoding.cs
- MembershipSection.cs
- FileUpload.cs
- codemethodreferenceexpression.cs
- TextViewBase.cs
- SqlServer2KCompatibilityAnnotation.cs
- ConfigXmlDocument.cs
- ZipIOExtraField.cs
- MetadataUtilsSmi.cs
- MonitoringDescriptionAttribute.cs
- TraceSection.cs
- PointConverter.cs
- TrustLevelCollection.cs
- RawStylusSystemGestureInputReport.cs
- WebEventTraceProvider.cs
- HtmlTernaryTree.cs
- MetaForeignKeyColumn.cs
- CharacterHit.cs
- FlowLayoutPanel.cs
- SystemKeyConverter.cs
- XPathPatternBuilder.cs
- MimeFormReflector.cs
- MembershipPasswordException.cs
- EntityViewGenerator.cs
- XmlSerializerVersionAttribute.cs