コード例 #1
0
        public static void ViewportThumbDragStarted(object sender, DragStartedEventArgs e)
        {
            var scrollThumb = VisualTreeExtraHelper.FindVisualParent <Thumb>(sender as DependencyObject);

            if (scrollThumb != null)
            {
                OriginalWidth = scrollThumb.ActualWidth;
                e.Handled     = true;
            }
        }
コード例 #2
0
        public static void ViewportThumbDragDelta(object sender, DragDeltaEventArgs e)
        {
            var scrollThumb = VisualTreeExtraHelper.FindVisualParent <Thumb>(sender as DependencyObject);

            if (scrollThumb != null)
            {
                var scrollThumbMargin = scrollThumb.Margin;
                scrollThumbMargin.Left += e.HorizontalChange;
                scrollThumb.Margin      = scrollThumbMargin;
                e.Handled = true;
            }
        }
コード例 #3
0
        public static void ViewportThumbDragCompleted(object sender, DragCompletedEventArgs e)
        {
            var scrollThumb = VisualTreeExtraHelper.FindVisualParent <Thumb>(sender as DependencyObject);

            if (scrollThumb != null)
            {
                var newMarginLeft = scrollThumb.Margin.Left;
                var change        = (newMarginLeft - OriginalWidth) * -1;
                var scale         = OriginalWidth / scrollThumb.ActualWidth;

                scrollThumb.Margin = new Thickness(-9, 1, -9, 1); // reset the margin back to what it was

                ZoomViewportCommand.Execute(
                    new TimelineZoomViewportParameters()
                {
                    ViewportAnchor = TimelineZoomAnchor.Right,
                    ViewportScale  = scale
                },
                    scrollThumb
                    );

                e.Handled = true;
            }
        }