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
- SpeakInfo.cs
- SecurityCriticalDataForSet.cs
- CTreeGenerator.cs
- XmlCDATASection.cs
- XPathEmptyIterator.cs
- QuadraticBezierSegment.cs
- XmlSortKeyAccumulator.cs
- EnumConverter.cs
- InputQueueChannelAcceptor.cs
- RulePatternOps.cs
- PageThemeCodeDomTreeGenerator.cs
- CompiledAction.cs
- HtmlTableCell.cs
- MimeObjectFactory.cs
- LayoutTable.cs
- FacetChecker.cs
- SymmetricAlgorithm.cs
- Function.cs
- COM2Properties.cs
- FlowLayoutPanel.cs
- MessageSecurityOverMsmqElement.cs
- FontUnitConverter.cs
- FlagsAttribute.cs
- WinInetCache.cs
- UnaryQueryOperator.cs
- ImageSourceValueSerializer.cs
- XPathChildIterator.cs
- KeyGesture.cs
- DropShadowBitmapEffect.cs
- ResourcePermissionBase.cs
- RemoteTokenFactory.cs
- XMLUtil.cs
- x509store.cs
- WizardPanelChangingEventArgs.cs
- EdmComplexTypeAttribute.cs
- BitmapEffectCollection.cs
- ImageMap.cs
- DataListCommandEventArgs.cs
- TransactionInformation.cs
- EventLogQuery.cs
- Certificate.cs
- DbParameterHelper.cs
- ScriptingScriptResourceHandlerSection.cs
- FocusWithinProperty.cs
- AspCompat.cs
- Point3DCollection.cs
- PathSegmentCollection.cs
- VirtualPathData.cs
- FlowLayout.cs
- TdsEnums.cs
- MSHTMLHost.cs
- PlatformNotSupportedException.cs
- FileSecurity.cs
- GenericEnumerator.cs
- RectKeyFrameCollection.cs
- Authorization.cs
- CapabilitiesRule.cs
- SafePointer.cs
- DataGridItemEventArgs.cs
- LocalizabilityAttribute.cs
- FontSizeConverter.cs
- MergeEnumerator.cs
- TextMetrics.cs
- SubstitutionList.cs
- SemanticResolver.cs
- Pointer.cs
- FileDialogPermission.cs
- DrawingVisualDrawingContext.cs
- MenuItem.cs
- JsonReader.cs
- EventLogPermissionEntry.cs
- EntityDataSourceView.cs
- DataGridCaption.cs
- SkewTransform.cs
- DataKeyCollection.cs
- NativeWindow.cs
- SimpleWorkerRequest.cs
- BrowsableAttribute.cs
- Line.cs
- SHA1Cng.cs
- LocatorPartList.cs
- SiteOfOriginPart.cs
- ObjectItemCollection.cs
- OleDbWrapper.cs
- X509ChainPolicy.cs
- SignedXml.cs
- BeginEvent.cs
- NonVisualControlAttribute.cs
- WindowsComboBox.cs
- TypeKeyValue.cs
- Point4D.cs
- Int32Converter.cs
- FormatSettings.cs
- ZipIOFileItemStream.cs
- Emitter.cs
- ContextProperty.cs
- TemplateControlBuildProvider.cs
- DataServiceResponse.cs
- SharedRuntimeState.cs
- CodeComment.cs