Code:
/ DotNET / DotNET / 8.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
- MonthCalendar.cs
- InternalMappingException.cs
- IPHostEntry.cs
- BuildProviderUtils.cs
- RuleConditionDialog.Designer.cs
- HealthMonitoringSectionHelper.cs
- BlurBitmapEffect.cs
- MailWebEventProvider.cs
- DocumentOutline.cs
- ContentFilePart.cs
- mda.cs
- MailAddressCollection.cs
- XmlToDatasetMap.cs
- NameTable.cs
- Int16Storage.cs
- DataGridParentRows.cs
- TimeSpanValidatorAttribute.cs
- VScrollBar.cs
- ExecutionEngineException.cs
- PictureBox.cs
- MergeFailedEvent.cs
- PlanCompilerUtil.cs
- ButtonColumn.cs
- SortedList.cs
- MailSettingsSection.cs
- EventDescriptor.cs
- KeyTimeConverter.cs
- COAUTHIDENTITY.cs
- XLinq.cs
- ObsoleteAttribute.cs
- MetadataCollection.cs
- InplaceBitmapMetadataWriter.cs
- RunInstallerAttribute.cs
- GenericQueueSurrogate.cs
- DoubleAnimationClockResource.cs
- HttpModuleAction.cs
- DataGridViewRowEventArgs.cs
- ExportException.cs
- DataBoundControlAdapter.cs
- xdrvalidator.cs
- TextTreeFixupNode.cs
- BaseDataListActionList.cs
- ToolStripHighContrastRenderer.cs
- X509Certificate2Collection.cs
- ISAPIRuntime.cs
- KoreanLunisolarCalendar.cs
- SecureStringHasher.cs
- DesignerView.xaml.cs
- DataGridItem.cs
- ReadOnlyPropertyMetadata.cs
- DataListItem.cs
- RangeValuePatternIdentifiers.cs
- InternalsVisibleToAttribute.cs
- BooleanConverter.cs
- AngleUtil.cs
- XPathNodePointer.cs
- X509Certificate2.cs
- RecordManager.cs
- ClientEndpointLoader.cs
- _SslStream.cs
- QueryableFilterRepeater.cs
- ActivityWithResultConverter.cs
- Overlapped.cs
- UserControlAutomationPeer.cs
- DocumentXmlWriter.cs
- WebBrowserNavigatedEventHandler.cs
- ActivityBuilderHelper.cs
- TrustManager.cs
- QueryableDataSource.cs
- util.cs
- ZoneButton.cs
- FixedStringLookup.cs
- ParameterInfo.cs
- PropertyEntry.cs
- ProfileProvider.cs
- UnsafeMethods.cs
- ConstructorNeedsTagAttribute.cs
- SelectionProcessor.cs
- DerivedKeySecurityToken.cs
- InkPresenter.cs
- EncoderReplacementFallback.cs
- Int16Converter.cs
- ToolStripDropTargetManager.cs
- SQLDecimalStorage.cs
- DbConnectionClosed.cs
- Fonts.cs
- ProcessProtocolHandler.cs
- UriTemplateLiteralPathSegment.cs
- AsyncCompletedEventArgs.cs
- SmiEventSink.cs
- IDQuery.cs
- TableItemStyle.cs
- WebRequestModulesSection.cs
- FactoryRecord.cs
- DispatcherFrame.cs
- StringUtil.cs
- StructureChangedEventArgs.cs
- XPathNodeIterator.cs
- Type.cs
- SafeHandles.cs