public MainSearchWindow(string version) { InitializeComponent(); this.Text = string.Format("{0} (v{1})", this.Text, version); // initialize the text fields SendMessage(txtFilespec.Handle, EM_SETCUEBANNER, 0, "File(s) to search"); SendMessage(txtSearchFor.Handle, EM_SETCUEBANNER, 0, "Search for"); txtFilespec.Text = AppUserSettings.ReadValue(appID, constRecentFilespec); }
private void btnGo_Click(object sender, EventArgs e) { if (!ValidateFields()) { return; } // remember this value for the next instance of this application AppUserSettings.WriteValue(appID, constRecentFilespec, txtFilespec.Text); lvMatches.Items.Clear(); statusLabel.Text = string.Format("Searching projects: {0}", txtFilespec.Text); txtMessages.AppendText(string.Format("Searching \"{0}\" for \"{1}\"\r\n", txtFilespec.Text, txtSearchFor.Text)); List <string> egpFiles = MatchFilesToSearch(); List <SearchMatch> matches = new List <SearchMatch>(); int matchCount = 0; // process each matching file in turn foreach (string filename in egpFiles) { if (File.Exists(filename)) { txtMessages.AppendText(string.Format(" Opening {0}\r\n", filename)); matches = SearchProject(filename, txtSearchFor.Text); foreach (SearchMatch m in matches) { ListViewItem item = ListItemFromMatch(filename, m); lvMatches.Items.Add(item); } } matchCount += matches.Count; } statusLabel.Text = string.Format("{0} project files processed, found {1} matches", egpFiles.Count, matchCount); txtMessages.AppendText(string.Format("{0} project files processed, found {1} matches\r\n", egpFiles.Count, matchCount)); }