Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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. // //----------------------------------------------------------------------------- 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
- DeferredSelectedIndexReference.cs
- XPathAncestorQuery.cs
- RedirectionProxy.cs
- XPathNodePointer.cs
- CharConverter.cs
- RtfToXamlLexer.cs
- TemplatedAdorner.cs
- DrawingDrawingContext.cs
- SerializerWriterEventHandlers.cs
- NamedElement.cs
- PopOutPanel.cs
- RectAnimationUsingKeyFrames.cs
- CallbackBehaviorAttribute.cs
- TextCompositionEventArgs.cs
- NodeFunctions.cs
- DetailsViewRowCollection.cs
- ConfigUtil.cs
- URLBuilder.cs
- ControlIdConverter.cs
- DesignTimeTemplateParser.cs
- SQlBooleanStorage.cs
- ImageCodecInfoPrivate.cs
- Row.cs
- SqlCacheDependencyDatabase.cs
- SecurityPermission.cs
- Soap.cs
- ListViewGroupItemCollection.cs
- RemotingAttributes.cs
- PopupEventArgs.cs
- SmtpCommands.cs
- KeyboardNavigation.cs
- BamlStream.cs
- DataFormats.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- TextHidden.cs
- DataGridViewHeaderCell.cs
- TextProviderWrapper.cs
- StylusLogic.cs
- XXXInfos.cs
- HttpValueCollection.cs
- ConfigUtil.cs
- complextypematerializer.cs
- TaskHelper.cs
- DataControlPagerLinkButton.cs
- TableCell.cs
- DeviceSpecificChoice.cs
- TrailingSpaceComparer.cs
- WebEventCodes.cs
- SqlConnectionManager.cs
- XmlSchemaInferenceException.cs
- FrameworkContentElement.cs
- TextProperties.cs
- BaseValidator.cs
- WriteStateInfoBase.cs
- InheritanceAttribute.cs
- ErrorFormatter.cs
- GridViewRowCollection.cs
- PeerNameRegistration.cs
- Native.cs
- ReflectPropertyDescriptor.cs
- AuthorizationContext.cs
- XmlAutoDetectWriter.cs
- ContourSegment.cs
- XmlAtomicValue.cs
- MinMaxParagraphWidth.cs
- MatrixTransform.cs
- IsolatedStorageFileStream.cs
- WebBrowserBase.cs
- RegexFCD.cs
- PeerApplicationLaunchInfo.cs
- Bold.cs
- XPathDescendantIterator.cs
- GlyphRunDrawing.cs
- SrgsOneOf.cs
- FunctionGenerator.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- KeyedCollection.cs
- InsufficientMemoryException.cs
- PackageProperties.cs
- Attributes.cs
- PerformanceCounterPermissionAttribute.cs
- ScriptMethodAttribute.cs
- SchemaTableColumn.cs
- ImageButton.cs
- AdRotator.cs
- ScopedKnownTypes.cs
- WebResourceAttribute.cs
- FlowPosition.cs
- OAVariantLib.cs
- ProfileWorkflowElement.cs
- COM2PropertyDescriptor.cs
- HostedHttpRequestAsyncResult.cs
- SynchronizedDispatch.cs
- LineServicesRun.cs
- TimerElapsedEvenArgs.cs
- OperationResponse.cs
- PhysicalAddress.cs
- PoisonMessageException.cs
- TreeNodeCollection.cs
- ReliableDuplexSessionChannel.cs