private void UpdateCamera() { foreach (Keys key in KeyboardReader.GetPressedKeys()) { switch (key) { case Keys.Down: Camera.Move(new Vector2(0, 5)); break; case Keys.Left: Camera.Move(new Vector2(-5, 0)); break; case Keys.Right: Camera.Move(new Vector2(5, 0)); break; case Keys.Up: Camera.Move(new Vector2(0, -5)); break; default: break; } } }
private void FindSnapPosition(Vector2 mousePosition) { _snapPosition = null; if (!KeyboardReader.GetPressedKeys().Any(k => k == Keys.LeftControl || k == Keys.RightControl)) { List <Rectangle> destinations = Items.Where(o => Camera.ObjectIsVisible(o)) .Select(o => Camera.WorldToScreen(o.Bounds)) .ToList(); Rectangle source = DndItem.Bounds; source.X = (int)mousePosition.X; source.Y = (int)mousePosition.Y; _snapPosition = Snap.FindContainerBounds(_snapPosition, source, Bounds); _snapPosition = Snap.FindCornerPosition(_snapPosition, source, destinations.ToArray()); } }