コード例 #1
0
        // Token: 0x06007246 RID: 29254 RVA: 0x0020AB60 File Offset: 0x00208D60
        internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart)
        {
            Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0);
            bool         result      = true;
            ITextPointer textPointer = elementStart.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.BeforeStart);
                if (textPointer.CompareTo(ownerContentStart) <= 0)
                {
                    break;
                }
                AutomationPeer automationPeer  = null;
                object         adjacentElement = textPointer.GetAdjacentElement(LogicalDirection.Forward);
                if (adjacentElement is UIElement)
                {
                    automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement);
                }
                else if (adjacentElement is ContentElement)
                {
                    automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                }
                if (automationPeer != null)
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Is AutometionPeer represented by 'elementStart' is immediate child of AutomationPeer
        /// represented by 'ownerContentStart'.
        /// </summary>
        internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart)
        {
            Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0);
            bool immediateChild = true;
            // Walk element tree up looking for AutomationPeers.
            ITextPointer position = elementStart.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(position.ParentType))
            {
                position.MoveToElementEdge(ElementEdge.BeforeStart);
                if (position.CompareTo(ownerContentStart) <= 0)
                {
                    break;
                }
                AutomationPeer peer    = null;
                object         element = position.GetAdjacentElement(LogicalDirection.Forward);
                if (element is UIElement)
                {
                    peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element);
                }
                else if (element is ContentElement)
                {
                    peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                }
                if (peer != null)
                {
                    immediateChild = false;
                    break;
                }
            }
            return(immediateChild);
        }
コード例 #3
0
        // Token: 0x06007245 RID: 29253 RVA: 0x0020AA54 File Offset: 0x00208C54
        internal static List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart)
        {
            List <AutomationPeer> list = new List <AutomationPeer>();

            start = start.CreatePointer();
            while (start.CompareTo(end) < 0)
            {
                bool flag = false;
                if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
                {
                    object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (adjacentElement is ContentElement)
                    {
                        AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                        if (automationPeer != null)
                        {
                            if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart))
                            {
                                list.Add(automationPeer);
                            }
                            start.MoveToNextContextPosition(LogicalDirection.Forward);
                            start.MoveToElementEdge(ElementEdge.AfterEnd);
                            flag = true;
                        }
                    }
                }
                else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement)
                {
                    object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (adjacentElement is UIElement)
                    {
                        if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart))
                        {
                            AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement);
                            if (automationPeer != null)
                            {
                                list.Add(automationPeer);
                            }
                            else
                            {
                                TextContainerHelper.iterate((Visual)adjacentElement, list);
                            }
                        }
                    }
                    else if (adjacentElement is ContentElement)
                    {
                        AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                        if (automationPeer != null && (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart)))
                        {
                            list.Add(automationPeer);
                        }
                    }
                }
                if (!flag && !start.MoveToNextContextPosition(LogicalDirection.Forward))
                {
                    break;
                }
            }
            return(list);
        }
コード例 #4
0
        // Token: 0x06007247 RID: 29255 RVA: 0x0020ABF0 File Offset: 0x00208DF0
        internal static AutomationPeer GetEnclosingAutomationPeer(ITextPointer start, ITextPointer end, out ITextPointer elementStart, out ITextPointer elementEnd)
        {
            List <object>       list        = new List <object>();
            List <ITextPointer> list2       = new List <ITextPointer>();
            ITextPointer        textPointer = start.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.BeforeStart);
                object obj = textPointer.GetAdjacentElement(LogicalDirection.Forward);
                if (obj != null)
                {
                    list.Insert(0, obj);
                    list2.Insert(0, textPointer.CreatePointer(LogicalDirection.Forward));
                }
            }
            List <object>       list3 = new List <object>();
            List <ITextPointer> list4 = new List <ITextPointer>();

            textPointer = end.CreatePointer();
            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.AfterEnd);
                object obj = textPointer.GetAdjacentElement(LogicalDirection.Backward);
                if (obj != null)
                {
                    list3.Insert(0, obj);
                    list4.Insert(0, textPointer.CreatePointer(LogicalDirection.Backward));
                }
            }
            AutomationPeer automationPeer = null;
            ITextPointer   textPointer2;

            elementEnd   = (textPointer2 = null);
            elementStart = textPointer2;
            for (int i = Math.Min(list.Count, list3.Count); i > 0; i--)
            {
                if (list[i - 1] == list3[i - 1])
                {
                    object obj = list[i - 1];
                    if (obj is UIElement)
                    {
                        automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)obj);
                    }
                    else if (obj is ContentElement)
                    {
                        automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)obj);
                    }
                    if (automationPeer != null)
                    {
                        elementStart = list2[i - 1];
                        elementEnd   = list4[i - 1];
                        break;
                    }
                }
            }
            return(automationPeer);
        }
