'How to implement auto scroll while making selection, typically when mouse is out of bounds of the control and is not moving?
I need to auto scroll when the anchor point of the draggable shape under selection goes out of the bounds of the control's client rectangle.
The OnMouseMove routine of my user control is like
protected override void OnMouseMove(MouseEventArgs e)
{
Point windowPoint = ViewportToWindow(e.Location);
Point worldPoint = WindowToWorld(windowPoint);
if (!Selection.IsEmpty)
{
Point changeInPos = new Point()
{
X = worldPoint.X - lastMousePositionInWorld.X,
Y = worldPoint.Y - lastMousePositionInWorld.Y,
};
Selection.Item.Move(changeInPos);
}
lastMousePositionInWorld = worldPoint;
base.OnMouseMove(e);
}
The problem is when mouse is out of bounds of control and is still, The mouse move will not get raised. Whereas the desired behavior is to keep moving the point in horizontal or vertical direction as per the mouse location relative to the point and auto scroll is same direction. Please help with the algorithm.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
