/// <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);
        }
Beispiel #2
0
 /// <summary>
 /// If the control contains a ScrollViewer, this will reset the viewer
 /// to be scrolled to the top.
 /// </summary>
 private void ResetScrollViewer()
 {
     if (SelectorControl != null)
     {
         ScrollViewer sv = SelectorControl.GetLogicalChildrenBreadthFirst().OfType <ScrollViewer>().FirstOrDefault();
         if (sv != null)
         {
             sv.ScrollToTop();
         }
     }
 }
        public void Load(IPdfSource source, string password = null)
        {
            virtualPanel = VisualTreeHelperEx.FindChild<CustomVirtualizingPanel>(this);
            scrollViewer = VisualTreeHelperEx.FindChild<ScrollViewer>(this);
            virtualPanel.PageRowBounds = parent.PageRowBounds.Select(f => f.SizeIncludingOffset).ToArray();
            imageProvider = new PdfImageProvider(source, parent.TotalPages,
                new PageDisplaySettings(parent.GetPagesPerRow(), parent.ViewType, parent.HorizontalMargin,
                    parent.Rotation),
                password: password);

            if (parent.ZoomType == ZoomType.Fixed)
                CreateNewItemsSource();
            else if (parent.ZoomType == ZoomType.FitToHeight)
                ZoomToHeight();
            else if (parent.ZoomType == ZoomType.FitToWidth)
                ZoomToWidth();

            if (scrollViewer != null)
            {
                scrollViewer.Visibility = Visibility.Visible;
                scrollViewer.ScrollToTop();
            }
        }
Beispiel #4
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);
        }
        /// <summary>
        /// If the control contains a ScrollViewer, this will reset the viewer
        /// to be scrolled to the top.
        /// </summary>
        private void ResetScrollViewer()
        {
            ScrollViewer sv = SelectorControl?.GetLogicalChildrenBreadthFirst().OfType <ScrollViewer>().FirstOrDefault();

            sv?.ScrollToTop();
        }
 /// <summary>
 /// This is the command scroll adjustment code which synchronizes two ScrollViewer instances.
 /// </summary>
 /// <param name="sv">ScrollViewer to adjust</param>
 /// <param name="e">Change in the source</param>
 /// <param name="hadjust">Horizontal adjustment</param>
 /// <param name="vadjust">Vertical adjustment</param>
 private static void AdjustScrollPosition(ScrollViewer sv, ScrollChangedEventArgs e, double hadjust, double vadjust)
 {
     if (e.HorizontalChange != 0 || e.ExtentWidthChange != 0)
     {
         if (e.HorizontalOffset == 0)
             sv.ScrollToLeftEnd();
         else if (e.HorizontalOffset >= e.ExtentWidth-5)
             sv.ScrollToRightEnd();
         else if (e.ExtentWidth + hadjust == sv.ExtentWidth)
             sv.ScrollToHorizontalOffset(e.HorizontalOffset + hadjust);
         else
             sv.ScrollToHorizontalOffset((sv.ExtentWidth * (e.HorizontalOffset / e.ExtentWidth)) + hadjust);
     }
     if (e.VerticalChange != 0 || e.ExtentHeightChange != 0)
     {
         if (e.VerticalOffset == 0)
             sv.ScrollToTop();
         else if (e.VerticalOffset >= e.ExtentHeight-5)
             sv.ScrollToBottom();
         else if (e.ExtentHeight + vadjust == sv.ExtentHeight)
             sv.ScrollToVerticalOffset(e.VerticalOffset + vadjust);
         else
             sv.ScrollToVerticalOffset((sv.ExtentHeight * (e.VerticalOffset / e.ExtentHeight)) + vadjust);
     }
 }
    internal static void ResetScrollPositions( ScrollViewer scrollViewer )
    {
      if( scrollViewer == null )
      {
        throw new ArgumentNullException( "scrollViewer" );
      }

      DataGridScrollViewer dataGridScrollViewer = scrollViewer as DataGridScrollViewer;
      if( dataGridScrollViewer != null )
      {
        foreach( SynchronizedScrollViewer ssv in dataGridScrollViewer.SynchronizedScrollViewers )
        {
          ssv.ScrollToTop();
          ssv.ScrollToLeftEnd();
        }
      }

      scrollViewer.ScrollToTop();
      scrollViewer.ScrollToLeftEnd();

    }
        /// <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);
        }
Beispiel #9
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);
        }