예제 #1
0
        public void MoveMouseToWidget(GuiWidget widget, SystemWindow containingWindow, Point2D offset, Point2D offsetHint, ClickOrigin origin, out Point2D screenPosition)
        {
            RectangleDouble childBounds = widget.TransformToParentSpace(containingWindow, widget.LocalBounds);

            screenPosition = SystemWindowToScreen(new Point2D(childBounds.Left + offset.x, childBounds.Bottom + offset.y), containingWindow);

            int     steps = (int)((TimeToMoveMouse * 1000) / 20);
            Vector2 start = new Vector2(CurrentMousePosition().x, CurrentMousePosition().y);

            if (origin == ClickOrigin.Center)
            {
                offset += offsetHint;
            }

            for (int i = 0; i < steps; i++)
            {
                childBounds = widget.TransformToParentSpace(containingWindow, widget.LocalBounds);

                screenPosition = SystemWindowToScreen(new Point2D(childBounds.Left + offset.x, childBounds.Bottom + offset.y), containingWindow);

                Vector2 end   = new Vector2(screenPosition.x, screenPosition.y);
                Vector2 delta = end - start;

                double ratio = i / (double)steps;
                ratio = Cubic.Out(ratio);
                Vector2 current = start + delta * ratio;
                inputSystem.SetCursorPosition((int)current.X, (int)current.Y);
                Thread.Sleep(20);
            }

            inputSystem.SetCursorPosition(screenPosition.x, screenPosition.y);
        }
예제 #2
0
        public void SetMouseCursorPosition(int x, int y)
        {
            Vector2 start = new Vector2(CurrentMousePosition().x, CurrentMousePosition().y);
            Vector2 end   = new Vector2(x, y);
            Vector2 delta = end - start;
            int     steps = (int)((TimeToMoveMouse * 1000) / 20);

            for (int i = 0; i < steps; i++)
            {
                double ratio = i / (double)steps;
                ratio = GetInterpolatedValue(ratio, InterpolationType.EASE_OUT);
                Vector2 current = start + delta * ratio;
                inputSystem.SetCursorPosition((int)current.x, (int)current.y);
                Thread.Sleep(20);
            }

            inputSystem.SetCursorPosition((int)end.x, (int)end.y);
        }