Пример #1
0
        // Token: 0x06002644 RID: 9796 RVA: 0x000B67D4 File Offset: 0x000B49D4
        protected override void SetFocusCore()
        {
            UIElementAutomationPeer wrapperPeer = this.WrapperPeer;

            if (wrapperPeer != null)
            {
                wrapperPeer.SetFocus();
                return;
            }
            this.ThrowElementNotAvailableException();
        }
        /// <summary>Sends a request to activate a control and initiate its single, unambiguous action.</summary>
        // Token: 0x060025C6 RID: 9670 RVA: 0x000B5288 File Offset: 0x000B3488
        void IInvokeProvider.Invoke()
        {
            UIElementAutomationPeer uielementAutomationPeer = this.GetWrapperPeer() as UIElementAutomationPeer;

            if (uielementAutomationPeer != null)
            {
                ((DataGridColumnHeader)uielementAutomationPeer.Owner).Invoke();
                return;
            }
            base.ThrowElementNotAvailableException();
        }
        // Token: 0x06002529 RID: 9513 RVA: 0x000B319C File Offset: 0x000B139C
        protected override List <AutomationPeer> GetChildrenCore()
        {
            if (this.OwningCalendar.MonthControl == null)
            {
                return(null);
            }
            List <AutomationPeer> list = new List <AutomationPeer>();
            Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer> dictionary = new Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer>();
            AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.PreviousButton);

            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.HeaderButton);
            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.NextButton);
            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            foreach (object obj in this.OwningGrid.Children)
            {
                UIElement uielement = (UIElement)obj;
                int       num       = (int)uielement.GetValue(Grid.RowProperty);
                if (this.OwningCalendar.DisplayMode == CalendarMode.Month && num == 0)
                {
                    AutomationPeer automationPeer2 = UIElementAutomationPeer.CreatePeerForElement(uielement);
                    if (automationPeer2 != null)
                    {
                        list.Add(automationPeer2);
                    }
                }
                else
                {
                    Button button = uielement as Button;
                    if (button != null && button.DataContext is DateTime)
                    {
                        DateTime date = (DateTime)button.DataContext;
                        DateTimeAutomationPeer orCreateDateTimeAutomationPeer = this.GetOrCreateDateTimeAutomationPeer(date, this.OwningCalendar.DisplayMode, false);
                        list.Add(orCreateDateTimeAutomationPeer);
                        DateTimeCalendarModePair key = new DateTimeCalendarModePair(date, this.OwningCalendar.DisplayMode);
                        dictionary.Add(key, orCreateDateTimeAutomationPeer);
                    }
                }
            }
            this.DateTimePeers = dictionary;
            return(list);
        }
Пример #4
0
        ///
        void IViewAutomationPeer.ItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            ListViewAutomationPeer peer = UIElementAutomationPeer.FromElement(_listview) as ListViewAutomationPeer;

            if (peer != null)
            {
                if (_oldItemsCount != _listview.Items.Count)
                {
                    peer.RaisePropertyChangedEvent(GridPatternIdentifiers.RowCountProperty, _oldItemsCount, _listview.Items.Count);
                }
                _oldItemsCount = _listview.Items.Count;
            }
        }
Пример #5
0
        void IInvokeProvider.Invoke()
        {
            UIElementAutomationPeer wrapperPeer = GetWrapperPeer() as UIElementAutomationPeer;

            if (wrapperPeer != null)
            {
                ((DataGridColumnHeader)wrapperPeer.Owner).Invoke();
            }
            else
            {
                ThrowElementNotAvailableException();
            }
        }
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = base.GetChildrenCore();

            if (OwningDatePicker.IsDropDownOpen && OwningDatePicker.Calendar != null)
            {
                CalendarAutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(OwningDatePicker.Calendar) as CalendarAutomationPeer;
                if (peer != null)
                {
                    children.Add(peer);
                }
            }
            return(children);
        }
        ///For ComboBoxItem for which peer is this element only, scrolling should happen when the pop-up is expanded.
        internal override void RealizeCore()
        {
            ComboBox parent = ItemsControlAutomationPeer.Owner as ComboBox;

            if (parent != null)
            {
                IExpandCollapseProvider iecp = (IExpandCollapseProvider)UIElementAutomationPeer.FromElement(parent) as ComboBoxAutomationPeer;
                if (iecp.ExpandCollapseState != ExpandCollapseState.Expanded)
                {
                    iecp.Expand();
                }
            }
            base.RealizeCore();
        }
Пример #8
0
        /// <summary>Returns the UI Automation provider for the specified cell.</summary>
        /// <param name="row">The ordinal number of the row of interest.</param>
        /// <param name="column">The ordinal number of the column of interest.</param>
        /// <returns>The UI Automation provider for the specified cell.</returns>
        // Token: 0x060026B4 RID: 9908 RVA: 0x000B7CA0 File Offset: 0x000B5EA0
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (row < 0 || row >= ((IGridProvider)this).RowCount)
            {
                throw new ArgumentOutOfRangeException("row");
            }
            if (column < 0 || column >= ((IGridProvider)this).ColumnCount)
            {
                throw new ArgumentOutOfRangeException("column");
            }
            ListViewItem listViewItem = this._listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem;

            if (listViewItem == null)
            {
                VirtualizingPanel virtualizingPanel = this._listview.ItemsHost as VirtualizingPanel;
                if (virtualizingPanel != null)
                {
                    virtualizingPanel.BringIndexIntoView(row);
                }
                listViewItem = (this._listview.ItemContainerGenerator.ContainerFromIndex(row) as ListViewItem);
                if (listViewItem != null)
                {
                    this._listview.Dispatcher.Invoke(DispatcherPriority.Loaded, new DispatcherOperationCallback((object arg) => null), null);
                }
            }
            if (listViewItem != null)
            {
                AutomationPeer automationPeer = UIElementAutomationPeer.FromElement(this._listview);
                if (automationPeer != null)
                {
                    AutomationPeer automationPeer2 = UIElementAutomationPeer.FromElement(listViewItem);
                    if (automationPeer2 != null)
                    {
                        AutomationPeer eventsSource = automationPeer2.EventsSource;
                        if (eventsSource != null)
                        {
                            automationPeer2 = eventsSource;
                        }
                        List <AutomationPeer> children = automationPeer2.GetChildren();
                        if (children.Count > column)
                        {
                            return(ElementProxy.StaticWrap(children[column], automationPeer));
                        }
                    }
                }
            }
            return(null);
        }
Пример #9
0
 /// <summary>Retrieves a collection of UI Automation providers that represents all the column headers associated with a table item or cell.</summary>
 /// <returns>A collection of UI Automation providers.</returns>
 // Token: 0x0600264F RID: 9807 RVA: 0x000B6A10 File Offset: 0x000B4C10
 IRawElementProviderSimple[] ITableItemProvider.GetColumnHeaderItems()
 {
     if (this.IsDayButton && this.OwningButton != null && this.OwningCalendar != null && this.OwningCalendarProvider != null)
     {
         IRawElementProviderSimple[] columnHeaders = ((ITableProvider)UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar)).GetColumnHeaders();
         if (columnHeaders != null)
         {
             int column = ((IGridItemProvider)this).Column;
             return(new IRawElementProviderSimple[]
             {
                 columnHeaders[column]
             });
         }
     }
     return(null);
 }
Пример #10
0
 /// <summary>Gets the collection of immediate child elements of the specified UI Automation peer.</summary>
 /// <param name="children">Collection of child objects you want to get.</param>
 /// <returns>Collection of child objects.</returns>
 // Token: 0x060026AB RID: 9899 RVA: 0x000B7A90 File Offset: 0x000B5C90
 List <AutomationPeer> IViewAutomationPeer.GetChildren(List <AutomationPeer> children)
 {
     if (this._owner.HeaderRowPresenter != null)
     {
         AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(this._owner.HeaderRowPresenter);
         if (automationPeer != null)
         {
             if (children == null)
             {
                 children = new List <AutomationPeer>();
             }
             children.Insert(0, automationPeer);
         }
     }
     return(children);
 }
Пример #11
0
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> list         = new List <AutomationPeer>();
            ItemsControl          itemscontrol = Owner as ItemsControl;

            if (itemscontrol != null)
            {
                foreach (object obj in itemscontrol.Items)
                {
                    if (obj is Separator)
                    {
                        Separator separator = obj as Separator;
                        list.Add(UIElementAutomationPeer.CreatePeerForElement(separator));
                    }
                    else
                    {
                        StatusBarItem item = itemscontrol.ItemContainerGenerator.ContainerFromItem(obj) as StatusBarItem;

                        if (item != null)
                        {
                            //If the item is a string or TextBlock or StatusBarItem
                            //StatusBarItemAutomationPeer will be created to show the text
                            //Or we'll use the control's automation peer
                            if (obj is string || obj is TextBlock ||
                                (obj is StatusBarItem && ((StatusBarItem)obj).Content is string))
                            {
                                list.Add(UIElementAutomationPeer.CreatePeerForElement(item));
                            }
                            else
                            {
                                List <AutomationPeer> childList = GetChildrenAutomationPeer(item);
                                if (childList != null)
                                {
                                    foreach (AutomationPeer ap in childList)
                                    {
                                        list.Add(ap);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(list);
        }
 /// <summary>Gets the control pattern for the <see cref="T:System.Windows.Controls.GroupItem" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.GroupItemAutomationPeer" />.</summary>
 /// <param name="patternInterface">One of the enumeration values.</param>
 /// <returns>If <paramref name="pattern" /> is <see cref="F:System.Windows.Automation.Peers.PatternInterface.ExpandCollapse" /> and the <see cref="T:System.Windows.Controls.GroupItem" />that is associated with this <see cref="T:System.Windows.Automation.Peers.GroupItemAutomationPeer" /> contains an <see cref="T:System.Windows.Controls.Expander" />, this method returns a reference to the current instance of the <see cref="T:System.Windows.Automation.Peers.GroupItemAutomationPeer" />.  Otherwise, this method calls the base implementation on <see cref="T:System.Windows.Automation.Peers.UIElementAutomationPeer" /> which returns <see langword="null" />.</returns>
 // Token: 0x060026E8 RID: 9960 RVA: 0x000B84DC File Offset: 0x000B66DC
 public override object GetPattern(PatternInterface patternInterface)
 {
     if (patternInterface == PatternInterface.ExpandCollapse)
     {
         GroupItem groupItem = (GroupItem)base.Owner;
         if (groupItem.Expander != null)
         {
             AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(groupItem.Expander);
             if (automationPeer != null && automationPeer is IExpandCollapseProvider)
             {
                 automationPeer.EventsSource = this;
                 return((IExpandCollapseProvider)automationPeer);
             }
         }
     }
     return(base.GetPattern(patternInterface));
 }
        /// <summary>
        /// Retrieves AutomationPeer for the document.
        /// </summary>
        /// <returns></returns>
        private AutomationPeer GetDocumentAutomationPeer()
        {
            AutomationPeer           documentPeer = null;
            IDocumentPaginatorSource document     = ((DocumentViewerBase)Owner).Document;

            if (document != null)
            {
                if (document is UIElement)
                {
                    documentPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)document);
                }
                else if (document is ContentElement)
                {
                    documentPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)document);
                }
            }
            return(documentPeer);
        }
        // Token: 0x06002567 RID: 9575 RVA: 0x000B4000 File Offset: 0x000B2200
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer>          list = base.GetChildrenCore();
            DataGridColumnHeadersPresenter columnHeadersPresenter = this.OwningDataGrid.ColumnHeadersPresenter;

            if (columnHeadersPresenter != null && columnHeadersPresenter.IsVisible)
            {
                AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(columnHeadersPresenter);
                if (automationPeer != null)
                {
                    if (list == null)
                    {
                        list = new List <AutomationPeer>(1);
                    }
                    list.Insert(0, automationPeer);
                }
            }
            return(list);
        }
        /// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.Controls.Expander" /> control that is associated with this <see cref="T:System.Windows.Automation.Peers.ExpanderAutomationPeer" />, and sets the event source of the templated toggle button to this <see cref="M:System.Windows.Automation.Peers.ExpanderAutomationPeer.GetChildrenCore" /> instance. </summary>
        /// <returns>The collection of child elements of the <see cref="T:System.Windows.Controls.Expander" /> control associated with this <see cref="T:System.Windows.Automation.Peers.ExpanderAutomationPeer" />. </returns>
        // Token: 0x06002673 RID: 9843 RVA: 0x000B7170 File Offset: 0x000B5370
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> childrenCore         = base.GetChildrenCore();
            ToggleButton          expanderToggleButton = ((Expander)base.Owner).ExpanderToggleButton;

            if (!AccessibilitySwitches.UseNetFx47CompatibleAccessibilityFeatures && childrenCore != null)
            {
                foreach (AutomationPeer automationPeer in childrenCore)
                {
                    UIElementAutomationPeer uielementAutomationPeer = (UIElementAutomationPeer)automationPeer;
                    if (uielementAutomationPeer.Owner == expanderToggleButton)
                    {
                        uielementAutomationPeer.EventsSource = ((!AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures && base.EventsSource != null) ? base.EventsSource : this);
                        break;
                    }
                }
            }
            return(childrenCore);
        }
