예제 #1
0
 public void DeselectAll()
 {
     SelectedPositions.Clear();
     SelectedMapObjects.Clear();
     OnMapPositionSelectionChanged?.Invoke(this);
     Redraw();
 }
예제 #2
0
 public void CheckSelection()
 {
     //check if any selected position is now out of map
     SelectedPositions.RemoveWhere(pos => !Map.IsPositionWithin(pos));
     CheckMapObjectSelection();
     OnMapPositionSelectionChanged?.Invoke(this);
     Redraw();
 }
예제 #3
0
        // 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();
        }