private async void SaveSearch_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(NewSearch.Species)) { return; } try { NewSearch.Order = ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100; } catch (InvalidOperationException) // no entries for .Max - ignore { } IsLoading = true; try { StatusText = $"Loading {NewSearch.Species}..."; await arkReaderWild.EnsureSpeciesIsLoaded(NewSearch.Species); StatusText = $"Ready"; } finally { IsLoading = false; } ListSearches.Add(NewSearch); NewSearch = null; NewSearchActive = false; CreateSearchAvailable = true; MarkSearchesChanged(); }
protected override void SetListSearches() { base.SetListSearches(); IFieldInfo title = GetFieldInfo("Title"); ListSearches.Add(title, new TwoFieldListSearch(title, GetFieldInfo("KeyWord"))); }
protected override void SetListSearches() { base.SetListSearches(); IFieldInfo nameField = GetFieldInfo("Name"); MultipleFieldListSearch search = new MultipleFieldListSearch( nameField, GetFieldInfo("Mobile"), GetFieldInfo("Weixin")); ListSearches.Add(nameField, search); }
private void SetupTamedSearches() { var wildcard = new string[] { null }; var speciesList = wildcard.Concat(arkReaderTamed.AllSpecies).ToList(); var orderList = Enumerable.Range(0, speciesList.Count); var searches = speciesList.Zip(orderList, (species, order) => new SearchCriteria { Species = species, Order = order }); ListSearches.Clear(); foreach (var search in searches) { ListSearches.Add(search); } }
private void SaveSearch_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(NewSearch.Species)) { return; } try { NewSearch.Order = ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100; } catch (InvalidOperationException) // no entries for .Max - ignore { } ListSearches.Add(NewSearch); NewSearch = null; NewSearchActive = false; CreateSearchAvailable = true; MarkSearchesChanged(); }
private void LoadSavedSearches() { if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedSearches)) { Collection <SearchCriteria> searches; try { searches = JsonConvert.DeserializeObject <Collection <SearchCriteria> >(Properties.Settings.Default.SavedSearches); } catch (Exception e) { Console.WriteLine("Exception reading saved searches: " + e.ToString()); return; } ListSearches.Clear(); foreach (var search in searches) { ListSearches.Add(search); } } }
private void SaveSearch_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrWhiteSpace(NewSearch.Species)) { return; } List <String> NewSearchList = new List <String>(AllSpecies.Where(species => species.Contains(NewSearch.Species))); SearchCriteria tempSearch; int order = 100; //If we lose our selection default back to Shopping List try { Properties.Settings.Default.LastGroup = groupsCombo.Text; } catch { Properties.Settings.Default.LastGroup = "Shopping List"; } //Set and save property Properties.Settings.Default.GroupSearch = NewSearch.GroupSearch; Properties.Settings.Default.Save(); if (NewSearchList.Count == 0 && !NewSearch.GroupSearch) // No matches { //Trigger default values so the user knows we did search to match NewSearch = null; tempSearch = null; NewSearchActive = false; CreateSearchAvailable = true; return; } ObservableCollection <SearchCriteria> tempListSearch = new ObservableCollection <SearchCriteria>(ListSearches.Where(sc => sc.Group == (String)groupsCombo.SelectedValue)); if (tempListSearch.Count > 0) { order = (int)ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100; } //Check for group based search if (NewSearch.GroupSearch) { tempSearch = new SearchCriteria(NewSearch); tempSearch.Species = NewSearch.Species; tempSearch.Order = order; //Sort order tempSearch.GroupSearch = NewSearch.GroupSearch; ListSearches.Add(tempSearch); } else { try { foreach (String newDino in NewSearchList) { if (tempListSearch.Count == 0 || tempListSearch.Where(dino => dino.Species == newDino).Count() == 0) { tempSearch = new SearchCriteria(NewSearch); tempSearch.Species = newDino; tempSearch.Order = order; tempSearch.GroupSearch = NewSearch.GroupSearch; ListSearches.Add(tempSearch); order += 100; } } } catch (InvalidOperationException) // no entries for .Max - ignore { } } NewSearch = null; tempSearch = null; NewSearchActive = false; CreateSearchAvailable = true; MarkSearchesChanged(); }