Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / WindowsToolbarItemAsMenuItem.cs / 1 / WindowsToolbarItemAsMenuItem.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Some applications implement menus with toolbars. This proxy // will used the IAccessible to expose these toolbar items as // menu items. This proxy is derived from ToolbarItem since // the underlying control really is a toolbar and ToolbarItem // knows how to communicate with a toolbars to get information for // toolbar items already. // // History: // 01/31/2005 : [....] Created //--------------------------------------------------------------------------- using System; using System.Windows.Automation; using MS.Win32; namespace MS.Internal.AutomationProxies { class ToolbarItemAsMenuItem : ToolbarItem { // ----------------------------------------------------- // // Constructors // // ----------------------------------------------------- #region Constructors internal ToolbarItemAsMenuItem(IntPtr hwnd, ProxyFragment parent, int item, int idCommand, Accessible acc) : base(hwnd, parent, item, idCommand) { _acc = acc; // Set the control type based on the IAccessible role. AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuItem) { _cControlType = ControlType.MenuItem; } else { System.Diagnostics.Debug.Assert(false, "Unexpected role " + role); } // MenuItems are by default KeyboardFocusable. _fIsKeyboardFocusable = true; } #endregion // ------------------------------------------------------ // // Patterns Implementation // // ----------------------------------------------------- #region ProxySimple Interface // Returns a pattern interface if supported. internal override object GetPatternProvider (AutomationPattern iid) { // Treate these toolbar items as menuitems and only support Invoke or Expand/Collapse patterns. // Invoke Pattern needs to be supported when the item has no children. When the item does have // children it needs to support ExpandCollapse Pattern. // Check if button is a separator if (IsSeparator()) { return null; } // Check if button is disabled if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONENABLED, new IntPtr(_idCommand), IntPtr.Zero) == 0) { return null; } // Check if button is hidden if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(_idCommand), IntPtr.Zero) != 0) { return null; } // if (iid == InvokePattern.Pattern) { // button is enabled and not hidden and not a separator return this; } // return null; } // Process all the Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.HasKeyboardFocusProperty) { return IsFocused(); } return base.GetElementProperty(idProp); } #endregion // ------------------------------------------------------ // // Private Fields // // ------------------------------------------------------ #region Private Fields Accessible _acc; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Some applications implement menus with toolbars. This proxy // will used the IAccessible to expose these toolbar items as // menu items. This proxy is derived from ToolbarItem since // the underlying control really is a toolbar and ToolbarItem // knows how to communicate with a toolbars to get information for // toolbar items already. // // History: // 01/31/2005 : [....] Created //--------------------------------------------------------------------------- using System; using System.Windows.Automation; using MS.Win32; namespace MS.Internal.AutomationProxies { class ToolbarItemAsMenuItem : ToolbarItem { // ----------------------------------------------------- // // Constructors // // ----------------------------------------------------- #region Constructors internal ToolbarItemAsMenuItem(IntPtr hwnd, ProxyFragment parent, int item, int idCommand, Accessible acc) : base(hwnd, parent, item, idCommand) { _acc = acc; // Set the control type based on the IAccessible role. AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuItem) { _cControlType = ControlType.MenuItem; } else { System.Diagnostics.Debug.Assert(false, "Unexpected role " + role); } // MenuItems are by default KeyboardFocusable. _fIsKeyboardFocusable = true; } #endregion // ------------------------------------------------------ // // Patterns Implementation // // ----------------------------------------------------- #region ProxySimple Interface // Returns a pattern interface if supported. internal override object GetPatternProvider (AutomationPattern iid) { // Treate these toolbar items as menuitems and only support Invoke or Expand/Collapse patterns. // Invoke Pattern needs to be supported when the item has no children. When the item does have // children it needs to support ExpandCollapse Pattern. // Check if button is a separator if (IsSeparator()) { return null; } // Check if button is disabled if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONENABLED, new IntPtr(_idCommand), IntPtr.Zero) == 0) { return null; } // Check if button is hidden if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(_idCommand), IntPtr.Zero) != 0) { return null; } // if (iid == InvokePattern.Pattern) { // button is enabled and not hidden and not a separator return this; } // return null; } // Process all the Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.HasKeyboardFocusProperty) { return IsFocused(); } return base.GetElementProperty(idProp); } #endregion // ------------------------------------------------------ // // Private Fields // // ------------------------------------------------------ #region Private Fields Accessible _acc; #endregion } } // 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
- SystemGatewayIPAddressInformation.cs
- ReadOnlyAttribute.cs
- TemplateXamlParser.cs
- CacheAxisQuery.cs
- XmlSerializerVersionAttribute.cs
- WinFormsSpinner.cs
- Viewport3DVisual.cs
- ProxySimple.cs
- EndpointIdentity.cs
- InfoCardPolicy.cs
- FormsAuthenticationUserCollection.cs
- DrawingGroup.cs
- WebPartEditorApplyVerb.cs
- NegotiationTokenAuthenticator.cs
- CodeGeneratorOptions.cs
- Trace.cs
- CompilerGeneratedAttribute.cs
- FixUpCollection.cs
- Transform3DGroup.cs
- DriveInfo.cs
- WebConfigurationFileMap.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- MetadataUtil.cs
- SynchronizationValidator.cs
- NumberSubstitution.cs
- HttpInputStream.cs
- HtmlTableCellCollection.cs
- UnsafeNativeMethodsCLR.cs
- WizardSideBarListControlItemEventArgs.cs
- GenericQueueSurrogate.cs
- WindowsListView.cs
- UnmanagedMemoryStream.cs
- ForceCopyBuildProvider.cs
- mda.cs
- XamlSerializer.cs
- FontFamilyIdentifier.cs
- SettingsProperty.cs
- ListViewInsertionMark.cs
- NullableLongMinMaxAggregationOperator.cs
- Encoding.cs
- PhysicalAddress.cs
- Separator.cs
- XmlKeywords.cs
- TypeForwardedFromAttribute.cs
- ErrorHandler.cs
- SiteOfOriginPart.cs
- TreeBuilder.cs
- FontInfo.cs
- DrawingContextWalker.cs
- ViewCellRelation.cs
- ImageAnimator.cs
- SqlRewriteScalarSubqueries.cs
- DynamicMethod.cs
- ApplicationId.cs
- ViewSimplifier.cs
- SqlParameterCollection.cs
- GeneralTransform2DTo3D.cs
- ProfileSection.cs
- AssociationSetMetadata.cs
- UriSection.cs
- XmlDataCollection.cs
- CodeGeneratorAttribute.cs
- TextMarkerSource.cs
- RadioButton.cs
- Triangle.cs
- SQLByteStorage.cs
- DataGridViewRowsAddedEventArgs.cs
- Token.cs
- DrawingImage.cs
- SqlBulkCopy.cs
- PipeStream.cs
- DbDeleteCommandTree.cs
- TableRow.cs
- CompiledQuery.cs
- DynamicDocumentPaginator.cs
- BuildDependencySet.cs
- XslUrlEditor.cs
- AudienceUriMode.cs
- TdsParserHelperClasses.cs
- UnsafeNativeMethods.cs
- UnionQueryOperator.cs
- _ConnectStream.cs
- ChannelDispatcher.cs
- PlanCompilerUtil.cs
- EasingFunctionBase.cs
- ForeignKeyFactory.cs
- SAPICategories.cs
- Int32.cs
- ActiveXContainer.cs
- TiffBitmapEncoder.cs
- DelegateSerializationHolder.cs
- MdiWindowListStrip.cs
- ParseHttpDate.cs
- Int16AnimationUsingKeyFrames.cs
- DataGridLengthConverter.cs
- TextRunCache.cs
- IsolatedStorageFile.cs
- PagesSection.cs
- ResolveNameEventArgs.cs
- FixedSOMSemanticBox.cs