Exemple #1
0
        protected void AddFocusedElementRange(IList <FrameworkElement> availableElements, RectangleF?startingRect,
                                              int firstElementIndex, int lastElementIndex, int elementsBefore, int elementsAfter, ICollection <FrameworkElement> outElements)
        {
            int numItems = availableElements.Count;

            if (numItems == 0)
            {
                return;
            }
            CalcHelper.Bound(ref firstElementIndex, 0, numItems - 1);
            CalcHelper.Bound(ref lastElementIndex, 0, numItems - 1);
            if (elementsBefore > 0)
            {
                // Find children before the first index which have focusable elements.
                int formerNumElements = outElements.Count;
                for (int i = firstElementIndex - 1; i >= 0; i--)
                {
                    FrameworkElement fe = availableElements[i];
                    fe.AddPotentialFocusableElements(startingRect, outElements);
                    if (formerNumElements == outElements.Count)
                    {
                        continue;
                    }
                    // Found focusable elements
                    elementsBefore--;
                    if (elementsBefore == 0)
                    {
                        break;
                    }
                    formerNumElements = outElements.Count;
                }
            }
            for (int i = firstElementIndex; i <= lastElementIndex; i++)
            {
                FrameworkElement fe = availableElements[i];
                fe.AddPotentialFocusableElements(startingRect, outElements);
            }
            if (elementsAfter > 0)
            {
                // Find children after the last index which have focusable elements.
                int formerNumElements = outElements.Count;
                for (int i = lastElementIndex + 1; i < availableElements.Count; i++)
                {
                    FrameworkElement fe = availableElements[i];
                    fe.AddPotentialFocusableElements(startingRect, outElements);
                    if (formerNumElements == outElements.Count)
                    {
                        continue;
                    }
                    // Found focusable elements
                    elementsAfter--;
                    if (elementsAfter == 0)
                    {
                        break;
                    }
                    formerNumElements = outElements.Count;
                }
            }
        }
Exemple #2
0
        protected void AddFocusedElementRange(IList <FrameworkElement> availableElements, RectangleF?startingRect,
                                              int firstLineIndex, int lastLineIndex, int linesBefore, int linesAfter, ICollection <FrameworkElement> outElements)
        {
            IList <LineMeasurement> lines = new List <LineMeasurement>(_arrangedLines);
            int numLines = lines.Count;

            if (numLines == 0)
            {
                return;
            }
            CalcHelper.Bound(ref firstLineIndex, 0, numLines - 1);
            CalcHelper.Bound(ref lastLineIndex, 0, numLines - 1);
            if (linesBefore > 0)
            {
                // Find children before the first index which have focusable elements.
                int formerNumElements = outElements.Count;
                for (int lineIndex = firstLineIndex - 1; lineIndex >= 0; lineIndex--)
                {
                    LineMeasurement line = lines[lineIndex];
                    for (int childIndex = line.StartIndex; childIndex <= line.EndIndex; childIndex++)
                    {
                        FrameworkElement fe = availableElements[childIndex];
                        fe.AddPotentialFocusableElements(startingRect, outElements);
                    }
                    if (formerNumElements == outElements.Count)
                    {
                        continue;
                    }
                    // Found focusable elements
                    linesBefore--;
                    if (linesBefore == 0)
                    {
                        break;
                    }
                    formerNumElements = outElements.Count;
                }
            }
            for (int lineIndex = firstLineIndex; lineIndex <= lastLineIndex; lineIndex++)
            {
                LineMeasurement line = lines[lineIndex];
                for (int childIndex = line.StartIndex; childIndex <= line.EndIndex; childIndex++)
                {
                    FrameworkElement fe = availableElements[childIndex];
                    fe.AddPotentialFocusableElements(startingRect, outElements);
                }
            }
            if (linesAfter > 0)
            {
                // Find children after the last index which have focusable elements.
                int formerNumElements = outElements.Count;
                for (int lineIndex = lastLineIndex + 1; lineIndex < lines.Count; lineIndex++)
                {
                    LineMeasurement line = lines[lineIndex];
                    for (int childIndex = line.StartIndex; childIndex <= line.EndIndex; childIndex++)
                    {
                        FrameworkElement fe = availableElements[childIndex];
                        fe.AddPotentialFocusableElements(startingRect, outElements);
                    }
                    if (formerNumElements == outElements.Count)
                    {
                        continue;
                    }
                    // Found focusable elements
                    linesAfter--;
                    if (linesAfter == 0)
                    {
                        break;
                    }
                    formerNumElements = outElements.Count;
                }
            }
        }