void FindPrev() { if (MatchSpots.Count == 0) { return; } if (CurrentSpot == 0) { CurrentSpot = MatchSpots.Count - 1; } else { CurrentSpot--; } if (IsInBinaryMode) { MainRichText.Select(MatchSpots[CurrentSpot], Keyword.Length); MainRichText.ScrollToCaret(); } else { MainText.Select(MatchSpots[CurrentSpot], Keyword.Length); MainText.ScrollToCaret(); } }
void ResetValues() { if (MatchCountLabel.Text != "0") { Keyword = ""; MatchSpots.RemoveRange(0, MatchSpots.Count); CurrentSpot = 0; MatchCountLabel.Text = "0"; MainText.DeselectAll(); MainRichText.DeselectAll(); } }
void Find() { ResetValues(); Keyword = SearchBox.Text; if (IsInBinaryMode) { TextToSearch = MainRichText.Text; } else { TextToSearch = MainText.Text; } if (Keyword.Length == 0) { return; } bool loop = true; int StartIndex = 0; while (loop) { loop = false; int match_spot = TextToSearch.IndexOf(Keyword, StartIndex, ComparisonType); if (match_spot >= 0) { MatchSpots.Add(match_spot); if ((match_spot + Keyword.Length) < TextToSearch.Length) { StartIndex = match_spot + 1; loop = true; } } } MatchCountLabel.Text = MatchSpots.Count.ToString(); if (MatchSpots.Count > 0) { if (IsInBinaryMode) { MainRichText.Select(MatchSpots[0], Keyword.Length); MainRichText.ScrollToCaret(); } else { MainText.Select(MatchSpots[0], Keyword.Length); MainText.ScrollToCaret(); } } }