Skip to content

Commit

Permalink
Added duplicate list checking/Fixed adding new list names
Browse files Browse the repository at this point in the history
  • Loading branch information
jamckee authored and Rottenbeer committed Aug 4, 2019
1 parent 8b618f8 commit 07d812c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions LarkatorGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ private void CreateSearch_Click(object sender, RoutedEventArgs e)

speciesCombo.ItemsSource = arkReader.AllSpecies;
groupsCombo.ItemsSource = ListSearches.Select(sc => sc.Group).Distinct().OrderBy(g => g).ToArray();
int temp = Properties.Settings.Default.lastGroup;
groupsCombo.SelectedIndex = Properties.Settings.Default.lastGroup;
}

Expand Down Expand Up @@ -528,12 +527,16 @@ private void Dev_DummyData_Click(object sender, MouseButtonEventArgs e)

private void SaveSearch_Click(object sender, RoutedEventArgs e)
{
List<String> NewSearchList;
SearchCriteria tempSearch;
if (String.IsNullOrWhiteSpace(NewSearch.Species)) return;

List<String> NewSearchList = new List<String>(AllSpecies.Where(species => species.Contains(NewSearch.Species)));
SearchCriteria tempSearch;
int order = 100;

Properties.Settings.Default.lastGroup = groupsCombo.SelectedIndex;
Properties.Settings.Default.Save();
NewSearchList = new List<String>(AllSpecies.Where(species => species.Contains(NewSearch.Species)));


if (NewSearchList.Count == 0) // No matches
{ //Trigger default values so the user knows we tried to match
NewSearch = null;
Expand All @@ -546,12 +549,19 @@ private void SaveSearch_Click(object sender, RoutedEventArgs e)
try
{
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;
}
foreach (String newDino in NewSearchList)
{
tempSearch = new SearchCriteria(NewSearch);
tempSearch.Species = newDino;
tempSearch.Order = ListSearches.Where(sc => sc.Group == tempSearch.Group).Max(sc => sc.Order) + 100;
ListSearches.Add(tempSearch);
if (tempListSearch.Count == 0 || tempListSearch.Where(dino =>dino.Species == newDino).Count() == 0) {
tempSearch = new SearchCriteria(NewSearch);
tempSearch.Species = newDino;
tempSearch.Order = order;
ListSearches.Add(tempSearch);
order += 100;
}
}
}
catch (InvalidOperationException) // no entries for .Max - ignore
Expand Down

0 comments on commit 07d812c

Please sign in to comment.