private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { switch (_mode) { case Mode.None: BuildingComponent.SetMovable(_walls, ref _lastMousePos, e.Location); BuildingComponent.SetMovable(_doors, ref _lastMousePos, e.Location); BuildingComponent.SetMovable(_windows, ref _lastMousePos, e.Location); break; } }
public static void SetMovable(List <BuildingComponent> components, ref Point _lastMousePos, Point location) { foreach (var component in components) { if (location.IsInPolygon(component.Corners)) { if (BuildingComponent.MovableComponent != null) { BuildingComponent.MovableComponent.Movable = false; } component.Movable = true; BuildingComponent.MovableComponent = component; _lastMousePos = location; break; } } }