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
- SqlGenerator.cs
- CfgParser.cs
- XmlSchemaComplexType.cs
- DataSourceSelectArguments.cs
- UnauthorizedAccessException.cs
- Size3D.cs
- FlowPanelDesigner.cs
- DesignerVerbCollection.cs
- GenericIdentity.cs
- DataSourceHelper.cs
- TableHeaderCell.cs
- SplineKeyFrames.cs
- EDesignUtil.cs
- Model3DGroup.cs
- ForeignKeyConstraint.cs
- EpmHelper.cs
- XmlSchemaObjectCollection.cs
- MessageParameterAttribute.cs
- HwndSource.cs
- DataGridViewTextBoxColumn.cs
- ItemCheckedEvent.cs
- CurrentChangingEventManager.cs
- PopOutPanel.cs
- SecurityKeyIdentifierClause.cs
- DataMember.cs
- WebPartExportVerb.cs
- BaseCodePageEncoding.cs
- WindowsGraphicsCacheManager.cs
- MessageQueueException.cs
- PkcsMisc.cs
- IMembershipProvider.cs
- OracleParameterCollection.cs
- ImageUrlEditor.cs
- CursorConverter.cs
- RuleSettingsCollection.cs
- KeyEvent.cs
- HtmlInputImage.cs
- IsolatedStorage.cs
- _NTAuthentication.cs
- PrintPreviewControl.cs
- KerberosRequestorSecurityToken.cs
- EntityTemplateFactory.cs
- ObjectIDGenerator.cs
- WindowsNonControl.cs
- Literal.cs
- IListConverters.cs
- AttachedAnnotation.cs
- GenericArgumentsUpdater.cs
- HttpHandlerAction.cs
- PromptBuilder.cs
- EntityStoreSchemaGenerator.cs
- PagesSection.cs
- DetailsViewPageEventArgs.cs
- EditorZoneBase.cs
- SchemaNamespaceManager.cs
- EmbossBitmapEffect.cs
- LinkLabelLinkClickedEvent.cs
- ToolStripComboBox.cs
- NameObjectCollectionBase.cs
- AssemblyName.cs
- EventProviderWriter.cs
- AutomationIdentifierGuids.cs
- NumberSubstitution.cs
- RightsDocument.cs
- FontFamilyConverter.cs
- SafeNativeMethods.cs
- Geometry.cs
- ViewManager.cs
- XamlRtfConverter.cs
- EntityDescriptor.cs
- HtmlTableRowCollection.cs
- coordinator.cs
- OSFeature.cs
- SecurityKeyIdentifierClause.cs
- XXXInfos.cs
- SqlBulkCopyColumnMappingCollection.cs
- FileRecordSequenceHelper.cs
- SQLMoney.cs
- CommonXSendMessage.cs
- GcHandle.cs
- IImplicitResourceProvider.cs
- EdmTypeAttribute.cs
- PeerCollaborationPermission.cs
- EventLogTraceListener.cs
- GeometryCombineModeValidation.cs
- DataException.cs
- SettingsPropertyNotFoundException.cs
- XsdCachingReader.cs
- AnimationException.cs
- SQlBooleanStorage.cs
- BulletedList.cs
- PeerDuplexChannelListener.cs
- ProfileGroupSettings.cs
- GeometryConverter.cs
- RtfToken.cs
- DBAsyncResult.cs
- Viewport3DAutomationPeer.cs
- XmlParserContext.cs
- HtmlToClrEventProxy.cs
- DockPanel.cs