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
- PasswordRecovery.cs
- ServiceHttpModule.cs
- BuildResult.cs
- MailMessageEventArgs.cs
- GregorianCalendar.cs
- GlobalProxySelection.cs
- DataControlFieldsEditor.cs
- TemplateControlBuildProvider.cs
- DescriptionAttribute.cs
- TabControlEvent.cs
- DataGridViewCellStateChangedEventArgs.cs
- TextBoxBase.cs
- EdmTypeAttribute.cs
- BuildProviderUtils.cs
- GroupItemAutomationPeer.cs
- glyphs.cs
- TraceUtils.cs
- TransportListener.cs
- WorkflowIdleBehavior.cs
- CDSsyncETWBCLProvider.cs
- DataColumnMappingCollection.cs
- SqlTrackingService.cs
- AttachedPropertiesService.cs
- ProcessProtocolHandler.cs
- ClientTargetCollection.cs
- ListDictionary.cs
- SqlProfileProvider.cs
- RotateTransform.cs
- Material.cs
- LinqDataSourceStatusEventArgs.cs
- BezierSegment.cs
- XMLDiffLoader.cs
- HtmlFormParameterReader.cs
- ContentOperations.cs
- sapiproxy.cs
- VectorAnimationBase.cs
- CLRBindingWorker.cs
- ListBoxItem.cs
- RadioButtonAutomationPeer.cs
- RootBuilder.cs
- ByteConverter.cs
- PriorityBinding.cs
- COM2ExtendedTypeConverter.cs
- RuntimeHandles.cs
- SecurityElement.cs
- FileDialog_Vista.cs
- ChtmlSelectionListAdapter.cs
- FilterEventArgs.cs
- CompareInfo.cs
- ExpressionBuilderContext.cs
- PropertyRef.cs
- HostExecutionContextManager.cs
- ComponentResourceManager.cs
- CodeExpressionStatement.cs
- WindowsFormsLinkLabel.cs
- HtmlTableCellCollection.cs
- _ShellExpression.cs
- Panel.cs
- ClonableStack.cs
- AnchoredBlock.cs
- MgmtConfigurationRecord.cs
- ExternalException.cs
- WebBrowserPermission.cs
- DataGridCell.cs
- LambdaCompiler.Statements.cs
- ModelItemCollection.cs
- ItemCollection.cs
- FormConverter.cs
- XmlILStorageConverter.cs
- Binding.cs
- XmlDictionaryWriter.cs
- Expressions.cs
- WebUtility.cs
- NeutralResourcesLanguageAttribute.cs
- IgnoreFileBuildProvider.cs
- NegotiateStream.cs
- Wizard.cs
- XmlDataSourceNodeDescriptor.cs
- SafeCoTaskMem.cs
- ArglessEventHandlerProxy.cs
- EventLogEntryCollection.cs
- Int32AnimationBase.cs
- HttpCachePolicyElement.cs
- WithParamAction.cs
- LogWriteRestartAreaAsyncResult.cs
- SimpleTypeResolver.cs
- BoundColumn.cs
- DeclarativeConditionsCollection.cs
- CompilerTypeWithParams.cs
- handlecollector.cs
- BitArray.cs
- RefreshPropertiesAttribute.cs
- BrushMappingModeValidation.cs
- SoundPlayer.cs
- DependencyPropertyValueSerializer.cs
- XmlSerializerVersionAttribute.cs
- InfocardChannelParameter.cs
- ReadWriteSpinLock.cs
- ImportContext.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs