/// <summary> /// Handles the selection Changed event for the drop down list of saved searches. /// </summary> /// <param name="sender">Instance of the cbSelectSearch drop down box.</param> /// <param name="e"></param> private void cbSelectSearch_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Try setting the selected search type for the current search (SelectedSearchTypeIndex) if (e.AddedItems.Count() == 1) { // TODO: Refactor some of this to a New SearchViewModel constructor or Factory (IN the LibraryDataSource (the View Model) // Retrieve the curent search, ready for update. // must add to a collection, with only 1 item, to avoid an exception. var currentSearch = LibraryDataSource.GetCurrentSearch(); // Get the selected search from the drop down. var selectedSearch = (SearchViewModel)e.AddedItems[0]; // Get the available SearchTypes. var searchTypes = LibraryDataSource.GetSearchTypes(); // Update the CurrentSearch with the selected search. currentSearch.First().SetSearch(selectedSearch, searchTypes); } }
/// <summary> /// Handles the OnNewSearchButtonClicked even from the app bar button /// </summary> /// <param name="sender">Instance of the App Bar button</param> /// <param name="e">Instance of the event args.</param> private void OnNewSearchButtonClicked(object sender, RoutedEventArgs e) { // TODO: Refactor some of this to a New SearchViewModel constructor or Factory (IN the LibraryDataSource (the View Model) // Reset the setting in the CurrentSearchViewer. // 1 Blank Search String // 2 Search Types to "Select a search Type......" // 3 Searchable Values to empty var currentSearch = LibraryDataSource.GetCurrentSearch(); var searchTypes = LibraryDataSource.GetSearchTypes(); var selectedSearch = new SearchViewModel() { UniqueId = string.Empty, Type = searchTypes[0].Type, SearchString = string.Empty, SearchDate = DateTime.Now.ToString(), }; currentSearch.First().SetSearch(selectedSearch, searchTypes); }