public void DeselectAll() { SelectedPositions.Clear(); SelectedMapObjects.Clear(); OnMapPositionSelectionChanged?.Invoke(this); Redraw(); }
public void CheckSelection() { //check if any selected position is now out of map SelectedPositions.RemoveWhere(pos => !Map.IsPositionWithin(pos)); CheckMapObjectSelection(); OnMapPositionSelectionChanged?.Invoke(this); Redraw(); }
// selects the hovered position. private void SelectHoveredPosition(bool drag) { Multiselect = Keyboard.IsKeyDown(Key.LeftCtrl); /****************/ if (Multiselect) { if (HoveredPosition != null && Map.IsPositionWithin(HoveredPosition)) { if (!drag) { if (SelectedPositions.RemoveWhere(pos => pos.Equals(HoveredPosition)) == 0) { SelectedPositions.Add(HoveredPosition); } } else { SelectedPositions.Add(HoveredPosition); } } } else { bool positionAlreadySelected = SelectedPositions.Where(pos => pos.Equals(HoveredPosition)).Count() > 0; bool multiplePositionsSelected = SelectedPositions.Count > 1; SelectedPositions.Clear(); if (HoveredPosition != null && Map.IsPositionWithin(HoveredPosition) && (drag || !positionAlreadySelected || multiplePositionsSelected)) { SelectedPositions.Add(HoveredPosition); } } /****************/ CheckMapObjectSelection(); OnMapPositionSelectionChanged?.Invoke(this); Redraw(); }