Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- ProtocolsSection.cs
- Line.cs
- ConfigXmlElement.cs
- ListViewCancelEventArgs.cs
- CompositeScriptReference.cs
- XmlUnspecifiedAttribute.cs
- ContourSegment.cs
- StyleHelper.cs
- QueryableDataSource.cs
- OleDbEnumerator.cs
- BulletedListEventArgs.cs
- FieldAccessException.cs
- SchemaElementLookUpTable.cs
- Hex.cs
- DataPagerCommandEventArgs.cs
- AuthenticationModulesSection.cs
- PropertyValueChangedEvent.cs
- PropertyRecord.cs
- RoleManagerSection.cs
- MethodMessage.cs
- ReachDocumentReferenceCollectionSerializerAsync.cs
- DefaultAuthorizationContext.cs
- SafeSecurityHandles.cs
- XmlSchemaExternal.cs
- DetailsViewInsertEventArgs.cs
- BuildManagerHost.cs
- ProcessThread.cs
- EntryWrittenEventArgs.cs
- util.cs
- ReadOnlyDataSourceView.cs
- PageCodeDomTreeGenerator.cs
- MethodRental.cs
- ContentPlaceHolder.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- EncodingFallbackAwareXmlTextWriter.cs
- ConnectionDemuxer.cs
- X509Chain.cs
- StoreItemCollection.cs
- TypeValidationEventArgs.cs
- XmlDataProvider.cs
- PageCopyCount.cs
- MultiSelectRootGridEntry.cs
- ListViewPagedDataSource.cs
- PageContentAsyncResult.cs
- WCFServiceClientProxyGenerator.cs
- CachedBitmap.cs
- Convert.cs
- UnmanagedHandle.cs
- __TransparentProxy.cs
- SqlMethodAttribute.cs
- PointConverter.cs
- ImplicitInputBrush.cs
- OptionUsage.cs
- MsdtcClusterUtils.cs
- SiteIdentityPermission.cs
- CommandDesigner.cs
- ToolStripItemRenderEventArgs.cs
- InternalControlCollection.cs
- RewritingProcessor.cs
- EventTask.cs
- FontFaceLayoutInfo.cs
- DCSafeHandle.cs
- ProtocolViolationException.cs
- RectangleHotSpot.cs
- ParenthesizePropertyNameAttribute.cs
- OperatorExpressions.cs
- HuffmanTree.cs
- FutureFactory.cs
- TouchDevice.cs
- FixedSOMImage.cs
- TableCellCollection.cs
- GenericTypeParameterConverter.cs
- Baml2006Reader.cs
- ReachPrintTicketSerializerAsync.cs
- SoapSchemaMember.cs
- SecurityState.cs
- TraceContext.cs
- PeerTransportListenAddressValidator.cs
- AnnotationComponentManager.cs
- Formatter.cs
- CodeArgumentReferenceExpression.cs
- DeploymentExceptionMapper.cs
- ServiceContractViewControl.cs
- SchemaManager.cs
- MobilePage.cs
- PingReply.cs
- TextEditorParagraphs.cs
- BaseCAMarshaler.cs
- ImageUrlEditor.cs
- HttpServerProtocol.cs
- DesignerForm.cs
- SqlLiftIndependentRowExpressions.cs
- AttributeUsageAttribute.cs
- EffectiveValueEntry.cs
- ListViewDataItem.cs
- MethodImplAttribute.cs
- ByteStreamMessageEncoder.cs
- SqlDeflator.cs
- RelatedImageListAttribute.cs
- DataServiceQuery.cs