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
- CellTreeNode.cs
- QueryGenerator.cs
- MailDefinition.cs
- GridSplitter.cs
- SecurityManager.cs
- TimersDescriptionAttribute.cs
- AttributeTable.cs
- SafeLibraryHandle.cs
- EndpointConfigContainer.cs
- EntityProviderServices.cs
- ManualResetEvent.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- AQNBuilder.cs
- ConstraintCollection.cs
- TraceEventCache.cs
- Package.cs
- GridViewPageEventArgs.cs
- WsdlBuildProvider.cs
- XmlTextAttribute.cs
- ContentOperations.cs
- WorkflowRuntimeEndpoint.cs
- StyleCollection.cs
- XomlCompilerResults.cs
- _ConnectOverlappedAsyncResult.cs
- X509Certificate2Collection.cs
- UnsafeNativeMethods.cs
- SoapCodeExporter.cs
- SafeFileMappingHandle.cs
- DiagnosticTraceRecords.cs
- Int32Storage.cs
- CfgParser.cs
- ChannelBuilder.cs
- ImageInfo.cs
- ReferentialConstraint.cs
- Dictionary.cs
- TreeBuilder.cs
- Control.cs
- Win32PrintDialog.cs
- FunctionNode.cs
- FixedSOMLineCollection.cs
- Events.cs
- RecordBuilder.cs
- WindowsScroll.cs
- DoubleAnimationClockResource.cs
- documentsequencetextview.cs
- ContractTypeNameCollection.cs
- TemplateApplicationHelper.cs
- EntityDesignerUtils.cs
- CornerRadiusConverter.cs
- TransformProviderWrapper.cs
- ListContractAdapter.cs
- JavaScriptString.cs
- DataServiceQueryException.cs
- ToolStripSplitStackLayout.cs
- ObjectParameterCollection.cs
- UniqueIdentifierService.cs
- TextEditorContextMenu.cs
- DataSourceGeneratorException.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- RadialGradientBrush.cs
- Char.cs
- TrustLevel.cs
- ItemCollection.cs
- MethodExpr.cs
- Rfc2898DeriveBytes.cs
- ProxyHwnd.cs
- WebPartCatalogCloseVerb.cs
- Visual3DCollection.cs
- ExpressionBuilderContext.cs
- CryptoStream.cs
- ContextMenu.cs
- UntypedNullExpression.cs
- SourceSwitch.cs
- ResourceDisplayNameAttribute.cs
- ServiceOperationParameter.cs
- DataSetUtil.cs
- DecoderBestFitFallback.cs
- HttpCapabilitiesSectionHandler.cs
- XomlSerializationHelpers.cs
- DataColumnMappingCollection.cs
- updatecommandorderer.cs
- RemotingServices.cs
- PeerSecurityHelpers.cs
- PermissionToken.cs
- IListConverters.cs
- Psha1DerivedKeyGenerator.cs
- SafeNativeMethodsOther.cs
- HtmlToClrEventProxy.cs
- FieldInfo.cs
- ProxyWebPartConnectionCollection.cs
- ManualResetEvent.cs
- ListArgumentProvider.cs
- TimeManager.cs
- SafeProcessHandle.cs
- CultureTable.cs
- PersonalizationStateInfoCollection.cs
- IncrementalReadDecoders.cs
- ControlDesignerState.cs
- GuidelineSet.cs
- CollectionType.cs