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
- Int64KeyFrameCollection.cs
- Converter.cs
- ObfuscationAttribute.cs
- PartialList.cs
- WebServiceFault.cs
- NotifyCollectionChangedEventArgs.cs
- ArcSegment.cs
- InheritanceContextChangedEventManager.cs
- User.cs
- Int32CollectionValueSerializer.cs
- FontStyle.cs
- NegotiateStream.cs
- Vector3DCollectionConverter.cs
- MimeImporter.cs
- DynamicAttribute.cs
- FontCollection.cs
- storepermission.cs
- BindValidator.cs
- GlyphsSerializer.cs
- WindowsEditBoxRange.cs
- IndexingContentUnit.cs
- PageThemeBuildProvider.cs
- ArgumentsParser.cs
- remotingproxy.cs
- ButtonBaseAutomationPeer.cs
- PtsHost.cs
- DataGridAutomationPeer.cs
- JsonSerializer.cs
- NonBatchDirectoryCompiler.cs
- SelectionRangeConverter.cs
- IDispatchConstantAttribute.cs
- BindingExpressionUncommonField.cs
- ValueTypeFixupInfo.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Brush.cs
- HyperLinkColumn.cs
- HttpAsyncResult.cs
- AudioDeviceOut.cs
- AppDomainAttributes.cs
- XmlAttributeAttribute.cs
- SettingsAttributes.cs
- SqlDataSourceView.cs
- typedescriptorpermission.cs
- CqlQuery.cs
- XmlNodeComparer.cs
- datacache.cs
- WindowsAuthenticationModule.cs
- MachineKeySection.cs
- MissingSatelliteAssemblyException.cs
- LinkDescriptor.cs
- RowsCopiedEventArgs.cs
- TextSchema.cs
- UrlPath.cs
- MouseCaptureWithinProperty.cs
- ErrorProvider.cs
- ThumbAutomationPeer.cs
- NumberFunctions.cs
- TextTreeInsertUndoUnit.cs
- IMembershipProvider.cs
- IxmlLineInfo.cs
- NameValuePermission.cs
- CodeDelegateInvokeExpression.cs
- KeyedHashAlgorithm.cs
- BitStack.cs
- AuthenticatedStream.cs
- Grammar.cs
- UIElementParagraph.cs
- Splitter.cs
- ResourceAttributes.cs
- TokenBasedSetEnumerator.cs
- WorkflowServiceBehavior.cs
- View.cs
- TiffBitmapDecoder.cs
- SymbolEqualComparer.cs
- SettingsSavedEventArgs.cs
- XamlWriter.cs
- MenuItemStyle.cs
- DesigntimeLicenseContextSerializer.cs
- DataColumnMapping.cs
- MemberNameValidator.cs
- DefaultWorkflowLoaderService.cs
- HttpResponseWrapper.cs
- sqlmetadatafactory.cs
- DeferredTextReference.cs
- WCFServiceClientProxyGenerator.cs
- WebRequestModuleElementCollection.cs
- NetworkCredential.cs
- FieldToken.cs
- InvalidAsynchronousStateException.cs
- adornercollection.cs
- XmlSerializerSection.cs
- AddInSegmentDirectoryNotFoundException.cs
- BlockCollection.cs
- WebBaseEventKeyComparer.cs
- AlgoModule.cs
- CompileXomlTask.cs
- PolyLineSegment.cs
- BamlRecords.cs
- SizeChangedInfo.cs
- QilExpression.cs