/// <summary> Populate the UI with the preset with the specified name. </summary> public void LoadPreset(string name) { if (!PresetsList.Any(p => p.Name == name)) { return; } var pr = PresetsList.Where(p => p.Name == name).First(); // Must clear any filters or units might not be selectable if (ShowFilter) { SelectedFilter = Filters.First(); } // Override dropdowns with preset SelectedUnit1 = FindUnit(pr.Character1, Units); SelectedUnit2 = FindUnit(pr.Character2, Units); SelectedUnit3 = FindUnit(pr.Character3, Units); SelectedUnit4 = FindUnit(pr.Character4, Units); SelectedUnit5 = FindUnit(pr.Character5, Units); }
public SquadFinderViewmodel(PlayerList members, IEnumerable <UnitDetails> unitDetails) { Members = members ?? throw new ArgumentNullException("members"); UnitDetails = unitDetails; ShowFilter = UnitDetails != null; SearchCommand = new SimpleCommand(DoSearch); BuildUnitList(); UnitSource1 = new CollectionViewSource { Source = Units }; UnitSource1.Filter += FilterUnits; UnitSource2 = new CollectionViewSource { Source = Units }; UnitSource2.Filter += FilterUnits; UnitSource3 = new CollectionViewSource { Source = Units }; UnitSource3.Filter += FilterUnits; UnitSource4 = new CollectionViewSource { Source = Units }; UnitSource4.Filter += FilterUnits; UnitSource5 = new CollectionViewSource { Source = Units }; UnitSource5.Filter += FilterUnits; BuildFilterList(); SelectedFilter = Filters.FirstOrDefault(); PresetsList = SquadPreset.LoadPresets(); ShowPresets = PresetsList.Any(); }