/// <summary> /// Creates a code search query from a query string. /// </summary> /// <param name="queryString"></param> /// <returns></returns> internal static CodeSearchQuery FromQueryString(string queryString) { bool inQuotes = false; var sb = new StringBuilder(); var query = new CodeSearchQuery(); foreach (var ch in queryString) { if (ch == '"') { inQuotes = !inQuotes; } else if ((ch == ' ') && !inQuotes) { query.AddTerm(sb.ToString()); sb.Clear(); continue; } sb.Append(ch); } if (sb.Length > 0) { query.AddTerm(sb.ToString()); } return(query); }
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e) { var s = e.Parameter as string; var q2 = CodeSearchQuery.FromQueryString(SearchTextBox.Text); q2.AddTerm("\"" + s + "\""); SearchTextBox.Text = q2.ToQueryString(); }
private void SetQuery(CodeSearchQuery query) { TabItem item = (TabItem)MyTabControl.SelectedItem; if (item == null) { return; } if (item.Content is DeclarationView) { ((DeclarationView)item.Content).Query = query; } }
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) { string searchText = SearchTextBox.Text; if (string.IsNullOrWhiteSpace(searchText)) { query = null; ClearSearch.Visibility = Visibility.Collapsed; } else { query = CodeSearchQuery.FromQueryString(searchText); ClearSearch.Visibility = Visibility.Visible; } SetQuery(query); }