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
- DataControlFieldCell.cs
- SynchronizationLockException.cs
- ComNativeDescriptor.cs
- SessionStateUtil.cs
- DescendantOverDescendantQuery.cs
- RoleBoolean.cs
- SQLDouble.cs
- TreeWalkHelper.cs
- ServicePointManager.cs
- DesignerObjectListAdapter.cs
- FillErrorEventArgs.cs
- SystemPens.cs
- DispatcherOperation.cs
- SectionRecord.cs
- DataObjectAttribute.cs
- DoWorkEventArgs.cs
- WebHttpEndpoint.cs
- NonClientArea.cs
- EventNotify.cs
- PropertySourceInfo.cs
- CodeStatementCollection.cs
- WebServiceErrorEvent.cs
- UnionCqlBlock.cs
- LayoutEditorPart.cs
- LOSFormatter.cs
- HandlerBase.cs
- EdmScalarPropertyAttribute.cs
- RequestCacheManager.cs
- AssertFilter.cs
- AddressHeader.cs
- VectorValueSerializer.cs
- DocumentViewerAutomationPeer.cs
- UpDownEvent.cs
- PageAsyncTaskManager.cs
- PropertyTab.cs
- FieldAccessException.cs
- BevelBitmapEffect.cs
- SHA1Managed.cs
- AnimationClock.cs
- ACE.cs
- DependencyObjectProvider.cs
- BaseTemplateCodeDomTreeGenerator.cs
- NumberSubstitution.cs
- WebPartConnectionCollection.cs
- IssuerInformation.cs
- DesigntimeLicenseContext.cs
- TextClipboardData.cs
- CodeNamespaceCollection.cs
- TreeSet.cs
- HttpCapabilitiesEvaluator.cs
- Hashtable.cs
- DesignerDataSourceView.cs
- listitem.cs
- ISO2022Encoding.cs
- SignerInfo.cs
- XmlArrayAttribute.cs
- ToolStripGrip.cs
- FlowLayoutPanel.cs
- CodeDOMProvider.cs
- HMACRIPEMD160.cs
- Expressions.cs
- PersonalizationDictionary.cs
- HeaderUtility.cs
- MetadataCache.cs
- SqlTriggerAttribute.cs
- DesignerUtility.cs
- MergeLocalizationDirectives.cs
- formatstringdialog.cs
- CombinedGeometry.cs
- SQLByte.cs
- AuthenticationModuleElement.cs
- SQLDateTime.cs
- HttpCachePolicy.cs
- DrawingAttributeSerializer.cs
- DtrList.cs
- _AutoWebProxyScriptWrapper.cs
- BinaryFormatterWriter.cs
- GeneralTransform2DTo3D.cs
- HtmlAnchor.cs
- BamlWriter.cs
- AmbientValueAttribute.cs
- IntSecurity.cs
- HttpTransportBindingElement.cs
- SerializationAttributes.cs
- OleDbReferenceCollection.cs
- ObjectListGeneralPage.cs
- HttpModuleCollection.cs
- CertificateManager.cs
- CharacterMetrics.cs
- ZoomPercentageConverter.cs
- FontNamesConverter.cs
- GlobalizationAssembly.cs
- StrokeCollectionDefaultValueFactory.cs
- SqlBulkCopy.cs
- DataKeyCollection.cs
- UserPrincipalNameElement.cs
- SqlExpressionNullability.cs
- COM2EnumConverter.cs
- ApplicationActivator.cs
- TCPListener.cs