protected void SelectClicked( Func <List <MediaCardViewModel> > getSortedItems, MediaCardViewModel card, MouseEventArgs e) { if (SelectedItems.Contains(card)) { SelectedItems.Remove(card); } else { if (e.ShiftKey && _recentlySelected.IsSome) { List <MediaCardViewModel> sorted = getSortedItems(); int start = sorted.IndexOf(_recentlySelected.ValueUnsafe()); int finish = sorted.IndexOf(card); if (start > finish) { (start, finish) = (finish, start); } for (int i = start; i < finish; i++) { SelectedItems.Add(sorted[i]); } } _recentlySelected = card; SelectedItems.Add(card); } }
protected bool IsSelected(MediaCardViewModel card) => SelectedItems.Contains(card);