Exemple #1
0
 private void OnMouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (ElementContainer != null)
     {
         ElementContainer.ScrollToVerticalOffset(ElementContainer.VerticalOffset + -e.Delta);
         e.Handled = true;
     }
 }
Exemple #2
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);
            }
        }
Exemple #4
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);
            }
        }
        protected override void Tick(object sender, System.EventArgs e)
        {
            double nodeMoveStep;
            double temp;

            base.Tick(sender, e);

            if (ElementChildren != null)
            {
                if (_mouseDown)
                {
                    nodeMoveStep = 10;

                    if (LastMousePosition.Y * _zoom < ElementContainer.VerticalOffset)
                    {
                        temp = ElementContainer.VerticalOffset - nodeMoveStep;
                        LastMousePosition = new Point(LastMousePosition.X, LastMousePosition.Y - nodeMoveStep);
                        if (temp < 0)
                        {
                            temp = 0;
                        }

                        ElementContainer.ScrollToVerticalOffset(temp);
                    }
                    else if (LastMousePosition.Y * _zoom > ElementContainer.VerticalOffset + ElementContainer.ViewportHeight)
                    {
                        temp = ElementContainer.VerticalOffset + nodeMoveStep;
                        LastMousePosition = new Point(LastMousePosition.X, LastMousePosition.Y + nodeMoveStep);
                        if (temp > ElementContainer.ScrollableHeight)
                        {
                            temp = ElementContainer.ScrollableHeight;
                        }

                        ElementContainer.ScrollToVerticalOffset(temp);
                    }
                }
            }
        }