Пример #16
0
        IRawElementProviderSimple[] ITableItemProvider.GetColumnHeaderItems()
        {
            ListView listview = _listviewAP.Owner as ListView;

            if (listview != null && listview.View is GridView)
            {
                GridView gridview = listview.View as GridView;
                if (gridview.HeaderRowPresenter != null && gridview.HeaderRowPresenter.ActualColumnHeaders.Count > Column)
                {
                    GridViewColumnHeader header = gridview.HeaderRowPresenter.ActualColumnHeaders[Column];
                    AutomationPeer       peer   = UIElementAutomationPeer.FromElement(header);
                    if (peer != null)
                    {
                        return(new IRawElementProviderSimple[] { ProviderFromPeer(peer) });
                    }
                }
            }
            return(new IRawElementProviderSimple[0]);
        }
 /// <summary>Retrieves a collection of UI Automation providers representing all the row headers associated with a table item or cell.</summary>
 /// <returns>A collection of UI Automation providers. </returns>
 // Token: 0x060025A7 RID: 9639 RVA: 0x000B4CE0 File Offset: 0x000B2EE0
 IRawElementProviderSimple[] ITableItemProvider.GetRowHeaderItems()
 {
     if (this.OwningDataGrid != null && (this.OwningDataGrid.HeadersVisibility & DataGridHeadersVisibility.Row) == DataGridHeadersVisibility.Row)
     {
         DataGridAutomationPeer     dataGridAutomationPeer     = UIElementAutomationPeer.CreatePeerForElement(this.OwningDataGrid) as DataGridAutomationPeer;
         DataGridItemAutomationPeer dataGridItemAutomationPeer = dataGridAutomationPeer.FindOrCreateItemAutomationPeer(this.Item) as DataGridItemAutomationPeer;
         if (dataGridItemAutomationPeer != null)
         {
             AutomationPeer rowHeaderAutomationPeer = dataGridItemAutomationPeer.RowHeaderAutomationPeer;
             if (rowHeaderAutomationPeer != null)
             {
                 return(new List <IRawElementProviderSimple>(1)
                 {
                     base.ProviderFromPeer(rowHeaderAutomationPeer)
                 }.ToArray());
             }
         }
     }
     return(null);
 }
Пример #18
0
        ///
        List <AutomationPeer> IViewAutomationPeer.GetChildren(List <AutomationPeer> children)
        {
            //Add GridViewHeaderRowPresenter as the first child of ListView
            if (_owner.HeaderRowPresenter != null)
            {
                AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(_owner.HeaderRowPresenter);
                if (peer != null)
                {
                    //If children is null, we still need to create an empty list to insert HeaderRowPresenter
                    if (children == null)
                    {
                        children = new List <AutomationPeer>();
                    }

                    children.Insert(0, peer);
                }
            }

            return(children);
        }
Пример #19
0
        /// <summary>Gets a collection of child elements. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary>
        /// <returns>A collection of child elements.</returns>
        // Token: 0x06002552 RID: 9554 RVA: 0x000B3D2C File Offset: 0x000B1F2C
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> list   = base.GetChildrenCore();
            ComboBox comboBox            = (ComboBox)base.Owner;
            TextBox  editableTextBoxSite = comboBox.EditableTextBoxSite;

            if (editableTextBoxSite != null)
            {
                AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(editableTextBoxSite);
                if (automationPeer != null)
                {
                    if (list == null)
                    {
                        list = new List <AutomationPeer>();
                    }
                    list.Insert(0, automationPeer);
                }
            }
            return(list);
        }
