/// <summary>Gets the control pattern for the <see cref="T:System.Windows.Controls.FlowDocumentScrollViewer" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.FlowDocumentScrollViewerAutomationPeer" />. </summary>
        /// <param name="patternInterface">One of the enumeration values.</param>
        /// <returns>An object that supports the control pattern if <paramref name="patternInterface" /> is a supported value; otherwise, <see langword="null" />. </returns>
        // Token: 0x0600268F RID: 9871 RVA: 0x000B7644 File Offset: 0x000B5844
        public override object GetPattern(PatternInterface patternInterface)
        {
            object result = null;

            if (patternInterface == PatternInterface.Scroll)
            {
                FlowDocumentScrollViewer flowDocumentScrollViewer = (FlowDocumentScrollViewer)base.Owner;
                if (flowDocumentScrollViewer.ScrollViewer != null)
                {
                    AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(flowDocumentScrollViewer.ScrollViewer);
                    if (automationPeer != null && automationPeer is IScrollProvider)
                    {
                        automationPeer.EventsSource = this;
                        result = automationPeer;
                    }
                }
            }
            else if (patternInterface == PatternInterface.Text)
            {
                base.GetChildren();
                if (this._documentPeer != null)
                {
                    this._documentPeer.EventsSource = this;
                    result = this._documentPeer.GetPattern(patternInterface);
                }
            }
            else if (patternInterface == PatternInterface.SynchronizedInput)
            {
                result = base.GetPattern(patternInterface);
            }
            return(result);
        }
        /// <summary>
        /// Gets the control pattern that is associated with the specified System.Windows.Automation.Peers.PatternInterface.
        /// </summary>
        /// <param name="patternInterface">A value from the System.Windows.Automation.Peers.PatternInterface enumeration.</param>
        /// <returns>The object that supports the specified pattern, or null if unsupported.</returns>
        public override object GetPattern(PatternInterface patternInterface)
        {
            switch (patternInterface)
            {
            case PatternInterface.Grid:
            case PatternInterface.Selection:
            case PatternInterface.Table:
                return(this);

            case PatternInterface.Scroll:
            {
                ScrollViewer scrollViewer = this.OwningDataGrid.InternalScrollHost;
                if (scrollViewer != null)
                {
                    AutomationPeer  scrollPeer     = UIElementAutomationPeer.CreatePeerForElement(scrollViewer);
                    IScrollProvider scrollProvider = scrollPeer as IScrollProvider;
                    if (scrollPeer != null && scrollProvider != null)
                    {
                        scrollPeer.EventsSource = this;
                        return(scrollProvider);
                    }
                }

                break;
            }
            }

            return(base.GetPattern(patternInterface));
        }
