Exemplo n.º 1
0
 public static void PageRight(this ScrollViewer viewer)
 {
     if (viewer == null)
     {
         throw new ArgumentNullException("viewer");
     }
     ScrollViewerExtensions.ScrollByHorizontalOffset(viewer, viewer.ViewportWidth);
 }
Exemplo n.º 2
0
 public static void PageDown(this ScrollViewer viewer)
 {
     if (viewer == null)
     {
         throw new ArgumentNullException("viewer");
     }
     ScrollViewerExtensions.ScrollByVerticalOffset(viewer, viewer.ViewportHeight);
 }
Exemplo n.º 3
0
 public static void LineRight(this ScrollViewer viewer)
 {
     if (viewer == null)
     {
         throw new ArgumentNullException("viewer");
     }
     ScrollViewerExtensions.ScrollByHorizontalOffset(viewer, 16.0);
 }
Exemplo n.º 4
0
 public static void LineUp(this ScrollViewer viewer)
 {
     if (viewer == null)
     {
         throw new ArgumentNullException("viewer");
     }
     ScrollViewerExtensions.ScrollByVerticalOffset(viewer, -16.0);
 }
Exemplo n.º 5
0
 public static void ScrollIntoView(this ScrollViewer viewer, FrameworkElement element)
 {
     if (viewer == null)
     {
         throw new ArgumentNullException("viewer");
     }
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     ScrollViewerExtensions.ScrollIntoView(viewer, element, 0.0, 0.0, (Duration)TimeSpan.Zero);
 }
Exemplo n.º 6
0
        private static void OnMouseWheel(object sender, MouseWheelEventArgs e)
        {
            ScrollViewer viewer = sender as ScrollViewer;

            if (e.Handled)
            {
                return;
            }
            double offset = ScrollViewerExtensions.CoerceVerticalOffset(viewer, viewer.VerticalOffset - (double)e.Delta);

            viewer.ScrollToVerticalOffset(offset);
            e.Handled = true;
        }
Exemplo n.º 7
0
        public static void ScrollIntoView(this ScrollViewer viewer, FrameworkElement element, double horizontalMargin, double verticalMargin, Duration duration)
        {
            if (viewer == null)
            {
                throw new ArgumentNullException("viewer");
            }
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            Rect?boundsRelativeTo = VisualTreeExtensions.GetBoundsRelativeTo(element, (UIElement)viewer);

            if (!boundsRelativeTo.HasValue)
            {
                return;
            }
            double verticalOffset = viewer.VerticalOffset;
            double num1           = 0.0;
            double viewportHeight = viewer.ViewportHeight;
            double num2           = boundsRelativeTo.Value.Bottom + verticalMargin;

            if (viewportHeight < num2)
            {
                num1            = num2 - viewportHeight;
                verticalOffset += num1;
            }
            double num3 = boundsRelativeTo.Value.Top - verticalMargin;

            if (num3 - num1 < 0.0)
            {
                verticalOffset -= num1 - num3;
            }
            double horizontalOffset = viewer.HorizontalOffset;
            double num4             = 0.0;
            double viewportWidth    = viewer.ViewportWidth;
            double num5             = boundsRelativeTo.Value.Right + horizontalMargin;

            if (viewportWidth < num5)
            {
                num4              = num5 - viewportWidth;
                horizontalOffset += num4;
            }
            double num6 = boundsRelativeTo.Value.Left - horizontalMargin;

            if (num6 - num4 < 0.0)
            {
                horizontalOffset -= num4 - num6;
            }
            if (duration == (Duration)TimeSpan.Zero)
            {
                viewer.ScrollToVerticalOffset(verticalOffset);
                viewer.ScrollToHorizontalOffset(horizontalOffset);
            }
            else
            {
                Storyboard storyboard = new Storyboard();
                ScrollViewerExtensions.SetVerticalOffset(viewer, viewer.VerticalOffset);
                ScrollViewerExtensions.SetHorizontalOffset(viewer, viewer.HorizontalOffset);
                DoubleAnimation doubleAnimation1 = new DoubleAnimation();
                doubleAnimation1.To       = new double?(verticalOffset);
                doubleAnimation1.Duration = duration;
                DoubleAnimation doubleAnimation2 = doubleAnimation1;
                DoubleAnimation doubleAnimation3 = new DoubleAnimation();
                doubleAnimation3.To       = new double?(verticalOffset);
                doubleAnimation3.Duration = duration;
                DoubleAnimation doubleAnimation4 = doubleAnimation3;
                Storyboard.SetTarget((DependencyObject)doubleAnimation2, (DependencyObject)viewer);
                Storyboard.SetTarget((DependencyObject)doubleAnimation4, (DependencyObject)viewer);
                Storyboard.SetTargetProperty((DependencyObject)doubleAnimation4, new PropertyPath((object)ScrollViewerExtensions.HorizontalOffsetProperty));
                Storyboard.SetTargetProperty((DependencyObject)doubleAnimation2, new PropertyPath((object)ScrollViewerExtensions.VerticalOffsetProperty));
                storyboard.Children.Add((Timeline)doubleAnimation2);
                storyboard.Children.Add((Timeline)doubleAnimation4);
                storyboard.Begin();
            }
        }
Exemplo n.º 8
0
 private static void ScrollByHorizontalOffset(ScrollViewer viewer, double offset)
 {
     offset += viewer.HorizontalOffset;
     offset  = ScrollViewerExtensions.CoerceHorizontalOffset(viewer, offset);
     viewer.ScrollToHorizontalOffset(offset);
 }
Exemplo n.º 9
0
 private static void ScrollByVerticalOffset(ScrollViewer viewer, double offset)
 {
     offset += viewer.VerticalOffset;
     offset  = ScrollViewerExtensions.CoerceVerticalOffset(viewer, offset);
     viewer.ScrollToVerticalOffset(offset);
 }