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
- AssemblyInfo.cs
- sqlcontext.cs
- TextLineResult.cs
- PropertyNames.cs
- SystemInformation.cs
- DesignObjectWrapper.cs
- TransformerInfoCollection.cs
- ReverseComparer.cs
- MarshalDirectiveException.cs
- DecoderFallbackWithFailureFlag.cs
- DefaultBinder.cs
- EntityProxyTypeInfo.cs
- PingReply.cs
- FunctionUpdateCommand.cs
- Int16.cs
- DockPatternIdentifiers.cs
- WebPartCloseVerb.cs
- ToolStripGrip.cs
- SqlUserDefinedAggregateAttribute.cs
- ReflectionUtil.cs
- keycontainerpermission.cs
- ClearCollection.cs
- Int32KeyFrameCollection.cs
- OuterGlowBitmapEffect.cs
- OdbcConnectionStringbuilder.cs
- LoadGrammarCompletedEventArgs.cs
- XmlNodeChangedEventManager.cs
- COAUTHINFO.cs
- TimelineClockCollection.cs
- ManagementException.cs
- SiteMembershipCondition.cs
- __FastResourceComparer.cs
- AssemblyAttributesGoHere.cs
- InputBinding.cs
- SuppressMergeCheckAttribute.cs
- DataStorage.cs
- BuilderElements.cs
- XmlMapping.cs
- InternalControlCollection.cs
- PageTheme.cs
- GridViewPageEventArgs.cs
- StaticTextPointer.cs
- FormatSettings.cs
- HttpHandlersSection.cs
- InlineCollection.cs
- HttpPostLocalhostServerProtocol.cs
- DbConnectionHelper.cs
- BitmapImage.cs
- SyndicationElementExtensionCollection.cs
- DataColumnMapping.cs
- Bind.cs
- TableLayoutColumnStyleCollection.cs
- ConnectionStringsExpressionBuilder.cs
- HwndKeyboardInputProvider.cs
- SqlFacetAttribute.cs
- DesignTimeVisibleAttribute.cs
- QilPatternFactory.cs
- DodSequenceMerge.cs
- SamlAudienceRestrictionCondition.cs
- TypeToken.cs
- ExecutionContext.cs
- EntityContainerRelationshipSet.cs
- OutputScopeManager.cs
- XmlSerializerSection.cs
- StrokeDescriptor.cs
- SqlDataSourceFilteringEventArgs.cs
- Metafile.cs
- BinarySerializer.cs
- PaginationProgressEventArgs.cs
- ByteAnimationBase.cs
- MetadataUtilsSmi.cs
- FormsAuthenticationUserCollection.cs
- XmlCharCheckingWriter.cs
- WaitHandleCannotBeOpenedException.cs
- EmissiveMaterial.cs
- PolyQuadraticBezierSegment.cs
- SecurityHelper.cs
- FormsAuthenticationCredentials.cs
- BuildProvidersCompiler.cs
- WebPartZoneDesigner.cs
- PropertyPathWorker.cs
- Funcletizer.cs
- CacheMemory.cs
- PipelineComponent.cs
- ScanQueryOperator.cs
- RuleSetCollection.cs
- HttpStreams.cs
- SoapConverter.cs
- FontConverter.cs
- ZipIOFileItemStream.cs
- PropertyManager.cs
- FormsAuthenticationModule.cs
- FunctionImportMapping.cs
- DeferredTextReference.cs
- Pair.cs
- StylusEventArgs.cs
- JoinGraph.cs
- X509Utils.cs
- AnnotationAdorner.cs
- XamlTypeMapper.cs