private void _searchControl_SelectionChanged(object sender, RoutedEventArgs e) { SearchSuggestionItem history = this._searchControl.SelectedItem as SearchSuggestionItem; if (history != null) { MainViewModel.Instance.Search(history); } }
public void DeleteHistory(SearchSuggestionItem history, bool ischear = false) { if (ischear) { this.SearchHistorys.Clear(); this.SearchSuggestions.Clear(); } else if (history != null) { this.SearchHistorys.Remove(history); this.SearchSuggestions.Remove(history); } this.SaveHostory(); }
public void Search(SearchSuggestionItem history) { if (!this.SearchHistorys.Contains(history)) { this.Search(history.Text); return; } history.Order = this.SearchHistorys.Max(_p => _p.Order) + 1; ResultPage newpage = new ResultPage(1, history.Text, this.NewWebCrawlers()); ViewHelper.ShowPage(newpage); newpage.Start(); this.SearchPageVisibility = Visibility.Hidden; this.MainPageVisibility = Visibility.Visible; Task.Factory.StartNew(this.SaveHostory); }
public void Search(string paramstr) { if (!string.IsNullOrEmpty(paramstr) && !string.IsNullOrWhiteSpace(paramstr)) { SearchSuggestionItem history = this.SearchHistorys.FirstOrDefault(_p => _p.Text == paramstr); if (history == null) { history = new SearchSuggestionItem(paramstr) { Order = this.SearchHistorys.Count == 0 ? 1 : this.SearchHistorys.Max(_p => _p.Order), IsHistory = true }; this.SearchHistorys.Insert(0, history); } this.Search(history); } }
private void _deleteHistoryBt_Click(object sender, RoutedEventArgs e) { SearchSuggestionItem history = (sender as Button)?.Tag as SearchSuggestionItem; MainViewModel.Instance.DeleteHistory(history); }