Ejemplo n.º 3
0
        //
        private static bool iterate(DependencyObject parent, IteratorCallback callback)
        {
            bool done = false;

            if (parent != null)
            {
                AutomationPeer peer  = null;
                int            count = VisualTreeHelper.GetChildrenCount(parent);
                for (int i = 0; i < count && !done; i++)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(parent, i);

                    if (child != null &&
                        child is UIElement &&
                        (peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)child)) != null)
                    {
                        done = callback(peer);
                    }
                    else if (child != null &&
                             child is UIElement3D &&
                             (peer = CreatePeerForElement(((UIElement3D)child))) != null)
                    {
                        done = callback(peer);
                    }
                    else
                    {
                        done = iterate(child, callback);
                    }
                }
            }

            return(done);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <see cref="AutomationPeer.GetPattern"/>
        /// </summary>
        override public object GetPattern(PatternInterface patternInterface)
        {
            object returnValue = null;

            // Check if provided patternInterface is for Scroll, which is all
            // that is currently exposed.
            if (patternInterface == PatternInterface.Scroll)
            {
                // Get a reference to DocumentViewer's ScrollViewer
                DocumentViewer owner = (DocumentViewer)Owner;
                if (owner.ScrollViewer != null)
                {
                    // Get a reference to ScrollViewer's AutomationPeer.
                    AutomationPeer scrollPeer = UIElementAutomationPeer.CreatePeerForElement(owner.ScrollViewer);
                    if (scrollPeer != null && scrollPeer is IScrollProvider)
                    {
                        scrollPeer.EventsSource = this;
                        returnValue             = scrollPeer;
                    }
                }
            }
            else
            {
                returnValue = base.GetPattern(patternInterface);
            }

            return(returnValue);
        }
        // MenuItem cannot rely on the base which gets the visal children because submenu items are part of
        // other visual tree under a Popup.
        // We return the list of items containers if they are currently visible
        // In case MenuItem is not expanded we return null
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = base.GetChildrenCore();

            if (ExpandCollapseState.Expanded == ((IExpandCollapseProvider)this).ExpandCollapseState)
            {
                ItemsControl   owner = (ItemsControl)Owner;
                ItemCollection items = owner.Items;

                if (items.Count > 0)
                {
                    children = new List <AutomationPeer>(items.Count);
                    for (int i = 0; i < items.Count; i++)
                    {
                        UIElement uiElement = owner.ItemContainerGenerator.ContainerFromIndex(i) as UIElement;
                        if (uiElement != null)
                        {
                            AutomationPeer peer = UIElementAutomationPeer.FromElement(uiElement);
                            if (peer == null)
                            {
                                peer = UIElementAutomationPeer.CreatePeerForElement(uiElement);
                            }
                            if (peer != null)
                            {
                                children.Add(peer);
                            }
                        }
                    }
                }
            }

            return(children);
        }
        /// <summary>Returns the object that supports the specified control pattern of the element that is associated with this automation peer.</summary>
        /// <param name="patternInterface">A value in the enumeration.</param>
        /// <returns>If <paramref name="patternInterface" /> is <see cref="F:System.Windows.Automation.Peers.PatternInterface.Grid" />, <see cref="F:System.Windows.Automation.Peers.PatternInterface.Selection" />, or <see cref="F:System.Windows.Automation.Peers.PatternInterface.Table" />, this method returns a <see langword="this" /> pointer; otherwise, this method returns <see langword="null" />.</returns>
        // Token: 0x06002569 RID: 9577 RVA: 0x000B4048 File Offset: 0x000B2248
        public override object GetPattern(PatternInterface patternInterface)
        {
            if (patternInterface <= PatternInterface.Scroll)
            {
                if (patternInterface != PatternInterface.Selection)
                {
                    if (patternInterface != PatternInterface.Scroll)
                    {
                        goto IL_45;
                    }
                    ScrollViewer internalScrollHost = this.OwningDataGrid.InternalScrollHost;
                    if (internalScrollHost == null)
                    {
                        goto IL_45;
                    }
                    AutomationPeer  automationPeer = UIElementAutomationPeer.CreatePeerForElement(internalScrollHost);
                    IScrollProvider scrollProvider = automationPeer as IScrollProvider;
                    if (automationPeer != null && scrollProvider != null)
                    {
                        automationPeer.EventsSource = this;
                        return(scrollProvider);
                    }
                    goto IL_45;
                }
            }
            else if (patternInterface != PatternInterface.Grid && patternInterface != PatternInterface.Table)
            {
                goto IL_45;
            }
            return(this);

IL_45:
            return(base.GetPattern(patternInterface));
        }
Ejemplo n.º 7
0
        ///
        override public object GetPattern(PatternInterface patternInterface)
        {
            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);
                    }
                }
            }
            else if (patternInterface == PatternInterface.ItemContainer)
            {
                if (Owner as ItemsControl != null)
                {
                    return(this);
                }
                return(null);
            }

            return(base.GetPattern(patternInterface));
        }
Ejemplo n.º 8
0
 /// <summary>Gets the control pattern for the <see cref="T:System.Windows.Controls.ItemsControl" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemsControlAutomationPeer" />.</summary>
 /// <param name="patternInterface">One of the enumeration values.</param>
 /// <returns>The <see cref="T:System.Windows.Automation.Peers.ScrollViewerAutomationPeer" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemsControlAutomationPeer" />.</returns>
 // Token: 0x06002732 RID: 10034 RVA: 0x000B93AC File Offset: 0x000B75AC
 public override object GetPattern(PatternInterface patternInterface)
 {
     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);
             }
         }
     }
     else if (patternInterface == PatternInterface.ItemContainer)
     {
         if (base.Owner is ItemsControl)
         {
             return(this);
         }
         return(null);
     }
     return(base.GetPattern(patternInterface));
 }