Пример #20
0
 /// <summary>Returns a collection of UI Automation providers that represents all the column headers in a table.</summary>
 /// <returns>A collection of UI Automation providers.</returns>
 // Token: 0x060026B0 RID: 9904 RVA: 0x000B7B94 File Offset: 0x000B5D94
 IRawElementProviderSimple[] ITableProvider.GetColumnHeaders()
 {
     if (this._owner.HeaderRowPresenter != null)
     {
         List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>(this._owner.HeaderRowPresenter.ActualColumnHeaders.Count);
         ListViewAutomationPeer           listViewAutomationPeer = UIElementAutomationPeer.FromElement(this._listview) as ListViewAutomationPeer;
         if (listViewAutomationPeer != null)
         {
             foreach (UIElement element in this._owner.HeaderRowPresenter.ActualColumnHeaders)
             {
                 AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(element);
                 if (automationPeer != null)
                 {
                     list.Add(ElementProxy.StaticWrap(automationPeer, listViewAutomationPeer));
                 }
             }
         }
         return(list.ToArray());
     }
     return(new IRawElementProviderSimple[0]);
 }
 /// <summary>Gets the control pattern for the <see cref="T:System.Windows.ContentElement" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ContentElementAutomationPeer" />.</summary>
 /// <param name="patternInterface">One of the enumeration values.</param>
 /// <returns>The current instance of the <see cref="T:System.Windows.Automation.Peers.TreeViewItemAutomationPeer" />, or <see langword="null" />.</returns>
 // Token: 0x06002862 RID: 10338 RVA: 0x000BC3B4 File Offset: 0x000BA5B4
 public override object GetPattern(PatternInterface patternInterface)
 {
     if (patternInterface == PatternInterface.Selection)
     {
         return(this);
     }
     if (patternInterface == PatternInterface.Scroll)
     {
         ItemsControl itemsControl = (ItemsControl)base.Owner;
         if (itemsControl.ScrollHost != null)
         {
             AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(itemsControl.ScrollHost);
             if (automationPeer != null && automationPeer is IScrollProvider)
             {
                 automationPeer.EventsSource = this;
                 return((IScrollProvider)automationPeer);
             }
         }
     }
     return(base.GetPattern(patternInterface));
 }
        /// <summary>Gets the collection of child elements of the <see cref="T:System.Windows.Controls.Primitives.StatusBar" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.StatusBarAutomationPeer" />. This method is called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary>
        /// <returns>A list of child elements.</returns>
        // Token: 0x06002805 RID: 10245 RVA: 0x000BB578 File Offset: 0x000B9778
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> list         = new List <AutomationPeer>();
            ItemsControl          itemsControl = base.Owner as ItemsControl;

            if (itemsControl != null)
            {
                foreach (object obj in ((IEnumerable)itemsControl.Items))
                {
                    if (obj is Separator)
                    {
                        Separator element = obj as Separator;
                        list.Add(UIElementAutomationPeer.CreatePeerForElement(element));
                    }
                    else
                    {
                        StatusBarItem statusBarItem = itemsControl.ItemContainerGenerator.ContainerFromItem(obj) as StatusBarItem;
                        if (statusBarItem != null)
                        {
                            if (obj is string || obj is TextBlock || (obj is StatusBarItem && ((StatusBarItem)obj).Content is string))
                            {
                                list.Add(UIElementAutomationPeer.CreatePeerForElement(statusBarItem));
                            }
                            else
                            {
                                List <AutomationPeer> childrenAutomationPeer = this.GetChildrenAutomationPeer(statusBarItem);
                                if (childrenAutomationPeer != null)
                                {
                                    foreach (AutomationPeer item in childrenAutomationPeer)
                                    {
                                        list.Add(item);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Пример #23
0
        // Token: 0x06002707 RID: 9991 RVA: 0x000B8B2C File Offset: 0x000B6D2C
        internal virtual AutomationPeer GetWrapperPeer()
        {
            AutomationPeer automationPeer = null;
            UIElement      wrapper        = this.GetWrapper();

            if (wrapper != null)
            {
                automationPeer = UIElementAutomationPeer.CreatePeerForElement(wrapper);
                if (automationPeer == null)
                {
                    if (wrapper is FrameworkElement)
                    {
                        automationPeer = new FrameworkElementAutomationPeer((FrameworkElement)wrapper);
                    }
                    else
                    {
                        automationPeer = new UIElementAutomationPeer(wrapper);
                    }
                }
            }
            return(automationPeer);
        }
Пример #24
0
        ///
        override public object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface == PatternInterface.Selection)
            {
                return(this);
            }
            else if (patternInterface == PatternInterface.Scroll)
            {
                ItemsControl owner = (ItemsControl)Owner;
                if (owner.ScrollHost != null)
                {
                    AutomationPeer scrollPeer = UIElementAutomationPeer.CreatePeerForElement(owner.ScrollHost);
                    if (scrollPeer != null && scrollPeer is IScrollProvider)
                    {
                        scrollPeer.EventsSource = this;
                        return((IScrollProvider)scrollPeer);
                    }
                }
            }

            return(base.GetPattern(patternInterface));
        }
        ///
        override public object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface == PatternInterface.VirtualizedItem)
            {
                if (VirtualizedItemPatternIdentifiers.Pattern != null)
                {
                    if (GetWrapperPeer() == null)
                    {
                        return(this);
                    }
                    else
                    {
                        // ItemsControlAutomationPeer can be null in case of TreeViewItems when parent TreeViewItem is also virtualized
                        // If the Item is in Automation Tree we consider it has Realized and need not return VirtualizeItem pattern.
                        if (ItemsControlAutomationPeer != null && !IsItemInAutomationTree())
                        {
                            return(this);
                        }

                        if (ItemsControlAutomationPeer == null)
                        {
                            return(this);
                        }
                    }
                }
                return(null);
            }
            else if (patternInterface == PatternInterface.SynchronizedInput)
            {
                UIElementAutomationPeer peer = GetWrapperPeer() as UIElementAutomationPeer;
                if (peer != null)
                {
                    return(peer.GetPattern(patternInterface));
                }
            }

            return(null);
        }
        /// <summary>Gets the control pattern for the <see cref="T:System.Windows.Controls.DocumentViewer" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.DocumentViewerAutomationPeer" />. </summary>
        /// <param name="patternInterface">One of the enumeration values.</param>
        /// <returns>If <paramref name="patternInterface" /> is <see cref="F:System.Windows.Automation.Peers.PatternInterface.ScrollItem" />, this method returns the <see cref="T:System.Windows.Automation.Peers.ScrollViewerAutomationPeer" /> for this <see cref="T:System.Windows.Automation.Peers.DocumentViewerAutomationPeer" />. This method also sets <see cref="T:System.Windows.Automation.Peers.DocumentViewerAutomationPeer" /> as the <see cref="P:System.Windows.Automation.Peers.AutomationPeer.EventsSource" />. </returns>
        // Token: 0x06002669 RID: 9833 RVA: 0x000B7020 File Offset: 0x000B5220
        public override object GetPattern(PatternInterface patternInterface)
        {
            object result = null;

            if (patternInterface == PatternInterface.Scroll)
            {
                DocumentViewer documentViewer = (DocumentViewer)base.Owner;
                if (documentViewer.ScrollViewer != null)
                {
                    AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(documentViewer.ScrollViewer);
                    if (automationPeer != null && automationPeer is IScrollProvider)
                    {
                        automationPeer.EventsSource = this;
                        result = automationPeer;
                    }
                }
            }
            else
            {
                result = base.GetPattern(patternInterface);
            }
            return(result);
        }
        virtual internal AutomationPeer GetWrapperPeer()
        {
            AutomationPeer wrapperPeer = null;
            UIElement      wrapper     = GetWrapper();

            if (wrapper != null)
            {
                wrapperPeer = UIElementAutomationPeer.CreatePeerForElement(wrapper);
                if (wrapperPeer == null) //fall back to default peer if there is no specific one
                {
                    if (wrapper is FrameworkElement)
                    {
                        wrapperPeer = new FrameworkElementAutomationPeer((FrameworkElement)wrapper);
                    }
                    else
                    {
                        wrapperPeer = new UIElementAutomationPeer(wrapper);
                    }
                }
            }

            return(wrapperPeer);
        }
Пример #28
0
        /// <summary>
        /// Collection of column headers
        /// </summary>
        IRawElementProviderSimple[] ITableProvider.GetColumnHeaders()
        {
            if (_owner.HeaderRowPresenter != null)
            {
                List <IRawElementProviderSimple> array  = new List <IRawElementProviderSimple>(_owner.HeaderRowPresenter.ActualColumnHeaders.Count);
                ListViewAutomationPeer           lvpeer = UIElementAutomationPeer.FromElement(_listview) as ListViewAutomationPeer;

                if (lvpeer != null)
                {
                    foreach (UIElement e in _owner.HeaderRowPresenter.ActualColumnHeaders)
                    {
                        AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(e);
                        if (peer != null)
                        {
                            array.Add(ElementProxy.StaticWrap(peer, lvpeer));
                        }
                    }
                }
                return(array.ToArray());
            }

            return(new IRawElementProviderSimple[0]);
        }
Пример #29
0
        ///
        override protected bool IsOffscreenCore()
        {
            IsOffscreenBehavior behavior = AutomationProperties.GetIsOffscreenBehavior(_owner);

            switch (behavior)
            {
            case IsOffscreenBehavior.Onscreen:
                return(false);

            case IsOffscreenBehavior.Offscreen:
                return(true);

            case IsOffscreenBehavior.FromClip:
            {
                bool isOffscreen = !_owner.IsVisible;

                if (!isOffscreen)
                {
                    UIElement containingUIElement = GetContainingUIElement(_owner);
                    if (containingUIElement != null)
                    {
                        Rect boundingRect = UIElementAutomationPeer.CalculateVisibleBoundingRect(containingUIElement);

                        isOffscreen = (DoubleUtil.AreClose(boundingRect, Rect.Empty) ||
                                       DoubleUtil.AreClose(boundingRect.Height, 0) ||
                                       DoubleUtil.AreClose(boundingRect.Width, 0));
                    }
                }

                return(isOffscreen);
            }

            default:
                return(!_owner.IsVisible);
            }
        }
Пример #30
0
        /// <summary>
        /// <see cref="AutomationPeer.GetPattern"/>
        /// </summary>
        public override object GetPattern(PatternInterface patternInterface)
        {
            object returnValue = null;

            if (patternInterface == PatternInterface.Scroll)
            {
                FlowDocumentScrollViewer owner = (FlowDocumentScrollViewer)Owner;
                if (owner.ScrollViewer != null)
                {
                    AutomationPeer scrollPeer = UIElementAutomationPeer.CreatePeerForElement(owner.ScrollViewer);
                    if (scrollPeer != null && scrollPeer is IScrollProvider)
                    {
                        scrollPeer.EventsSource = this;
                        returnValue             = scrollPeer;
                    }
                }
            }
            else if (patternInterface == PatternInterface.Text)
            {
                // Make sure that Automation children are created.
                this.GetChildren();

                // Re-expose TextPattern from hosted document.
                if (_documentPeer != null)
                {
                    _documentPeer.EventsSource = this;
                    returnValue = _documentPeer.GetPattern(patternInterface);
                }
            }
            else if (patternInterface == PatternInterface.SynchronizedInput)
            {
                returnValue = base.GetPattern(patternInterface);
            }

            return(returnValue);
        }
        protected override System.Collections.Generic.List<AutomationPeer> GetChildrenCore()
        {
            // If Ribbon is Collapsed, dont show anything in the UIA tree
            if (OwningRibbon.IsCollapsed)
            {
                return null;
            }

            List<AutomationPeer> children = new List<AutomationPeer>();

            // Step1: Add QAT + Title + ContextualTabGroupHeaderItemsControl
            if (OwningRibbon.QuickAccessToolBar != null)
            {
                AutomationPeer peer = CreatePeerForElement(OwningRibbon.QuickAccessToolBar);
                if (peer != null)
                {
                    children.Add(peer);
                }
            }

            if (OwningRibbon.TitleHost != null)
            {
                AutomationPeer peer = CreatePeerForElement(OwningRibbon.TitleHost);
                if (peer == null)
                {
                    FrameworkElement titleHost = OwningRibbon.TitleHost as FrameworkElement;
                    if (titleHost != null)
                        peer = new RibbonTitleAutomationPeer(titleHost);
                    else
                        peer = new UIElementAutomationPeer(OwningRibbon.TitleHost);
                }
                children.Add(peer);
            }

            if (OwningRibbon.ContextualTabGroupItemsControl != null)
            {
                AutomationPeer peer = CreatePeerForElement(OwningRibbon.ContextualTabGroupItemsControl);
                if (peer != null)
                {
                    children.Add(peer);
                }
            }

            // Step2: Add ApplicationMenu
            if (OwningRibbon.ApplicationMenu != null)
            {
                AutomationPeer peer = CreatePeerForElement(OwningRibbon.ApplicationMenu);
                if (peer != null)
                {
                    children.Add(peer);
                }
            }

            // Step3: Refresh RibbonTabHeaders
            // RibbonTabHeaderItemsControl doesnt appear in the UIA Tree, but its children RibbonTabHeader appear as children of RibbonTab
            // We need to ensure that RibbonTabHeader peers are created and refreshed manually here
            if (OwningRibbon.RibbonTabHeaderItemsControl != null)
            {
                // We are unable to use this commented piece of code because ForceEnsureChildren
                // is an internal method in .Net 4.0. The public alternative is to use
                // AutomationPeer.ResetChildrenCache. However this methods isn't appropriate to be
                // called during a GetChildrenCore call because it causes a recursive call to the
                // GetChildren call for the current AutomationPeer which is prohibited. For
                // illustration here's a callstack.

                // Exception:System.InvalidOperationException: Recursive call to Automation Peer API is not valid. at
                // System.Windows.Automation.Peers.AutomationPeer.GetChildren() at
                // System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent) at
                // System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent) at
                // System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer) at
                // MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer, AutomationPeer referencePeer) at
                // System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit) at
                // System.Windows.Automation.Peers.ItemsControlAutomationPeer.UpdateChildren() at
                // Microsoft.Windows.Automation.Peers.RibbonAutomationPeer.GetChildrenCore() at

                // Also note that this code path is hit only when the UIA client is listening for
                // structure changed events. UI Spy for instance doesn't do this by default and
                // hence you will not automatically see the above crash it in that case. You need
                // to configure the events to include structure changed.

                // -----------------------------------------------------------------------------------------
                // AutomationPeer peer = CreateItemAutomationPeer(OwningRibbon.RibbonTabHeaderItemsControl);
                // if (peer != null)
                // {
                //     peer.ForceEnsureChildren();
                // }
                // -----------------------------------------------------------------------------------------

                // The strategy to create a new instance of the AutomationPeer is a workaround to
                // the above limitation. It is important to create a new instance each time so
                // that we guarantee that the children are in fact updated. A GetChildren call on
                // a previously existing AutomationPeer will short circuit due to the _childrenValid
                // flag. Hence the creation of a new AutomationPeer object each time around. Note
                // that it is only this one AutomationPeer instanced that is created anew each time.
                // The Peers for the descendents are not recreated.

                AutomationPeer peer = new RibbonTabHeaderItemsControlAutomationPeer(OwningRibbon.RibbonTabHeaderItemsControl);
                peer.GetChildren();
            }

            // Step4: Add RibbonTabs
            List<AutomationPeer> ribbonTabs = base.GetChildrenCore();
            if (ribbonTabs != null && ribbonTabs.Count > 0)
            {
                children.AddRange(ribbonTabs);
            }

            // Step5: Add HelpPane that appears next to TabPanel
            UIElement helpPaneHost = OwningRibbon.HelpPaneHost;
            if (helpPaneHost != null)
            {
                AutomationPeer peer = CreatePeerForElement(helpPaneHost);
                if (peer == null)
                {
                    FrameworkElement helpPaneHostFE = helpPaneHost as FrameworkElement;
                    if (helpPaneHostFE != null)
                        peer = new FrameworkElementAutomationPeer(helpPaneHostFE);
                    else
                        peer = new UIElementAutomationPeer(helpPaneHost);
                }
                children.Add(peer);
            }

            return children;
        }
Пример #32
0
        internal static AutomationPeer CreatePeer(UIElement element)
        {
            AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(element);
            if (peer == null)
            {
                FrameworkElement elementFE = element as FrameworkElement;
                if (elementFE != null)
                    peer = new FrameworkElementAutomationPeer(elementFE);
                else
                    peer = new UIElementAutomationPeer(element);
            }

            return peer;
        }
Пример #33
0
        virtual internal AutomationPeer GetWrapperPeer() 
        { 
            AutomationPeer wrapperPeer = null;
            UIElement wrapper = GetWrapper(); 
            if(wrapper != null)
            {
                wrapperPeer = UIElementAutomationPeer.CreatePeerForElement(wrapper);
                if(wrapperPeer == null) //fall back to default peer if there is no specific one 
                {
                    if(wrapper is FrameworkElement) 
                        wrapperPeer = new FrameworkElementAutomationPeer((FrameworkElement)wrapper); 
                    else
                        wrapperPeer = new UIElementAutomationPeer(wrapper); 
                }
            }

            return wrapperPeer; 
        }