// Nova.Studio - a GUI test framework for the Nova.CodeDOM C# object model library. // Copyright (C) 2007-2012 Inevitable Software, all rights reserved. // Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php using System.Collections.Generic; using System.Windows; using System.Windows.Controls; namespace Nova.Studio { /// <summary> /// Interaction logic for FindByTextWindow.xaml /// </summary> public partial class FindByTextWindow : Window { private static readonly List<string> History = new List<string>(); private static readonly HashSet<string> HistorySet = new HashSet<string>(); private static string Scope = "Entire Solution"; private static bool MatchCase = true; private static bool MatchWholeWord = true; private static bool UseRegularExpressions; private static bool MatchDeclarations = true; private static bool MatchSymbolicRefs = true; private static bool MatchLiterals = true; private static bool MatchComments = true; private static bool MatchMessages = true; public FindByTextWindow() { InitializeComponent(); // Populate search history and other settings comboBoxFindText.ItemsSource = History; if (History.Count > 0) comboBoxFindText.SelectedItem = History[0]; comboBoxScope.Text = Scope; checkBoxMatchCase.IsChecked = MatchCase; checkBoxMatchWholeWord.IsChecked = MatchWholeWord; checkBoxUseRegularExpressions.IsChecked = UseRegularExpressions; checkBoxMatchDeclarations.IsChecked = MatchDeclarations; checkBoxMatchReferences.IsChecked = MatchSymbolicRefs; checkBoxMatchLiterals.IsChecked = MatchLiterals; checkBoxMatchComments.IsChecked = MatchComments; checkBoxMatchMessages.IsChecked = MatchMessages; } /// <summary> /// Reset any persistent settings as appropriate when a solution is closed. /// </summary> public static void Reset() { Scope = "Entire Solution"; } private void FocusFindText() { // Force focus on the TextBox *inside* the editable combobox upon loading TextBox textBox = (comboBoxFindText.Template.FindName("PART_EditableTextBox", comboBoxFindText) as TextBox); if (textBox != null) textBox.Focus(); } private void Window_Loaded(object sender, RoutedEventArgs e) { FocusFindText(); } private void buttonFind_Click(object sender, RoutedEventArgs e) { // Abort if the Find Text field is empty string findText = comboBoxFindText.Text; if (string.IsNullOrEmpty(findText)) { FocusFindText(); return; } // Maintain a history of entered search strings, and other settings string value = comboBoxFindText.Text; if (!HistorySet.Contains(value)) { History.Insert(0, value); HistorySet.Add(value); } Scope = comboBoxScope.Text; MatchCase = checkBoxMatchCase.IsChecked ?? false; MatchWholeWord = checkBoxMatchWholeWord.IsChecked ?? false; UseRegularExpressions = checkBoxUseRegularExpressions.IsChecked ?? false; MatchDeclarations = checkBoxMatchDeclarations.IsChecked ?? false; MatchSymbolicRefs = checkBoxMatchReferences.IsChecked ?? false; MatchLiterals = checkBoxMatchLiterals.IsChecked ?? false; MatchComments = checkBoxMatchComments.IsChecked ?? false; MatchMessages = checkBoxMatchMessages.IsChecked ?? false; DialogResult = true; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)