Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / TabItemAutomationPeer.cs / 1305600 / TabItemAutomationPeer.cs
using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Windows; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class TabItemAutomationPeer : SelectorItemAutomationPeer, ISelectionItemProvider { /// public TabItemAutomationPeer(object owner, TabControlAutomationPeer tabControlAutomationPeer) : base(owner, tabControlAutomationPeer) {} /// override protected string GetClassNameCore() { return "TabItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.TabItem; } // Return the base without the AccessKey character /// override protected string GetNameCore() { string result = base.GetNameCore(); if (!string.IsNullOrEmpty(result)) { TabItem tabItem = GetWrapper() as TabItem; if ((tabItem != null) && (tabItem.Header is string)) { return AccessText.RemoveAccessKeyMarker(result); } } return result; } // Selected TabItem content is located under the TabControl style visual tree /// protected override ListGetChildrenCore() { // Call the base in case we have children in the header List headerChildren = base.GetChildrenCore(); // Only if the TabItem is selected we need to add its visual children TabItem tabItem = GetWrapper() as TabItem; if (tabItem != null && tabItem.IsSelected) { TabControl parentTabControl = ItemsControlAutomationPeer.Owner as TabControl; if (parentTabControl != null) { ContentPresenter contentHost = parentTabControl.SelectedContentPresenter; if (contentHost != null) { AutomationPeer contentHostPeer = new FrameworkElementAutomationPeer(contentHost); List contentChildren = contentHostPeer.GetChildren(); if (contentChildren != null) { if (headerChildren == null) headerChildren = contentChildren; else headerChildren.AddRange(contentChildren); } } } } return headerChildren; } void ISelectionItemProvider.RemoveFromSelection() { if (!IsEnabled()) throw new ElementNotEnabledException(); TabItem tabItem = GetWrapper() as TabItem; if ((tabItem != null) && tabItem.IsSelected) { throw new InvalidOperationException(SR.Get(SRID.UIA_OperationCannotBePerformed)); } } /// Realization for TabItem is tied to selection, bringing item into view for realizing the element /// as done for controls like ListBox doesn't make sense for TabControl. internal override void RealizeCore() { ISelectionItemProvider selectionItemProvider = this as ISelectionItemProvider; Selector parentSelector = (Selector)(ItemsControlAutomationPeer.Owner); if (parentSelector != null && selectionItemProvider != null) { if (parentSelector.CanSelectMultiple) selectionItemProvider.AddToSelection(); else selectionItemProvider.Select(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Windows; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class TabItemAutomationPeer : SelectorItemAutomationPeer, ISelectionItemProvider { /// public TabItemAutomationPeer(object owner, TabControlAutomationPeer tabControlAutomationPeer) : base(owner, tabControlAutomationPeer) {} /// override protected string GetClassNameCore() { return "TabItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.TabItem; } // Return the base without the AccessKey character /// override protected string GetNameCore() { string result = base.GetNameCore(); if (!string.IsNullOrEmpty(result)) { TabItem tabItem = GetWrapper() as TabItem; if ((tabItem != null) && (tabItem.Header is string)) { return AccessText.RemoveAccessKeyMarker(result); } } return result; } // Selected TabItem content is located under the TabControl style visual tree /// protected override List GetChildrenCore() { // Call the base in case we have children in the header List headerChildren = base.GetChildrenCore(); // Only if the TabItem is selected we need to add its visual children TabItem tabItem = GetWrapper() as TabItem; if (tabItem != null && tabItem.IsSelected) { TabControl parentTabControl = ItemsControlAutomationPeer.Owner as TabControl; if (parentTabControl != null) { ContentPresenter contentHost = parentTabControl.SelectedContentPresenter; if (contentHost != null) { AutomationPeer contentHostPeer = new FrameworkElementAutomationPeer(contentHost); List contentChildren = contentHostPeer.GetChildren(); if (contentChildren != null) { if (headerChildren == null) headerChildren = contentChildren; else headerChildren.AddRange(contentChildren); } } } } return headerChildren; } void ISelectionItemProvider.RemoveFromSelection() { if (!IsEnabled()) throw new ElementNotEnabledException(); TabItem tabItem = GetWrapper() as TabItem; if ((tabItem != null) && tabItem.IsSelected) { throw new InvalidOperationException(SR.Get(SRID.UIA_OperationCannotBePerformed)); } } /// Realization for TabItem is tied to selection, bringing item into view for realizing the element /// as done for controls like ListBox doesn't make sense for TabControl. internal override void RealizeCore() { ISelectionItemProvider selectionItemProvider = this as ISelectionItemProvider; Selector parentSelector = (Selector)(ItemsControlAutomationPeer.Owner); if (parentSelector != null && selectionItemProvider != null) { if (parentSelector.CanSelectMultiple) selectionItemProvider.AddToSelection(); else selectionItemProvider.Select(); } } } } // 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
- FontDialog.cs
- SqlClientMetaDataCollectionNames.cs
- GPStream.cs
- MultiPageTextView.cs
- PackagePartCollection.cs
- VisualBrush.cs
- MouseEvent.cs
- ThemeableAttribute.cs
- SerializableAttribute.cs
- FilterElement.cs
- GiveFeedbackEvent.cs
- SrgsRulesCollection.cs
- RegexMatchCollection.cs
- TableItemStyle.cs
- XmlSchemaException.cs
- InkCanvasFeedbackAdorner.cs
- Journal.cs
- TextDecorationCollection.cs
- WebPartConnectionsConfigureVerb.cs
- DeclaredTypeValidatorAttribute.cs
- SHA1CryptoServiceProvider.cs
- BaseResourcesBuildProvider.cs
- Typography.cs
- CookieHandler.cs
- HttpFileCollectionBase.cs
- TreeViewEvent.cs
- ProfileInfo.cs
- FunctionQuery.cs
- HandleRef.cs
- DataServices.cs
- Popup.cs
- AssertSection.cs
- QueryableDataSourceView.cs
- AttachmentService.cs
- ResourceDisplayNameAttribute.cs
- DbMetaDataCollectionNames.cs
- DynamicRendererThreadManager.cs
- Literal.cs
- EmptyTextWriter.cs
- DetailsViewRowCollection.cs
- DbProviderFactory.cs
- BamlBinaryReader.cs
- CollectionEditVerbManager.cs
- Point3DConverter.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- EntityDataSourceSelectedEventArgs.cs
- StringHelper.cs
- SoapAttributeAttribute.cs
- Coordinator.cs
- Ipv6Element.cs
- safePerfProviderHandle.cs
- DLinqTableProvider.cs
- MergeFailedEvent.cs
- AxHostDesigner.cs
- StandardCommands.cs
- FilteredDataSetHelper.cs
- SqlRowUpdatingEvent.cs
- Int64KeyFrameCollection.cs
- SystemGatewayIPAddressInformation.cs
- _IPv4Address.cs
- TlsnegoTokenAuthenticator.cs
- ServiceNameElement.cs
- ViewgenGatekeeper.cs
- _OSSOCK.cs
- DataGridDesigner.cs
- XPathDocumentIterator.cs
- PageThemeCodeDomTreeGenerator.cs
- CompositionTarget.cs
- WindowsToolbarAsMenu.cs
- WebReferencesBuildProvider.cs
- PageThemeBuildProvider.cs
- TableRowCollection.cs
- ProcessHostServerConfig.cs
- TableChangeProcessor.cs
- SqlNotificationRequest.cs
- WebServiceMethodData.cs
- QueryModel.cs
- DynamicDataExtensions.cs
- Polygon.cs
- WindowsRichEdit.cs
- PngBitmapDecoder.cs
- ExpandedWrapper.cs
- NonParentingControl.cs
- DescriptionAttribute.cs
- SymLanguageType.cs
- MergePropertyDescriptor.cs
- XamlRtfConverter.cs
- NoneExcludedImageIndexConverter.cs
- Blend.cs
- HtmlProps.cs
- LocatorPart.cs
- PnrpPermission.cs
- WindowsClaimSet.cs
- HwndHost.cs
- X509ChainPolicy.cs
- Roles.cs
- PropertyCondition.cs
- AuthorizationSection.cs
- PromptBuilder.cs
- SafeHandle.cs