/// <summary> /// Clear all of the searches and go to the Top List without any chosen results /// </summary> public void ClearSearches() { AllSearches.Clear(); var newSearch = new SearchVM(); AllSearches.Add(newSearch); CurrentSearch = newSearch; CurrentSearch.GoToTopList(); }
/// <summary> /// Switch to another search. Search must be present in AllSearches already /// </summary> /// <param name="switchTo">Search to switch to</param> public void SwitchToSearch(SearchVM switchTo) { if (AllSearches.Contains(switchTo)) { var currSearch = CurrentSearch; CurrentSearch = switchTo; if (String.IsNullOrWhiteSpace(currSearch.CurrentText)) { AllSearches.Remove(currSearch); } } }
/// <summary> /// Prepare a new search, using either the current search if not currently already selected, or creating a new search VM /// </summary> /// <param name="perform">Action to perform on the appropriate search VM</param> private void PrepareNewSearch(Action <SearchVM> perform) { if (String.IsNullOrWhiteSpace(CurrentSearch.CurrentText)) { if (perform != null) { perform(CurrentSearch); } } else { var newSearch = new SearchVM(); AllSearches.Add(newSearch); CurrentSearch = newSearch; if (perform != null) { perform(newSearch); } } }