Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- TripleDESCryptoServiceProvider.cs
- WebPartCloseVerb.cs
- SR.cs
- UserControlBuildProvider.cs
- TrustLevel.cs
- File.cs
- ObjectFullSpanRewriter.cs
- WebRequestModulesSection.cs
- DesignTimeVisibleAttribute.cs
- KeyInfo.cs
- NullableIntSumAggregationOperator.cs
- SpanIndex.cs
- Types.cs
- DbMetaDataFactory.cs
- HtmlDocument.cs
- NativeMethodsCLR.cs
- ParameterReplacerVisitor.cs
- UInt64Storage.cs
- DataGridViewEditingControlShowingEventArgs.cs
- PropertyIDSet.cs
- Process.cs
- WebHttpDispatchOperationSelector.cs
- Zone.cs
- SecurityRuntime.cs
- GridProviderWrapper.cs
- CharAnimationUsingKeyFrames.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- SystemIPv4InterfaceProperties.cs
- FunctionImportElement.cs
- ControlBuilderAttribute.cs
- MouseDevice.cs
- AppliedDeviceFiltersDialog.cs
- PackageStore.cs
- DrawingGroup.cs
- WSFederationHttpBinding.cs
- WSHttpSecurityElement.cs
- IResourceProvider.cs
- SizeAnimationClockResource.cs
- StyleSheet.cs
- TCPClient.cs
- IFormattable.cs
- NativeMethods.cs
- XmlNodeChangedEventArgs.cs
- HttpModulesInstallComponent.cs
- GenerateTemporaryTargetAssembly.cs
- MaskedTextBox.cs
- DefaultValueMapping.cs
- ZoneMembershipCondition.cs
- ObjectDataSourceStatusEventArgs.cs
- CheckBoxAutomationPeer.cs
- ListParagraph.cs
- COM2ExtendedTypeConverter.cs
- DiscoveryMessageProperty.cs
- cookie.cs
- OrderByBuilder.cs
- BitConverter.cs
- XmlSubtreeReader.cs
- ButtonChrome.cs
- AssemblyAssociatedContentFileAttribute.cs
- PngBitmapDecoder.cs
- ColumnClickEvent.cs
- AspNetSynchronizationContext.cs
- PlaceHolder.cs
- HtmlInputReset.cs
- Claim.cs
- FormViewInsertEventArgs.cs
- ClientBuildManager.cs
- DBSqlParserTableCollection.cs
- FileNotFoundException.cs
- DefaultTraceListener.cs
- cookieexception.cs
- UpWmlMobileTextWriter.cs
- PlaceHolder.cs
- ECDsaCng.cs
- WSHttpBindingBase.cs
- UserControlCodeDomTreeGenerator.cs
- HostedHttpRequestAsyncResult.cs
- AsyncDataRequest.cs
- Boolean.cs
- XmlDataSourceView.cs
- RoleManagerEventArgs.cs
- IndexedGlyphRun.cs
- ComponentGuaranteesAttribute.cs
- DrawingVisual.cs
- RadioButtonDesigner.cs
- Accessible.cs
- PackageRelationshipSelector.cs
- CellCreator.cs
- HtmlListAdapter.cs
- StylusPointPropertyId.cs
- XmlDocumentSchema.cs
- CancellationHandlerDesigner.cs
- ManipulationInertiaStartingEventArgs.cs
- WebPartUserCapability.cs
- Menu.cs
- TempFiles.cs
- XmlSchemaElement.cs
- TextFormatterContext.cs
- BrowserDefinition.cs
- ToolStrip.cs