Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2ColorConverter.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ColorConverter.cs
- MissingFieldException.cs
- ObjectQueryProvider.cs
- ItemCollection.cs
- ConnectionPoolManager.cs
- LocationChangedEventArgs.cs
- DocumentOutline.cs
- connectionpool.cs
- PropagatorResult.cs
- JsonReaderDelegator.cs
- Material.cs
- Utils.cs
- EventLogSession.cs
- DefaultIfEmptyQueryOperator.cs
- EncoderExceptionFallback.cs
- CodeLabeledStatement.cs
- EventTrigger.cs
- MetadataItem.cs
- QueryContinueDragEventArgs.cs
- DefaultSerializationProviderAttribute.cs
- DrawListViewColumnHeaderEventArgs.cs
- ProfilePropertyNameValidator.cs
- DataConnectionHelper.cs
- NameSpaceExtractor.cs
- Focus.cs
- EventWaitHandleSecurity.cs
- DataObjectAttribute.cs
- _SslState.cs
- SystemIPv4InterfaceProperties.cs
- CodeDirectiveCollection.cs
- DropSource.cs
- BooleanExpr.cs
- SubqueryRules.cs
- StringArrayConverter.cs
- CharEntityEncoderFallback.cs
- ColorBlend.cs
- GenerateScriptTypeAttribute.cs
- Validator.cs
- ArraySubsetEnumerator.cs
- InfoCardArgumentException.cs
- ReservationNotFoundException.cs
- BufferedGraphics.cs
- SchemaElementDecl.cs
- DefaultTraceListener.cs
- HtmlMeta.cs
- HandleExceptionArgs.cs
- SrgsGrammarCompiler.cs
- CharEnumerator.cs
- LinqDataSourceSelectEventArgs.cs
- UnaryOperationBinder.cs
- XmlCodeExporter.cs
- DisplayInformation.cs
- PropertyInformation.cs
- XNodeValidator.cs
- RSAProtectedConfigurationProvider.cs
- ContentFileHelper.cs
- ReachSerializationUtils.cs
- DataBindingList.cs
- IndexedGlyphRun.cs
- EmptyControlCollection.cs
- BinaryNode.cs
- ConfigurationSectionGroup.cs
- HtmlEncodedRawTextWriter.cs
- ServiceSecurityAuditBehavior.cs
- PermissionToken.cs
- RuntimeIdentifierPropertyAttribute.cs
- XmlSchemas.cs
- PipelineModuleStepContainer.cs
- CompModSwitches.cs
- ExpressionLink.cs
- HtmlShim.cs
- SearchForVirtualItemEventArgs.cs
- ResourceSet.cs
- BitmapSource.cs
- UTF32Encoding.cs
- LostFocusEventManager.cs
- MessageDroppedTraceRecord.cs
- CurrentChangingEventManager.cs
- DbModificationCommandTree.cs
- RijndaelManaged.cs
- MetadataPropertyAttribute.cs
- TransactionFlowBindingElementImporter.cs
- Propagator.ExtentPlaceholderCreator.cs
- PropertyOrder.cs
- GenericsInstances.cs
- JsonEncodingStreamWrapper.cs
- Serializer.cs
- ObjectSet.cs
- Cursor.cs
- PropertyConverter.cs
- Overlapped.cs
- SecurityTokenRequirement.cs
- SqlNodeTypeOperators.cs
- OleDbFactory.cs
- AdapterDictionary.cs
- CodePageUtils.cs
- DataGridViewRowEventArgs.cs
- SqlDataSourceConfigureSortForm.cs
- PropertyEmitterBase.cs
- SchemaAttDef.cs