Ejemplo n.º 9
0
        // Token: 0x06002654 RID: 9812 RVA: 0x000B6AF4 File Offset: 0x000B4CF4
        internal override void AddToParentProxyWeakRefCache()
        {
            CalendarAutomationPeer calendarAutomationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar) as CalendarAutomationPeer;

            if (calendarAutomationPeer != null)
            {
                calendarAutomationPeer.AddProxyToWeakRefStorage(base.ElementProxyWeakReference, this);
            }
        }
        // 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);
        }
        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);
        }
Ejemplo n.º 12
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);
 }
Ejemplo n.º 13
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);
 }
 /// <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));
 }
Ejemplo n.º 15
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>
        /// 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>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);
 }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
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 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);
        }
Ejemplo n.º 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);
        }
        /// <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);
        }
Ejemplo n.º 26
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]);
        }
 /// <summary>Gets 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: 0x0600253F RID: 9535 RVA: 0x000B3BBC File Offset: 0x000B1DBC
 IRawElementProviderSimple[] ITableProvider.GetColumnHeaders()
 {
     if (this.OwningCalendar.DisplayMode == CalendarMode.Month)
     {
         List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>();
         foreach (object obj in this.OwningGrid.Children)
         {
             UIElement uielement = (UIElement)obj;
             if ((int)uielement.GetValue(Grid.RowProperty) == 0)
             {
                 AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(uielement);
                 if (automationPeer != null)
                 {
                     list.Add(base.ProviderFromPeer(automationPeer));
                 }
             }
         }
         if (list.Count > 0)
         {
             return(list.ToArray());
         }
     }
     return(null);
 }
Ejemplo n.º 28
0
        ///
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = base.GetChildrenCore();

            //  include text box part into children collection
            ComboBox owner   = (ComboBox)Owner;
            TextBox  textBox = owner.EditableTextBoxSite;

            if (textBox != null)
            {
                AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(textBox);
                if (peer != null)
                {
                    if (children == null)
                    {
                        children = new List <AutomationPeer>();
                    }

                    children.Insert(0, peer);
                }
            }

            return(children);
        }
