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
- MulticastIPAddressInformationCollection.cs
- WebHttpElement.cs
- LabelEditEvent.cs
- CheckBoxAutomationPeer.cs
- BindableAttribute.cs
- QilFunction.cs
- UIElementPropertyUndoUnit.cs
- ListViewContainer.cs
- LinearGradientBrush.cs
- OdbcEnvironmentHandle.cs
- CodeNamespaceImportCollection.cs
- StylusOverProperty.cs
- UIElement3DAutomationPeer.cs
- GlyphInfoList.cs
- SimpleModelProvider.cs
- X509SubjectKeyIdentifierClause.cs
- UnmanagedMarshal.cs
- Message.cs
- _NetRes.cs
- WindowProviderWrapper.cs
- FrameworkContentElement.cs
- StreamSecurityUpgradeAcceptor.cs
- Duration.cs
- translator.cs
- FloatMinMaxAggregationOperator.cs
- Boolean.cs
- SqlReferenceCollection.cs
- _NestedSingleAsyncResult.cs
- FlowPanelDesigner.cs
- BaseTreeIterator.cs
- ExpressionList.cs
- ParseNumbers.cs
- ComPlusTypeValidator.cs
- UnaryQueryOperator.cs
- SpanIndex.cs
- PartialCachingAttribute.cs
- MenuItemBinding.cs
- NumberFormatter.cs
- XXXOnTypeBuilderInstantiation.cs
- Util.cs
- SymDocumentType.cs
- Stroke.cs
- PropertyMappingExceptionEventArgs.cs
- WebPartConnectVerb.cs
- MailAddressCollection.cs
- SettingsPropertyValueCollection.cs
- TaskCanceledException.cs
- BinaryReader.cs
- BitmapEffectState.cs
- Attributes.cs
- dbdatarecord.cs
- TransferRequestHandler.cs
- SystemIdentity.cs
- InteropAutomationProvider.cs
- URLMembershipCondition.cs
- PocoEntityKeyStrategy.cs
- IncrementalReadDecoders.cs
- WindowShowOrOpenTracker.cs
- MemoryRecordBuffer.cs
- ClientBuildManager.cs
- TemplateBuilder.cs
- CodeMethodInvokeExpression.cs
- ProcessStartInfo.cs
- CustomCredentialPolicy.cs
- DetailsViewPagerRow.cs
- DataRelationCollection.cs
- MarkupCompilePass2.cs
- MissingMethodException.cs
- WebEvents.cs
- ModelFunctionTypeElement.cs
- XamlFxTrace.cs
- DbConnectionHelper.cs
- Fonts.cs
- MediaSystem.cs
- Control.cs
- NotSupportedException.cs
- HttpException.cs
- BitmapDownload.cs
- FillErrorEventArgs.cs
- BypassElement.cs
- DataGridViewCellPaintingEventArgs.cs
- SimplePropertyEntry.cs
- SafeUserTokenHandle.cs
- DbLambda.cs
- DataRecordInfo.cs
- PermissionAttributes.cs
- Repeater.cs
- TextTreeTextBlock.cs
- SecurityPermission.cs
- Visual3D.cs
- MessageEncodingBindingElement.cs
- DataStorage.cs
- PropertyChangedEventArgs.cs
- FontStyle.cs
- ComPersistableTypeElementCollection.cs
- SqlNamer.cs
- WindowsSpinner.cs
- Claim.cs
- CodeVariableDeclarationStatement.cs
- SegmentInfo.cs