Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ComponentModel / COM2Interop / COM2IProvidePropertyBuilderHandler.cs / 1305376 / COM2IProvidePropertyBuilderHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ComponentModel.Com2Interop { using System.ComponentModel; using System.Diagnostics; using System; using System.Collections; using Microsoft.Win32; using System.Drawing.Design; [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal class Com2IProvidePropertyBuilderHandler : Com2ExtendedBrowsingHandler { public override Type Interface { get { return typeof(NativeMethods.IProvidePropertyBuilder); } } private bool GetBuilderGuidString(NativeMethods.IProvidePropertyBuilder target, int dispid, ref string strGuidBldr, int[] bldrType) { bool valid = false; string[] pGuidBldr = new string[1]; if (NativeMethods.Failed(target.MapPropertyToBuilder(dispid, bldrType, pGuidBldr, ref valid))) { valid = false; } if (valid && (bldrType[0] & _CTLBLDTYPE.CTLBLDTYPE_FINTERNALBUILDER) == 0) { valid = false; Debug.Fail("Property Browser doesn't support standard builders -- NYI"); } if (!valid) { return false; } if (pGuidBldr[0] == null) { strGuidBldr = Guid.Empty.ToString(); } else { strGuidBldr = pGuidBldr[0]; } return true; } public override void SetupPropertyHandlers(Com2PropertyDescriptor[] propDesc) { if (propDesc == null) { return; } for (int i = 0; i < propDesc.Length; i++) { propDesc[i].QueryGetBaseAttributes += new GetAttributesEventHandler(this.OnGetBaseAttributes); propDesc[i].QueryGetTypeConverterAndTypeEditor += new GetTypeConverterAndTypeEditorEventHandler(this.OnGetTypeConverterAndTypeEditor); } } ////// /// Here is where we handle IVsPerPropertyBrowsing.GetLocalizedPropertyInfo and IVsPerPropertyBrowsing. HideProperty /// such as IPerPropertyBrowsing, IProvidePropertyBuilder, etc. /// private void OnGetBaseAttributes(Com2PropertyDescriptor sender, GetAttributesEvent attrEvent) { NativeMethods.IProvidePropertyBuilder target = sender.TargetObject as NativeMethods.IProvidePropertyBuilder; if (target != null ) { string s = null; bool builderValid = GetBuilderGuidString(target, sender.DISPID, ref s, new int[1]); // we hide IDispatch props by default, we we need to force showing them here if (sender.CanShow && builderValid) { if (typeof(UnsafeNativeMethods.IDispatch).IsAssignableFrom(sender.PropertyType)) { attrEvent.Add(BrowsableAttribute.Yes); } } } } private void OnGetTypeConverterAndTypeEditor(Com2PropertyDescriptor sender, GetTypeConverterAndTypeEditorEvent gveevent) { object target = sender.TargetObject; if (target is NativeMethods.IProvidePropertyBuilder) { NativeMethods.IProvidePropertyBuilder propBuilder = (NativeMethods.IProvidePropertyBuilder)target; int[] pctlBldType = new int[1]; string guidString = null; if (GetBuilderGuidString(propBuilder, sender.DISPID, ref guidString, pctlBldType)) { gveevent.TypeEditor = new Com2PropertyBuilderUITypeEditor(sender, guidString, pctlBldType[0], (UITypeEditor)gveevent.TypeEditor); } } } } } // 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.ComponentModel; using System.Diagnostics; using System; using System.Collections; using Microsoft.Win32; using System.Drawing.Design; [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal class Com2IProvidePropertyBuilderHandler : Com2ExtendedBrowsingHandler { public override Type Interface { get { return typeof(NativeMethods.IProvidePropertyBuilder); } } private bool GetBuilderGuidString(NativeMethods.IProvidePropertyBuilder target, int dispid, ref string strGuidBldr, int[] bldrType) { bool valid = false; string[] pGuidBldr = new string[1]; if (NativeMethods.Failed(target.MapPropertyToBuilder(dispid, bldrType, pGuidBldr, ref valid))) { valid = false; } if (valid && (bldrType[0] & _CTLBLDTYPE.CTLBLDTYPE_FINTERNALBUILDER) == 0) { valid = false; Debug.Fail("Property Browser doesn't support standard builders -- NYI"); } if (!valid) { return false; } if (pGuidBldr[0] == null) { strGuidBldr = Guid.Empty.ToString(); } else { strGuidBldr = pGuidBldr[0]; } return true; } public override void SetupPropertyHandlers(Com2PropertyDescriptor[] propDesc) { if (propDesc == null) { return; } for (int i = 0; i < propDesc.Length; i++) { propDesc[i].QueryGetBaseAttributes += new GetAttributesEventHandler(this.OnGetBaseAttributes); propDesc[i].QueryGetTypeConverterAndTypeEditor += new GetTypeConverterAndTypeEditorEventHandler(this.OnGetTypeConverterAndTypeEditor); } } ////// /// Here is where we handle IVsPerPropertyBrowsing.GetLocalizedPropertyInfo and IVsPerPropertyBrowsing. HideProperty /// such as IPerPropertyBrowsing, IProvidePropertyBuilder, etc. /// private void OnGetBaseAttributes(Com2PropertyDescriptor sender, GetAttributesEvent attrEvent) { NativeMethods.IProvidePropertyBuilder target = sender.TargetObject as NativeMethods.IProvidePropertyBuilder; if (target != null ) { string s = null; bool builderValid = GetBuilderGuidString(target, sender.DISPID, ref s, new int[1]); // we hide IDispatch props by default, we we need to force showing them here if (sender.CanShow && builderValid) { if (typeof(UnsafeNativeMethods.IDispatch).IsAssignableFrom(sender.PropertyType)) { attrEvent.Add(BrowsableAttribute.Yes); } } } } private void OnGetTypeConverterAndTypeEditor(Com2PropertyDescriptor sender, GetTypeConverterAndTypeEditorEvent gveevent) { object target = sender.TargetObject; if (target is NativeMethods.IProvidePropertyBuilder) { NativeMethods.IProvidePropertyBuilder propBuilder = (NativeMethods.IProvidePropertyBuilder)target; int[] pctlBldType = new int[1]; string guidString = null; if (GetBuilderGuidString(propBuilder, sender.DISPID, ref guidString, pctlBldType)) { gveevent.TypeEditor = new Com2PropertyBuilderUITypeEditor(sender, guidString, pctlBldType[0], (UITypeEditor)gveevent.TypeEditor); } } } } } // 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
- Double.cs
- PropertyTabChangedEvent.cs
- QueryOperator.cs
- RelatedImageListAttribute.cs
- Vector3DValueSerializer.cs
- RoleManagerEventArgs.cs
- XsdBuilder.cs
- TypeHelper.cs
- BooleanToVisibilityConverter.cs
- ConfigurationValidatorAttribute.cs
- MetadataExporter.cs
- DataControlReferenceCollection.cs
- DataTransferEventArgs.cs
- ActivityFunc.cs
- PanelStyle.cs
- PaintValueEventArgs.cs
- ReadOnlyHierarchicalDataSourceView.cs
- X509RawDataKeyIdentifierClause.cs
- WindowsStartMenu.cs
- ColorConvertedBitmap.cs
- InkSerializer.cs
- FileNotFoundException.cs
- ConsoleKeyInfo.cs
- PixelFormats.cs
- CalendarKeyboardHelper.cs
- StatusBar.cs
- StylusCollection.cs
- FieldNameLookup.cs
- Point3DCollection.cs
- CaretElement.cs
- ConditionalAttribute.cs
- RawStylusActions.cs
- CompiledAction.cs
- graph.cs
- ArgumentException.cs
- CriticalFinalizerObject.cs
- BamlBinaryWriter.cs
- TextSelectionHighlightLayer.cs
- ScrollData.cs
- TextSelection.cs
- ResourceContainer.cs
- Collection.cs
- GridViewRowCollection.cs
- FirstQueryOperator.cs
- PropertyDescriptorCollection.cs
- MetadataPropertyAttribute.cs
- WebPartChrome.cs
- AppSettingsReader.cs
- xmlsaver.cs
- SrgsGrammar.cs
- HandleDictionary.cs
- StateBag.cs
- CodeStatement.cs
- SectionXmlInfo.cs
- SecurityUtils.cs
- ContextMenuStripActionList.cs
- DependencyPropertyConverter.cs
- PointAnimation.cs
- RenderData.cs
- ExpressionBindingCollection.cs
- CreateParams.cs
- InputScope.cs
- FormViewActionList.cs
- Part.cs
- Substitution.cs
- TextParentUndoUnit.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- PersonalizationProviderHelper.cs
- SqlDataSourceCache.cs
- XmlNodeComparer.cs
- FormatterServices.cs
- AsyncCompletedEventArgs.cs
- AutomationTextAttribute.cs
- OleDbDataAdapter.cs
- ExpressionBindingCollection.cs
- SQLBinary.cs
- InputProcessorProfiles.cs
- BamlBinaryReader.cs
- EntityDataSourceEntityTypeFilterItem.cs
- DiscriminatorMap.cs
- BinaryParser.cs
- LinqDataSourceHelper.cs
- UnknownBitmapDecoder.cs
- TokenBasedSet.cs
- EmbeddedObject.cs
- ColumnResizeAdorner.cs
- COMException.cs
- HttpHandlersSection.cs
- OleDbRowUpdatedEvent.cs
- SafeNativeMethods.cs
- WizardForm.cs
- brushes.cs
- CryptoConfig.cs
- ProfilePropertySettingsCollection.cs
- TripleDES.cs
- SinglePageViewer.cs
- ListBase.cs
- SqlTriggerContext.cs
- SoapEnumAttribute.cs
- SQLSingleStorage.cs