Ejemplo n.º 29
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 List <AutomationPeer> GetChildrenCore()
        {
            GroupItem    owner        = (GroupItem)Owner;
            ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner);

            if (itemsControl != null)
            {
                ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer;
                if (itemsControlAP != null)
                {
                    List <AutomationPeer> children = new List <AutomationPeer>();
                    bool useNetFx472CompatibleAccessibilityFeatures = AccessibilitySwitches.UseNetFx472CompatibleAccessibilityFeatures;

                    if (!useNetFx472CompatibleAccessibilityFeatures && owner.Expander != null)
                    {
                        _expanderPeer = UIElementAutomationPeer.CreatePeerForElement(owner.Expander);

                        if (_expanderPeer != null)
                        {
                            _expanderPeer.EventsSource = this;

                            // Call GetChildren so the Expander's toggle button updates its EventsSource as well
                            _expanderPeer.GetChildren();
                        }
                    }
                    Panel itemsHost = owner.ItemsHost;

                    if (itemsHost == null)
                    {
                        if (_expanderPeer == null)
                        {
                            return(null);
                        }
                        else
                        {
                            children.Add(_expanderPeer);
                            return(children);
                        }
                    }

                    IList childItems = itemsHost.Children;
                    ItemPeersStorage <ItemAutomationPeer> addedChildren = new ItemPeersStorage <ItemAutomationPeer>();


                    foreach (UIElement child in childItems)
                    {
                        if (!((MS.Internal.Controls.IGeneratorHost)itemsControl).IsItemItsOwnContainer(child))
                        {
                            UIElementAutomationPeer peer = child.CreateAutomationPeer() as UIElementAutomationPeer;
                            if (peer != null)
                            {
                                children.Add(peer);

                                if (useNetFx472CompatibleAccessibilityFeatures)
                                {
                                    //
                                    // The AncestorsInvalid check is meant so that we do this call to invalidate the
                                    // GroupItemPeers containing the realized item peers only when we arrive here from an
                                    // UpdateSubtree call because that call does not otherwise descend into parts of the tree
                                    // that have their children invalid as an optimization.
                                    //
                                    if (itemsControlAP.RecentlyRealizedPeers.Count > 0 && this.AncestorsInvalid)
                                    {
                                        GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer;
                                        if (groupItemPeer != null)
                                        {
                                            groupItemPeer.InvalidateGroupItemPeersContainingRecentlyRealizedPeers(itemsControlAP.RecentlyRealizedPeers);
                                        }
                                    }
                                }
                                else
                                {
                                    //
                                    // The AncestorsInvalid check is meant so that we do this call to invalidate the
                                    // GroupItemPeers only when we arrive here from an
                                    // UpdateSubtree call because that call does not otherwise descend into parts of the tree
                                    // that have their children invalid as an optimization.
                                    //
                                    if (this.AncestorsInvalid)
                                    {
                                        GroupItemAutomationPeer groupItemPeer = peer as GroupItemAutomationPeer;
                                        if (groupItemPeer != null)
                                        {
                                            // invalidate all GroupItemAP children, so
                                            // that the top-level ItemsControlAP's
                                            // ItemPeers collection is repopulated.
                                            groupItemPeer.AncestorsInvalid = true;
                                            groupItemPeer.ChildrenValid    = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            object item = itemsControl.ItemContainerGenerator.ItemFromContainer(child);

                            // ItemFromContainer can return {UnsetValue} if we're in a re-entrant
                            // call while the generator is in the midst of unhooking the container.
                            // Ignore such children.
                            if (item == DependencyProperty.UnsetValue)
                            {
                                continue;
                            }

                            // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client
                            ItemAutomationPeer peer = useNetFx472CompatibleAccessibilityFeatures
                                                        ? itemsControlAP.ItemPeers[item]
                                                        : itemsControlAP.ReusablePeerFor(item);

                            peer = itemsControlAP.ReusePeerForItem(peer, item);

                            if (peer != null)
                            {
                                if (useNetFx472CompatibleAccessibilityFeatures)
                                {
                                    //
                                    // We have now connected the realized peer to its actual parent. Hence the cache can be cleared
                                    //
                                    int realizedPeerIndex = itemsControlAP.RecentlyRealizedPeers.IndexOf(peer);
                                    if (realizedPeerIndex >= 0)
                                    {
                                        itemsControlAP.RecentlyRealizedPeers.RemoveAt(realizedPeerIndex);
                                    }
                                }
                            }
                            else
                            {
                                peer = itemsControlAP.CreateItemAutomationPeerInternal(item);
                            }

                            //perform hookup so the events sourced from wrapper peer are fired as if from the data item
                            if (peer != null)
                            {
                                AutomationPeer wrapperPeer = peer.GetWrapperPeer();
                                if (wrapperPeer != null)
                                {
                                    wrapperPeer.EventsSource = peer;
                                    if (peer.ChildrenValid && peer.Children == null && this.AncestorsInvalid)
                                    {
                                        peer.AncestorsInvalid        = true;
                                        wrapperPeer.AncestorsInvalid = true;
                                    }
                                }
                            }

                            //protection from indistinguishable items - for example, 2 strings with same value
                            //this scenario does not work in ItemsControl however is not checked for.
                            //  Our parent's ItemPeerStorage collection may not have been cleared,
                            // this would cause us to report 0 children, if the peer is already in the collection
                            // check its parent, if it has been set to us, we should add it to the return collection,
                            // but only if we haven't added a peer for this item during this GetChildrenCore call.
                            bool itemMissingPeerInGlobalStorage = itemsControlAP.ItemPeers[item] == null;

                            if (peer != null && (itemMissingPeerInGlobalStorage ||
                                                 (peer.GetParent() == this && addedChildren[item] == null)))
                            {
                                children.Add(peer);
                                addedChildren[item] = peer;

                                if (itemMissingPeerInGlobalStorage)
                                {
                                    itemsControlAP.ItemPeers[item] = peer;
                                }
                            }
                        }
                    }

                    return(children);
                }
            }

            return(null);
        }