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
- XmlILOptimizerVisitor.cs
- LogEntryHeaderDeserializer.cs
- Page.cs
- DataGridViewColumnConverter.cs
- SqlDataRecord.cs
- XPathAncestorIterator.cs
- HTTPRemotingHandler.cs
- BinaryFormatterSinks.cs
- TableRow.cs
- StateMachineWorkflow.cs
- ProxyWebPartManager.cs
- SessionEndingCancelEventArgs.cs
- OdbcHandle.cs
- RemoteDebugger.cs
- GeneratedCodeAttribute.cs
- Compiler.cs
- RtfToXamlReader.cs
- SrgsDocument.cs
- RealProxy.cs
- CryptoApi.cs
- WindowsGraphics.cs
- OracleRowUpdatedEventArgs.cs
- COM2Properties.cs
- PersonalizationStateQuery.cs
- ErrorHandlingAcceptor.cs
- PolicyValidationException.cs
- _NegotiateClient.cs
- FormattedText.cs
- EntityFrameworkVersions.cs
- FlowDocumentPage.cs
- DatagramAdapter.cs
- LazyTextWriterCreator.cs
- DependencyPropertyKey.cs
- TimeSpanMinutesConverter.cs
- FileLogRecord.cs
- StreamInfo.cs
- ApplicationActivator.cs
- Brush.cs
- PolyBezierSegment.cs
- AssemblyAttributes.cs
- WebPartEventArgs.cs
- TdsParser.cs
- WindowsAuthenticationModule.cs
- Rotation3DAnimationBase.cs
- HttpPostedFileWrapper.cs
- XPathExpr.cs
- CodeTypeConstructor.cs
- CopyEncoder.cs
- ReflectionUtil.cs
- PermissionRequestEvidence.cs
- EventHandlerList.cs
- PointConverter.cs
- DecimalSumAggregationOperator.cs
- ScrollData.cs
- DeviceContexts.cs
- DescendentsWalkerBase.cs
- Debugger.cs
- TemplateControlCodeDomTreeGenerator.cs
- CodeAttributeDeclaration.cs
- FileLogRecordStream.cs
- WeakReferenceKey.cs
- OleDbStruct.cs
- BindingCompleteEventArgs.cs
- _NTAuthentication.cs
- ModelPropertyImpl.cs
- IPPacketInformation.cs
- ValidatingPropertiesEventArgs.cs
- DynamicScriptObject.cs
- ModuleElement.cs
- EmptyReadOnlyDictionaryInternal.cs
- SubpageParagraph.cs
- ConnectionInterfaceCollection.cs
- ConfigXmlSignificantWhitespace.cs
- UriSection.cs
- GeometryDrawing.cs
- TextEditorCharacters.cs
- RefreshEventArgs.cs
- FormsAuthenticationUserCollection.cs
- Operand.cs
- WeakEventManager.cs
- SplitterDesigner.cs
- QuaternionValueSerializer.cs
- NewExpression.cs
- SqlDataReaderSmi.cs
- AbstractSvcMapFileLoader.cs
- SoapExtensionImporter.cs
- TextTreePropertyUndoUnit.cs
- dataprotectionpermission.cs
- ValidatorCollection.cs
- TableItemPatternIdentifiers.cs
- CharacterMetrics.cs
- SqlBinder.cs
- EndpointConfigContainer.cs
- ManagementQuery.cs
- PointConverter.cs
- EntityAdapter.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ExtensionWindowResizeGrip.cs
- QilTernary.cs
- DiagnosticTrace.cs