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
- CodeExporter.cs
- HandledEventArgs.cs
- ProgressBar.cs
- DynamicMetaObjectBinder.cs
- RandomNumberGenerator.cs
- DataServiceExpressionVisitor.cs
- EventArgs.cs
- SqlClientWrapperSmiStream.cs
- PresentationAppDomainManager.cs
- FileDialogCustomPlace.cs
- DataTableTypeConverter.cs
- DoubleKeyFrameCollection.cs
- BuildProviderAppliesToAttribute.cs
- FaultHandlingFilter.cs
- DataControlPagerLinkButton.cs
- ButtonFieldBase.cs
- Application.cs
- SqlNotificationEventArgs.cs
- HttpDebugHandler.cs
- DataGridViewElement.cs
- BidirectionalDictionary.cs
- EntityParameterCollection.cs
- Setter.cs
- PropertyInformation.cs
- SqlDataSourceStatusEventArgs.cs
- PackageDigitalSignatureManager.cs
- FunctionMappingTranslator.cs
- ControlBindingsConverter.cs
- MailDefinition.cs
- ValueHandle.cs
- FieldMetadata.cs
- ListManagerBindingsCollection.cs
- TextViewBase.cs
- ComNativeDescriptor.cs
- assemblycache.cs
- AsyncStreamReader.cs
- HttpListenerException.cs
- XmlUtf8RawTextWriter.cs
- WebScriptClientGenerator.cs
- MeasureData.cs
- WindowsGrip.cs
- IpcChannel.cs
- CodeAttributeArgument.cs
- MexHttpBindingElement.cs
- RadioButton.cs
- PopOutPanel.cs
- VisualBasicSettingsHandler.cs
- TextPointerBase.cs
- WebCategoryAttribute.cs
- IfElseDesigner.xaml.cs
- CodeVariableReferenceExpression.cs
- DragEventArgs.cs
- Setter.cs
- EventManager.cs
- ConcurrentStack.cs
- WindowPattern.cs
- ModelTreeManager.cs
- TransportConfigurationTypeElementCollection.cs
- VarInfo.cs
- UnorderedHashRepartitionStream.cs
- NullableBoolConverter.cs
- ProtocolsSection.cs
- LockRenewalTask.cs
- HierarchicalDataBoundControl.cs
- AttributeTableBuilder.cs
- SqlClientPermission.cs
- WindowsTreeView.cs
- NameValueCache.cs
- SqlDataSourceCommandEventArgs.cs
- GlobalizationAssembly.cs
- BlockCollection.cs
- StylusPointCollection.cs
- VariableValue.cs
- EntityDataSourceConfigureObjectContext.cs
- OracleParameterBinding.cs
- ServiceInstallComponent.cs
- Icon.cs
- JpegBitmapEncoder.cs
- ResourcePool.cs
- LoginViewDesigner.cs
- SymmetricKeyWrap.cs
- NamespaceInfo.cs
- XmlSignatureProperties.cs
- GeometryValueSerializer.cs
- ClientOptions.cs
- HttpChannelBindingToken.cs
- SpeakInfo.cs
- NamespaceMapping.cs
- PointF.cs
- MultilineStringConverter.cs
- TextServicesProperty.cs
- SafeSecurityHandles.cs
- InputScopeAttribute.cs
- COM2EnumConverter.cs
- HtmlInputRadioButton.cs
- ContextMarshalException.cs
- WorkflowViewStateService.cs
- ISAPIWorkerRequest.cs
- MultiPropertyDescriptorGridEntry.cs
- CommandManager.cs