Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2ICategorizePropertiesHandler.cs / 1 / COM2ICategorizePropertiesHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ComponentModel.Com2Interop { using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using Microsoft.Win32; [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal class Com2ICategorizePropertiesHandler : Com2ExtendedBrowsingHandler { public override Type Interface { get { return typeof(NativeMethods.ICategorizeProperties); } } private string GetCategoryFromObject(object obj, int dispid) { if (obj == null) { return null; } if (obj is NativeMethods.ICategorizeProperties) { NativeMethods.ICategorizeProperties catObj = (NativeMethods.ICategorizeProperties)obj; try { int categoryID = 0; if (NativeMethods.S_OK == catObj.MapPropertyToCategory(dispid, ref categoryID)) { string categoryName = null; switch (categoryID) { case NativeMethods.ActiveX.PROPCAT_Nil: return ""; case NativeMethods.ActiveX.PROPCAT_Misc: return SR.GetString(SR.PropertyCategoryMisc); case NativeMethods.ActiveX.PROPCAT_Font: return SR.GetString(SR.PropertyCategoryFont); case NativeMethods.ActiveX.PROPCAT_Position: return SR.GetString(SR.PropertyCategoryPosition); case NativeMethods.ActiveX.PROPCAT_Appearance: return SR.GetString(SR.PropertyCategoryAppearance); case NativeMethods.ActiveX.PROPCAT_Behavior: return SR.GetString(SR.PropertyCategoryBehavior); case NativeMethods.ActiveX.PROPCAT_Data: return SR.GetString(SR.PropertyCategoryData); case NativeMethods.ActiveX.PROPCAT_List: return SR.GetString(SR.PropertyCategoryList); case NativeMethods.ActiveX.PROPCAT_Text: return SR.GetString(SR.PropertyCategoryText); case NativeMethods.ActiveX.PROPCAT_Scale: return SR.GetString(SR.PropertyCategoryScale); case NativeMethods.ActiveX.PROPCAT_DDE: return SR.GetString(SR.PropertyCategoryDDE); } if (NativeMethods.S_OK == catObj.GetCategoryName(categoryID, CultureInfo.CurrentCulture.LCID, out categoryName)) { return categoryName; } } } catch { } } return null; } public override void SetupPropertyHandlers(Com2PropertyDescriptor[] propDesc) { if (propDesc == null) { return; } for (int i = 0; i < propDesc.Length; i++) { propDesc[i].QueryGetBaseAttributes += new GetAttributesEventHandler(this.OnGetAttributes); } } private void OnGetAttributes(Com2PropertyDescriptor sender, GetAttributesEvent attrEvent) { string cat = GetCategoryFromObject(sender.TargetObject, sender.DISPID); if (cat != null && cat.Length > 0) { attrEvent.Add(new CategoryAttribute(cat)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ComponentModel.Com2Interop { using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using Microsoft.Win32; [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal class Com2ICategorizePropertiesHandler : Com2ExtendedBrowsingHandler { public override Type Interface { get { return typeof(NativeMethods.ICategorizeProperties); } } private string GetCategoryFromObject(object obj, int dispid) { if (obj == null) { return null; } if (obj is NativeMethods.ICategorizeProperties) { NativeMethods.ICategorizeProperties catObj = (NativeMethods.ICategorizeProperties)obj; try { int categoryID = 0; if (NativeMethods.S_OK == catObj.MapPropertyToCategory(dispid, ref categoryID)) { string categoryName = null; switch (categoryID) { case NativeMethods.ActiveX.PROPCAT_Nil: return ""; case NativeMethods.ActiveX.PROPCAT_Misc: return SR.GetString(SR.PropertyCategoryMisc); case NativeMethods.ActiveX.PROPCAT_Font: return SR.GetString(SR.PropertyCategoryFont); case NativeMethods.ActiveX.PROPCAT_Position: return SR.GetString(SR.PropertyCategoryPosition); case NativeMethods.ActiveX.PROPCAT_Appearance: return SR.GetString(SR.PropertyCategoryAppearance); case NativeMethods.ActiveX.PROPCAT_Behavior: return SR.GetString(SR.PropertyCategoryBehavior); case NativeMethods.ActiveX.PROPCAT_Data: return SR.GetString(SR.PropertyCategoryData); case NativeMethods.ActiveX.PROPCAT_List: return SR.GetString(SR.PropertyCategoryList); case NativeMethods.ActiveX.PROPCAT_Text: return SR.GetString(SR.PropertyCategoryText); case NativeMethods.ActiveX.PROPCAT_Scale: return SR.GetString(SR.PropertyCategoryScale); case NativeMethods.ActiveX.PROPCAT_DDE: return SR.GetString(SR.PropertyCategoryDDE); } if (NativeMethods.S_OK == catObj.GetCategoryName(categoryID, CultureInfo.CurrentCulture.LCID, out categoryName)) { return categoryName; } } } catch { } } return null; } public override void SetupPropertyHandlers(Com2PropertyDescriptor[] propDesc) { if (propDesc == null) { return; } for (int i = 0; i < propDesc.Length; i++) { propDesc[i].QueryGetBaseAttributes += new GetAttributesEventHandler(this.OnGetAttributes); } } private void OnGetAttributes(Com2PropertyDescriptor sender, GetAttributesEvent attrEvent) { string cat = GetCategoryFromObject(sender.TargetObject, sender.DISPID); if (cat != null && cat.Length > 0) { attrEvent.Add(new CategoryAttribute(cat)); } } } } // 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
- IODescriptionAttribute.cs
- StrokeNodeEnumerator.cs
- PowerModeChangedEventArgs.cs
- ScriptComponentDescriptor.cs
- cache.cs
- XmlILIndex.cs
- FileLogRecordEnumerator.cs
- DocumentPageViewAutomationPeer.cs
- PackWebRequest.cs
- FileLogRecordEnumerator.cs
- OleStrCAMarshaler.cs
- dataprotectionpermission.cs
- ExportOptions.cs
- ManagementNamedValueCollection.cs
- SimpleBitVector32.cs
- PageSetupDialog.cs
- EntityStoreSchemaGenerator.cs
- NativeMethods.cs
- TailCallAnalyzer.cs
- XmlSerializerVersionAttribute.cs
- Rectangle.cs
- WebBrowserProgressChangedEventHandler.cs
- CodeNamespaceImportCollection.cs
- FeatureAttribute.cs
- ObjectListDataBindEventArgs.cs
- Rect3D.cs
- DataSourceProvider.cs
- ColumnMapProcessor.cs
- TypeElementCollection.cs
- SequenceQuery.cs
- ArraySortHelper.cs
- ConsumerConnectionPointCollection.cs
- XhtmlConformanceSection.cs
- TreeNodeBindingCollection.cs
- OutputCacheProfileCollection.cs
- recordstatefactory.cs
- CallContext.cs
- XamlSerializationHelper.cs
- InkCanvasFeedbackAdorner.cs
- TemplateXamlTreeBuilder.cs
- DataObjectMethodAttribute.cs
- EntityTypeEmitter.cs
- TextOutput.cs
- AuthenticationManager.cs
- _AutoWebProxyScriptEngine.cs
- CollectionChangedEventManager.cs
- DataGridViewMethods.cs
- BaseParaClient.cs
- SqlFormatter.cs
- ApplicationDirectoryMembershipCondition.cs
- Variant.cs
- DataGridViewRowHeaderCell.cs
- EntityDataSourceDesignerHelper.cs
- BooleanStorage.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- ToolStripTextBox.cs
- GenericsInstances.cs
- ValueType.cs
- GlyphRunDrawing.cs
- WebConfigurationFileMap.cs
- ColorMatrix.cs
- KeysConverter.cs
- EntityRecordInfo.cs
- RectIndependentAnimationStorage.cs
- InputMethod.cs
- PartManifestEntry.cs
- ListItemCollection.cs
- ActivityTrace.cs
- FontConverter.cs
- SQLByte.cs
- DataGridRowDetailsEventArgs.cs
- Touch.cs
- Opcode.cs
- PeerCollaborationPermission.cs
- WSFederationHttpBinding.cs
- ColorTranslator.cs
- GraphicsContainer.cs
- PerspectiveCamera.cs
- CodeDOMProvider.cs
- SecurityUtils.cs
- TemplateModeChangedEventArgs.cs
- DataListItem.cs
- DataGridViewRowConverter.cs
- relpropertyhelper.cs
- StaticResourceExtension.cs
- WinInetCache.cs
- TouchesOverProperty.cs
- SecurityKeyIdentifierClause.cs
- WebConfigurationManager.cs
- VolatileEnlistmentMultiplexing.cs
- Keywords.cs
- MergeFailedEvent.cs
- WindowsIPAddress.cs
- EdmItemError.cs
- FixedSOMLineCollection.cs
- ComponentRenameEvent.cs
- Odbc32.cs
- ControlValuePropertyAttribute.cs
- RegistrationServices.cs
- MenuItemStyleCollection.cs