private void RefreshSearch(bool isAppending) { if (isAppending) { foreach (MapItemVM mapItemVm in MapSearchResults.ToList()) { if (mapItemVm.MapName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) < 0) { MapSearchResults.Remove(mapItemVm); } else { mapItemVm.UpdateSearchedText(_searchText); } } } else { MapSearchResults.Clear(); foreach (MapItemVM availableMap in _availableMaps) { MapItemVM map = availableMap; if (map.MapName.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0 && MapSearchResults.All(m => m.MapName != map.MapName)) { MapSearchResults.Add(map); } } } }
public void OnGameTypeChange(BattleType gameType) { MapSearchResults.Clear(); switch (gameType) { case BattleType.Field: IsCurrentMapSiege = false; _availableMaps = _battleMaps; break; case BattleType.Siege: IsCurrentMapSiege = true; _availableMaps = _siegeMaps; break; case BattleType.Village: IsCurrentMapSiege = false; _availableMaps = _villageMaps; break; } foreach (MapItemVM availableMap in _availableMaps) { MapSearchResults.Add(availableMap); } _searchText = new TextObject("{=7i1vmgQ9}Select a Map").ToString(); OnPropertyChanged(nameof(SearchText)); }