private bool CanMove(SKPoint controlPosition) { var mapPoint = CalculatePointHelper.ToMapPoint(MapSettings, controlPosition); var radius = CalculatePointHelper.ToMapDistance(_mapSettingsController.Value, SelectRadius); var elements = _selectableObjects.GetElements(mapPoint, radius); return(!elements.Any()); }
public override bool OnMouseUp(MouseButtonEventArgs mouseButtonEventArgs, SKPoint controlPosition) { if (!IsRun || mouseButtonEventArgs.ChangedButton != MouseButton.Left || mouseButtonEventArgs.ButtonState != MouseButtonState.Released) { return(false); } var mapPoint = CalculatePointHelper.ToMapPoint(MapSettings, controlPosition); var radius = CalculatePointHelper.ToMapDistance(MapSettings, SelectRadius); var selectedObject = _selectableController.Value.FirstOrDefault(); var intersectObjects = _selectableObjects.GetElements(mapPoint, radius); if (!intersectObjects.Any() || intersectObjects.Count == 1 && intersectObjects.First() == selectedObject) { _selectableController.ClearSelect(); } else { var index = intersectObjects.IndexOf(selectedObject); if (index == -1 || intersectObjects.Count == index + 1) { _selectableController.Select(intersectObjects.First()); } else { _selectableController.Select(intersectObjects.ElementAt(index + 1)); } } _subOperation?.Stop(); End(controlPosition); return(true); }
public float ToMapDistance(float distance) { return(CalculatePointHelper.ToMapDistance(MapSettings, distance)); }