public FindNextResult FindNext(FindNextSearch search) { FindNextResult result = new FindNextResult(); int position = -1; StringComparison s = search.MatchCase ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase; if (search.Direction == "UP") { position = search.Content.Substring(0, search.Position) .LastIndexOf(search.SearchString, s); search.Success = position >= 0 ? true : false; result.SearchStatus = search.Success; } else { int start = search.Success ? search.Position + search.SearchString.Length : search.Position; position = start + search.Content .Substring(start, search.Content.Length - start) .IndexOf(search.SearchString, s); search.Success = position - start >= 0 ? true : false; result.SearchStatus = search.Success; } result.SelectionStart = result.SearchStatus ? position : -1; return(result); }
private void btnFind_Click(object sender, EventArgs e) { UpdateSearchQuery(); FindNextResult result = editOpertion.FindNext(this.Qry); if (result.SearchStatus) { this.Editor.Select(result.SelectionStart, txtFind.Text.Length); } }
private void findnextEditMenu_Click(object sender, EventArgs e) { formFind.UpdateSearchQuery(); if (formFind.Qry.SearchString.Length == 0) { formFind.Show(); } else { FindNextResult result = editOperation.FindNext(formFind.Qry); if (result.SearchStatus) { txtArea.Select(result.SelectionStart, formFind.Qry.SearchString.Length); } } }