Beispiel #1
0
        private void ElementContent_MouseMove(object sender, MouseEventArgs e)
        {
            Point p;

            if (IsEnabled && _leftButtonDown)
            {
                p = e.GetPosition(ElementRoot);
                ElementContainer.ScrollToHorizontalOffset(ElementContainer.HorizontalOffset - ((p.X - _lastMouseDownPosition.X) * Zoom * DragSpeed));
                ElementContainer.ScrollToVerticalOffset(ElementContainer.VerticalOffset - ((p.Y - _lastMouseDownPosition.Y) * Zoom * DragSpeed));

                _lastMouseDownPosition = p;
            }
        }
        /// <summary>
        /// Scrolls the area control into position
        /// </summary>
        /// <param name="x">X position</param>
        /// <param name="y">Y position</param>
        /// <param name="width">Width of the area that must be in view</param>
        /// <param name="height">Height of the area that must be in view</param>
        private void ScrollIntoPosition(double x, double y, double width, double height)
        {
            if (y + height >= ElementContainer.VerticalOffset + ElementContainer.ViewportHeight)
            {
                ElementContainer.ScrollToVerticalOffset((y + height) - ElementContainer.ViewportHeight);
            }
            else if (y < ElementContainer.VerticalOffset)
            {
                ElementContainer.ScrollToVerticalOffset(y);
            }

            if (x + width >= ElementContainer.HorizontalOffset + ElementContainer.ViewportWidth)
            {
                ElementContainer.ScrollToHorizontalOffset((x + width) - ElementContainer.ViewportWidth);
            }
            else if (x < ElementContainer.HorizontalOffset)
            {
                ElementContainer.ScrollToHorizontalOffset(x);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Scrolls into position
        /// </summary>
        /// <param name="position">Position to be in view</param>
        /// <param name="size">Size that should be in view</param>
        private void ScrollIntoPosition(Point position, Size size)
        {
            if ((position.Y + size.Height) * Zoom >= ElementContainer.VerticalOffset + ElementContainer.ViewportHeight)
            {
                ElementContainer.ScrollToVerticalOffset(((position.Y + size.Height) * Zoom) - ElementContainer.ViewportHeight);
            }
            else if (position.Y * Zoom < ElementContainer.VerticalOffset)
            {
                ElementContainer.ScrollToVerticalOffset(position.Y * Zoom);
            }

            if ((position.X + size.Width * Zoom) >= ElementContainer.HorizontalOffset + ElementContainer.ViewportWidth)
            {
                ElementContainer.ScrollToHorizontalOffset(((position.X + size.Width) * Zoom) - ElementContainer.ViewportWidth);
            }
            else if (position.X * Zoom < ElementContainer.HorizontalOffset)
            {
                ElementContainer.ScrollToHorizontalOffset(position.X * Zoom);
            }
        }