Ejemplo n.º 1
0
        /// <summary>
        /// Handle keys related to scrolling.
        /// </summary>
        /// <param name="key">The key to handle.</param>
        /// <returns>A value indicating whether the key was handled.</returns>
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scrollHost = ItemsControlHelper.ScrollHost;

            if (scrollHost != null)
            {
                switch (key)
                {
                case Key.PageUp:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageLeft();
                    }
                    else
                    {
                        scrollHost.PageUp();
                    }
                    return(true);

                case Key.PageDown:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageRight();
                    }
                    else
                    {
                        scrollHost.PageDown();
                    }
                    return(true);

                case Key.Home:
                    scrollHost.ScrollToTop();
                    return(true);

                case Key.End:
                    scrollHost.ScrollToBottom();
                    return(true);

                case Key.Left:
                    scrollHost.LineLeft();
                    return(true);

                case Key.Right:
                    scrollHost.LineRight();
                    return(true);

                case Key.Up:
                    scrollHost.LineUp();
                    return(true);

                case Key.Down:
                    scrollHost.LineDown();
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handle keys related to scrolling.
        /// </summary>
        /// <param name="key">The key to handle.</param>
        /// <returns>A value indicating whether the key was handled.</returns>
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scrollHost = ItemsControlHelper.ScrollHost;

            if (scrollHost != null)
            {
                // Some keys (e.g. Left/Right) need to be translated in RightToLeft mode
                Key invariantKey = InteractionHelper.GetLogicalKey(FlowDirection, key);

                switch (invariantKey)
                {
                case Key.PageUp:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageLeft();
                    }
                    else
                    {
                        scrollHost.PageUp();
                    }
                    return(true);

                case Key.PageDown:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageRight();
                    }
                    else
                    {
                        scrollHost.PageDown();
                    }
                    return(true);

                case Key.Home:
                    scrollHost.ScrollToTop();
                    return(true);

                case Key.End:
                    scrollHost.ScrollToBottom();
                    return(true);

                case Key.Left:
                    scrollHost.LineLeft();
                    return(true);

                case Key.Right:
                    scrollHost.LineRight();
                    return(true);

                case Key.Up:
                    scrollHost.LineUp();
                    return(true);

                case Key.Down:
                    scrollHost.LineDown();
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scroller = ScrollHost;

            if (scroller != null)
            {
                bool invert = (FlowDirection == FlowDirection.RightToLeft);
                switch (key)
                {
                case Key.Up:
                    scroller.LineUp();
                    return(true);

                case Key.Down:
                    scroller.LineDown();
                    return(true);

                case Key.Left:
                    if (invert)
                    {
                        scroller.LineRight();
                    }
                    else
                    {
                        scroller.LineLeft();
                    }
                    return(true);

                case Key.Right:
                    if (invert)
                    {
                        scroller.LineLeft();
                    }
                    else
                    {
                        scroller.LineRight();
                    }
                    return(true);

                case Key.Home:
                    scroller.ScrollToTop();
                    return(true);

                case Key.End:
                    scroller.ScrollToBottom();
                    return(true);

                case Key.PageUp:
                    //if vertically scrollable - go vertical, otherwise horizontal
                    if (DoubleUtil.GreaterThan(scroller.ExtentHeight, scroller.ViewportHeight))
                    {
                        scroller.PageUp();
                    }
                    else
                    {
                        scroller.PageLeft();
                    }
                    return(true);

                case Key.PageDown:
                    //if vertically scrollable - go vertical, otherwise horizontal
                    if (DoubleUtil.GreaterThan(scroller.ExtentHeight, scroller.ViewportHeight))
                    {
                        scroller.PageDown();
                    }
                    else
                    {
                        scroller.PageRight();
                    }
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        // Token: 0x060058E9 RID: 22761 RVA: 0x00189730 File Offset: 0x00187930
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scrollHost = base.ScrollHost;

            if (scrollHost != null)
            {
                bool flag = base.FlowDirection == FlowDirection.RightToLeft;
                switch (key)
                {
                case Key.Prior:
                    if (DoubleUtil.GreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageUp();
                    }
                    else
                    {
                        scrollHost.PageLeft();
                    }
                    return(true);

                case Key.Next:
                    if (DoubleUtil.GreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageDown();
                    }
                    else
                    {
                        scrollHost.PageRight();
                    }
                    return(true);

                case Key.End:
                    scrollHost.ScrollToBottom();
                    return(true);

                case Key.Home:
                    scrollHost.ScrollToTop();
                    return(true);

                case Key.Left:
                    if (flag)
                    {
                        scrollHost.LineRight();
                    }
                    else
                    {
                        scrollHost.LineLeft();
                    }
                    return(true);

                case Key.Up:
                    scrollHost.LineUp();
                    return(true);

                case Key.Right:
                    if (flag)
                    {
                        scrollHost.LineLeft();
                    }
                    else
                    {
                        scrollHost.LineRight();
                    }
                    return(true);

                case Key.Down:
                    scrollHost.LineDown();
                    return(true);
                }
            }
            return(false);
        }