mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-02 13:57:14 -05:00
Add text highlighting method
This commit is contained in:
@@ -620,5 +620,24 @@ internal static byte[] StringToByteArray(string hex)
|
||||
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
|
||||
.ToArray();
|
||||
}
|
||||
internal static int highlightText(RichTextBox RTB, string word, Color hlColor)
|
||||
{
|
||||
int ctr = 0;
|
||||
int s_start = RTB.SelectionStart, startIndex = 0, index;
|
||||
|
||||
while ((index = RTB.Text.IndexOf(word, startIndex, StringComparison.Ordinal)) != -1)
|
||||
{
|
||||
RTB.Select(index, word.Length);
|
||||
RTB.SelectionColor = hlColor;
|
||||
|
||||
startIndex = index + word.Length;
|
||||
ctr++;
|
||||
}
|
||||
|
||||
RTB.SelectionStart = s_start;
|
||||
RTB.SelectionLength = 0;
|
||||
RTB.SelectionColor = Color.Black;
|
||||
return ctr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user