private void Window_MouseMove(object sender, MouseEventArgs e) { if (mouseEnabled) { if (lastMousePos == null) { lastMousePos = e.GetPosition(grid); } else { Point mouseMovement = e.GetPosition(grid); mouseMovement = new Point(mouseMovement.X - lastMousePos.Value.X, mouseMovement.Y - lastMousePos.Value.Y); lastMousePos = e.GetPosition(grid); if (!mouseDebounce && lastMousePos.Value.X != -mouseMovement.X && lastMousePos.Value.Y != -mouseMovement.Y) { Vec3 strafe = new Vec3(-mouseMovement.Y, mouseMovement.X, 0) * 0.008f; if (Math.Abs(strafe.x) > 0 || Math.Abs(strafe.y) > 0) { rtRenderer.CameraUpdate(new Vec3(), strafe); Point relativePoint = TransformToAncestor(this).Transform(new Point(0, 0)); Point pt = new Point(relativePoint.X + grid.ActualWidth / 2, relativePoint.Y + grid.ActualHeight / 2); Point windowCenterPoint = pt; Point centerPointRelativeToSCreen = grid.PointToScreen(windowCenterPoint); SetCursorPos((int)centerPointRelativeToSCreen.X, (int)centerPointRelativeToSCreen.Y); mouseDebounce = true; } } else { mouseDebounce = false; } } } }