Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2ICategorizePropertiesHandler.cs / 1305376 / 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
- ListBoxItemAutomationPeer.cs
- FieldTemplateUserControl.cs
- MsmqVerifier.cs
- BamlWriter.cs
- ResolveCriteriaApril2005.cs
- TextTreeInsertElementUndoUnit.cs
- ICollection.cs
- ISAPIWorkerRequest.cs
- TextBoxAutomationPeer.cs
- ResourceCodeDomSerializer.cs
- UnknownWrapper.cs
- HelpPage.cs
- TextElementAutomationPeer.cs
- NativeCompoundFileAPIs.cs
- IInstanceTable.cs
- LineBreakRecord.cs
- UriTemplateEquivalenceComparer.cs
- FileLogRecord.cs
- LockCookie.cs
- MaskInputRejectedEventArgs.cs
- TransformProviderWrapper.cs
- FontFamilyValueSerializer.cs
- control.ime.cs
- SendKeys.cs
- DataListItemCollection.cs
- CommandConverter.cs
- UTF32Encoding.cs
- SqlClientPermission.cs
- SecurityElement.cs
- MexHttpsBindingCollectionElement.cs
- FormsAuthenticationUser.cs
- Section.cs
- ToolStripOverflowButton.cs
- SpellerInterop.cs
- HelpKeywordAttribute.cs
- InteropAutomationProvider.cs
- SourceFilter.cs
- MsmqVerifier.cs
- Popup.cs
- datacache.cs
- CodeTypeMember.cs
- XmlSubtreeReader.cs
- Model3D.cs
- ContractHandle.cs
- PageAsyncTaskManager.cs
- XmlIlTypeHelper.cs
- GuidConverter.cs
- FormViewInsertedEventArgs.cs
- X509Certificate2Collection.cs
- SystemIPv4InterfaceProperties.cs
- CursorInteropHelper.cs
- RegexNode.cs
- SelectedDatesCollection.cs
- CodeAccessPermission.cs
- ThousandthOfEmRealPoints.cs
- ScriptResourceHandler.cs
- TemplateBindingExpressionConverter.cs
- SignatureResourcePool.cs
- XmlSerializationWriter.cs
- RsaElement.cs
- XmlNavigatorFilter.cs
- SettingsBase.cs
- EventLogPermission.cs
- ContentOperations.cs
- OdbcInfoMessageEvent.cs
- ParseElement.cs
- TransformConverter.cs
- ObjectDataSourceStatusEventArgs.cs
- Pkcs7Signer.cs
- DragDrop.cs
- X509Chain.cs
- TraceHandler.cs
- DiscreteKeyFrames.cs
- XmlSchemaDocumentation.cs
- CuspData.cs
- Expander.cs
- ArrayList.cs
- WebPartZoneCollection.cs
- DesignerObjectListAdapter.cs
- SafeCoTaskMem.cs
- DESCryptoServiceProvider.cs
- LookupBindingPropertiesAttribute.cs
- HitTestResult.cs
- LinearGradientBrush.cs
- ObservableDictionary.cs
- Brush.cs
- Nullable.cs
- RegexCompilationInfo.cs
- ThreadBehavior.cs
- FixedHighlight.cs
- BrowserCapabilitiesFactoryBase.cs
- ProjectionCamera.cs
- DataServiceQueryException.cs
- StrokeCollection.cs
- GeneralTransformCollection.cs
- StringFunctions.cs
- OpenFileDialog.cs
- FileVersion.cs
- TextDecorationCollectionConverter.cs
- _AutoWebProxyScriptHelper.cs