コード例 #5
0
 /// <summary>Handles the <see cref="E:System.Windows.Documents.Hyperlink.Click" /> routed event.</summary>
 // Token: 0x06003041 RID: 12353 RVA: 0x000D8E2C File Offset: 0x000D702C
 protected virtual void OnClick()
 {
     if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked))
     {
         AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement(this);
         if (automationPeer != null)
         {
             automationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
         }
     }
     Hyperlink.DoNavigation(this);
     base.RaiseEvent(new RoutedEventArgs(Hyperlink.ClickEvent, this));
     CommandHelpers.ExecuteCommandSource(this);
 }
コード例 #6
0
        // Token: 0x06003644 RID: 13892 RVA: 0x000F532C File Offset: 0x000F352C
        private static void OnRowSpanChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TableCell tableCell = (TableCell)d;

            if (tableCell.Table != null)
            {
                tableCell.Table.OnStructureChanged();
            }
            TableCellAutomationPeer tableCellAutomationPeer = ContentElementAutomationPeer.FromElement(tableCell) as TableCellAutomationPeer;

            if (tableCellAutomationPeer != null)
            {
                tableCellAutomationPeer.OnRowSpanChanged((int)e.OldValue, (int)e.NewValue);
            }
        }
コード例 #7
0
 // Token: 0x0600360E RID: 13838 RVA: 0x000F4DC8 File Offset: 0x000F2FC8
 internal void OnStructureChanged()
 {
     if (!this._initializing)
     {
         if (this.TableStructureChanged != null)
         {
             this.TableStructureChanged(this, EventArgs.Empty);
         }
         this.ValidateStructure();
         TableAutomationPeer tableAutomationPeer = ContentElementAutomationPeer.FromElement(this) as TableAutomationPeer;
         if (tableAutomationPeer != null)
         {
             tableAutomationPeer.OnStructureInvalidated();
         }
     }
 }
コード例 #8
0
ファイル: TableCell.cs プロジェクト: dox0/DotNet471RS3
        /// <summary>
        /// <see cref="PropertyMetadata.PropertyChangedCallback"/>
        /// </summary>
        private static void OnColumnSpanChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TableCell cell = (TableCell)d;

            if (cell.Table != null)
            {
                cell.Table.OnStructureChanged();
            }

            // Update AutomaitonPeer.
            TableCellAutomationPeer peer = ContentElementAutomationPeer.FromElement(cell) as TableCellAutomationPeer;

            if (peer != null)
            {
                peer.OnColumnSpanChanged((int)e.OldValue, (int)e.NewValue);
            }
        }
