private void LineNumbers()
{
TextPointer start = rtbInput.Document.ContentStart;
TextPointer end = rtbInput.Document.ContentEnd;
TextRange tr = new TextRange(start, end);
string[] txt = tr.Text.Split('\n');
if (tr.Text.Length > 2)
{
if (!mnuWrap.IsChecked)
{
lstLine.Items.Clear();
if (txt.Length > 0 && lstLine.Items.Count >= 0)
{
if (lstLine.Items.Count <= txt.Length - 2)
{
while (lstLine.Items.Count <= txt.Length - 2)
lstLine.Items.Add(lstLine.Items.Count + 1);
}
}
}
else
{
if (txt.Length > 0 && lstLine.Items.Count >= 0)
{
int lines = 0;
lstLine.Items.Clear();
int i;
for (i = 0; i <= txt.Length - 2; i++)
{
lines = 0;
lines += txt[i].Length / 99;
if (txt[i].Length % 99 != 0)
lines += 1;
lstLine.Items.Add(i + 1);
for (int j = 1; j< lines; j++)
{
lstLine.Items.Add(" ");
}
}
}
}
}
tr = new TextRange(rtbInput.Document.ContentStart, rtbInput.Document.ContentEnd);
if (tr.Text.Length == 0 && lstLine.Items.Count > 0)
{
while (lstLine.Items.Count > 0)
lstLine.Items.RemoveAt(lstLine.Items.Count - 1);
}
}