Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Latin1Encoding.cs
- XmlSchemaAttributeGroup.cs
- XhtmlBasicTextViewAdapter.cs
- XpsS0ValidatingLoader.cs
- ThicknessKeyFrameCollection.cs
- streamingZipPartStream.cs
- ClrPerspective.cs
- DataGridCell.cs
- SettingsPropertyValueCollection.cs
- ApplicationServiceHelper.cs
- EditingCommands.cs
- VerificationAttribute.cs
- SecurityRuntime.cs
- figurelength.cs
- Sequence.cs
- PolicyException.cs
- EventToken.cs
- OSFeature.cs
- SettingsAttributes.cs
- SelectionGlyphBase.cs
- WorkflowMessageEventArgs.cs
- PasswordPropertyTextAttribute.cs
- FileUtil.cs
- Control.cs
- ErrorRuntimeConfig.cs
- MessageBox.cs
- UTF32Encoding.cs
- TreeNodeCollection.cs
- SecurityContextCookieSerializer.cs
- SqlNode.cs
- EntityDataSourceMemberPath.cs
- SystemColors.cs
- DoubleAnimationBase.cs
- ProtocolState.cs
- XmlnsDictionary.cs
- TreeNodeStyleCollectionEditor.cs
- GAC.cs
- ColumnMapTranslator.cs
- DesignerView.cs
- ColumnPropertiesGroup.cs
- SoapIncludeAttribute.cs
- altserialization.cs
- PolyLineSegmentFigureLogic.cs
- LazyTextWriterCreator.cs
- LOSFormatter.cs
- FileDialogCustomPlacesCollection.cs
- diagnosticsswitches.cs
- HotSpot.cs
- SweepDirectionValidation.cs
- LocalizabilityAttribute.cs
- BlockUIContainer.cs
- Int32Animation.cs
- ProtocolReflector.cs
- PathFigureCollection.cs
- QueryServiceConfigHandle.cs
- SqlDataSourceCache.cs
- MasterPageBuildProvider.cs
- CompositeCollectionView.cs
- Rectangle.cs
- MetadataFile.cs
- NamedObject.cs
- clipboard.cs
- Executor.cs
- TableAdapterManagerHelper.cs
- TypeBrowser.xaml.cs
- MULTI_QI.cs
- CommandHelpers.cs
- XmlSchemaExternal.cs
- UnauthorizedWebPart.cs
- CodeSubDirectoriesCollection.cs
- FileNameEditor.cs
- VisualBrush.cs
- SectionXmlInfo.cs
- CaseCqlBlock.cs
- XmlSchemaSet.cs
- StringUtil.cs
- FontStyleConverter.cs
- PipelineComponent.cs
- DocobjHost.cs
- Msec.cs
- ListenerElementsCollection.cs
- SafeMILHandleMemoryPressure.cs
- cryptoapiTransform.cs
- KernelTypeValidation.cs
- PatternMatcher.cs
- ViewLoader.cs
- PartitionedStream.cs
- ChannelBinding.cs
- CategoriesDocumentFormatter.cs
- WorkflowInstanceContextProvider.cs
- XamlPathDataSerializer.cs
- VBCodeProvider.cs
- ISAPIRuntime.cs
- AuthenticationModulesSection.cs
- PerformanceCounterScope.cs
- AuthenticationConfig.cs
- EncryptedKey.cs
- dsa.cs
- MediaTimeline.cs
- CustomTokenProvider.cs