コード例 #9
0
        /// <summary>
        /// OnStructureChanged - Called to rebuild structure.
        /// </summary>
        internal void OnStructureChanged()
        {
            if (!_initializing)
            {
                if (TableStructureChanged != null)
                {
                    TableStructureChanged(this, EventArgs.Empty);
                }

                ValidateStructure();

                // Table structure changes affect number of rows and colums. Need to notify peer about it.
                TableAutomationPeer peer = ContentElementAutomationPeer.FromElement(this) as TableAutomationPeer;
                if (peer != null)
                {
                    peer.OnStructureInvalidated();
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Returns the common ancestor of two positions. This ancestor needs to have
        /// AutomationPeer associated with it.
        /// </summary>
        internal static AutomationPeer GetEnclosingAutomationPeer(ITextPointer start, ITextPointer end, out ITextPointer elementStart, out ITextPointer elementEnd)
        {
            object              element;
            AutomationPeer      peer;
            ITextPointer        position;
            List <object>       ancestorsStart, ancestorsEnd;
            List <ITextPointer> positionsStart, positionsEnd;

            // Get instances of parent objects for start position. The only valid type for
            // scoping elements inside ITextContainer is TextElement.
            ancestorsStart = new List <object>();
            positionsStart = new List <ITextPointer>();
            position       = start.CreatePointer();
            while (typeof(TextElement).IsAssignableFrom(position.ParentType))
            {
                position.MoveToElementEdge(ElementEdge.BeforeStart);
                element = position.GetAdjacentElement(LogicalDirection.Forward);
                if (element != null)
                {
                    ancestorsStart.Insert(0, element);
                    positionsStart.Insert(0, position.CreatePointer(LogicalDirection.Forward));
                }
            }

            // Get instances of parent objects for end position. The only valid type for
            // scoping elements inside ITextContainer is TextElement.
            ancestorsEnd = new List <object>();
            positionsEnd = new List <ITextPointer>();
            position     = end.CreatePointer();
            while (typeof(TextElement).IsAssignableFrom(position.ParentType))
            {
                position.MoveToElementEdge(ElementEdge.AfterEnd);
                element = position.GetAdjacentElement(LogicalDirection.Backward);
                if (element != null)
                {
                    ancestorsEnd.Insert(0, element);
                    positionsEnd.Insert(0, position.CreatePointer(LogicalDirection.Backward));
                }
            }

            // Find common ancestor. If any of ancestors collection is empty, there
            // is no common ancestor.
            peer         = null;
            elementStart = elementEnd = null;
            int depth = Math.Min(ancestorsStart.Count, ancestorsEnd.Count);

            while (depth > 0)
            {
                if (ancestorsStart[depth - 1] == ancestorsEnd[depth - 1])
                {
                    element = ancestorsStart[depth - 1];
                    if (element is UIElement)
                    {
                        peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element);
                    }
                    else if (element is ContentElement)
                    {
                        peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                    }
                    if (peer != null)
                    {
                        elementStart = positionsStart[depth - 1];
                        elementEnd   = positionsEnd[depth - 1];
                        break;
                    }
                }
                depth--;
            }

            return(peer);
        }
コード例 #11
0
        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Retrieves a collection of AutomationPeers that fall within the range.
        /// Children that overlap with the range but are not entirely enclosed by
        /// it will also be included in the collection.
        /// </summary>
        internal static List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart)
        {
            bool                  positionMoved;
            AutomationPeer        peer = null;
            object                element;
            List <AutomationPeer> peers = new List <AutomationPeer>();

            start = start.CreatePointer();

            while (start.CompareTo(end) < 0)
            {
                // Indicate that 'start' position is not moved yet.
                positionMoved = false;

                if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
                {
                    // Get adjacent element and try to retrive AutomationPeer for it.
                    element = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (element is ContentElement)
                    {
                        peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                        // If AutomationPeer has been retrieved, add it to the collection.
                        // And skip entire element.
                        if (peer != null)
                        {
                            if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart))
                            {
                                peers.Add(peer);
                            }
                            start.MoveToNextContextPosition(LogicalDirection.Forward);
                            start.MoveToElementEdge(ElementEdge.AfterEnd);
                            positionMoved = true;
                        }
                    }
                }
                else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement)
                {
                    // Get adjacent element and try to retrive AutomationPeer for it.
                    element = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (element is UIElement)
                    {
                        if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart))
                        {
                            peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element);
                            // If AutomationPeer has been retrieved, add it to the collection.
                            if (peer != null)
                            {
                                peers.Add(peer);
                            }
                            else
                            {
                                iterate((Visual)element, peers);
                            }
                        }
                    }
                    else if (element is ContentElement)
                    {
                        peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                        // If AutomationPeer has been retrieved, add it to the collection.
                        if (peer != null)
                        {
                            if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart))
                            {
                                peers.Add(peer);
                            }
                        }
                    }
                }
                // Move to the next content position, if position has not been moved already.
                if (!positionMoved)
                {
                    if (!start.MoveToNextContextPosition(LogicalDirection.Forward))
                    {
                        break;
                    }
                }
            }

            return(peers);
        }