Nicholas, this is the routine I wrote, that DOES highlight the specific info
that I want highlighted.
The problem is it is time consuming(4mb file, 1-2 minutes) to load as it
populate the RichTextBox and highlights as it goes.
Is there a way I can have it do the same info before it popultes to the form?
Goal would be Open source log, read the log, and highlight the desired
information, then Show in the RichTextBox of the form.
---------------------------------------------------
private void findSequenceNumbers()
{
toolStripStatusLabel.Visible = toolStripProgressBar.Visible =
true;
toolStripProgressBar.Value = 0;
int lineNum = 0;
bool startingNewLine = true;
FontStyle style = FontStyle.Bold;
string[] lines = rtbTextBox.Lines;
string text = rtbTextBox.Text;
toolStripProgressBar.Maximum = text.Length;
for (int i = 0; i < text.Length; i++)
{
if (startingNewLine)
{
if ((lines[lineNum].Contains("ARES_EINDICATION")) ||
(lines[lineNum].Contains("ARES_INDICATION")))
{
i += 169;
rtbTextBox.Select(i, 2);
rtbTextBox.SelectionFont = new
Font(rtbTextBox.SelectionFont, rtbTextBox.SelectionFont.Style ^ style);
rtbTextBox.SelectionColor = Color.DarkBlue;
}
else if
(lines[lineNum].Contains("]CODELINE_INDICATION_MSG"))
{
i += 160;
rtbTextBox.Select(i, 2);
rtbTextBox.SelectionFont = new
Font(rtbTextBox.SelectionFont, rtbTextBox.SelectionFont.Style ^ style);
rtbTextBox.SelectionColor = Color.DarkBlue;
}
else
{
i += lines[lineNum].Length - 1;
}
startingNewLine = false;
Application.DoEvents();
}
if (text[i] == '\n')
{
startingNewLine = true;
lineNum++;
}
toolStripProgressBar.Value = i;
}
toolStripStatusLabel.Visible = toolStripProgressBar.Visible =
false;
}
-------------------------------------------------------------
Thanks,
"Nicholas Paldino [.NET/C# MVP]" wrote:
> Brian,
>
> What you will want to do in this case is for the sections that you want
> to change the font/color of, you would select them using the
> SelectedText/SelectedRtf properties, or the SelectionLength/SelectionStart
> properties. Once you have the text selected that you want to format, you
> can set the SelectionColor and SelectionFont properties to change the
> font/color of the selected text.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
> "Brian Cook" <(E-Mail Removed)> wrote in message
> news:19F4AF9F-A600-4864-9BDA-(E-Mail Removed)...
> >I have a text file that I modify from a compressed hex format into a single
> > line. This is the output of that part of the program that displays in a
> > RichTextBox;
> >
> > 2007/07/27 11:59:37 [123007]ARES_EINDICATION 010.050.016.004 407.3.01
> > (65e1) RX 68 bytes 65 E1 26 02 A4 5C AA 20 76 79 51 23 50 76 37
> > 62
> > 99 00 48 02 02 C7 88 01 C7 88 AA 50 76 37 62 99 20 76 79 51 23 D7 07 07 1B
> > 0B
> > 3B 22 00 00 10 06 0A 06 06 06 06 06 06 06 0A 0A 06 06 06 0A 0A BB 1C 78 56
> > BC
> >
> > In this sample the hex pair 48 represents the position in the line. It
> > lays
> > out at position 155/156 from the left. I need to change this to BLUE/BOLD
> > for
> > every instance of the ARES_INIDICATION and ARES_EINDICATION as the form
> > loads.
> >
> >
> > Hope that clears it up.
> >
> > Thanks,
> >
> >
> > "Nicholas Paldino [.NET/C# MVP]" wrote:
> >
> >> Brian,
> >>
> >> What are you displaying this in? All you have shown is some content,
> >> but not the mechanism by which you want to display it.
> >>
> >>
> >> --
> >> - Nicholas Paldino [.NET/C# MVP]
> >> - (E-Mail Removed)
> >>
> >> "Brian Cook" <(E-Mail Removed)> wrote in message
> >> news:1B05FEA5-6B72-4D11-BCE2-(E-Mail Removed)...
> >> >I want to change the font color and weight at a specific position in the
> >> >text.
> >> >
> >> > I am not sure where or what I need to do. It will be at position
> >> > 155/156
> >> > from the left on each line.
> >> >
> >> > Here is the code I need to put it into.
> >> >
> >> > using System;
> >> > using System.Drawing;
> >> > using System.IO;
> >> > using System.Collections.Generic;
> >> > using System.Text;
> >> > using System.Windows.Forms;
> >> >
> >> > namespace DatReader
> >> > {
> >> > class Streamer
> >> > {
> >> > public static string LayoutInput(string input)
> >> > {
> >> > StreamReader sr = File.OpenText(input);
> >> > StringBuilder sb = new StringBuilder(input.Length);
> >> > bool firstLine = true;
> >> > string line;
> >> > while ((line = sr.ReadLine()) != null)
> >> > {
> >> > if (line.Length < 29) { throw new
> >> > InvalidOperationException("invalid input"); }
> >> > if (line[29] != ' ')
> >> > {
> >> > int txPos;
> >> > int rxPos = -1;
> >> > if (firstLine)
> >> > firstLine = false;
> >> > else
> >> > sb.Append("\r\n");
> >> > if (((txPos = line.IndexOf("TX")) > -1) || ((rxPos =
> >> > line.IndexOf("RX")) > 0))
> >> > {
> >> > int charactersTillPoint;
> >> > if (txPos > -1)
> >> > charactersTillPoint = txPos;
> >> > else
> >> > charactersTillPoint = rxPos;
> >> > string part0 = line.Substring(0,
> >> > charactersTillPoint);
> >> > string part1 =
> >> > line.Substring(charactersTillPoint);
> >> > sb.Append(part0.PadRight(86));
> >> > sb.Append(part1);
> >> > }
> >> > else
> >> > sb.Append(line);
> >> > }
> >> > else
> >> > {
> >> > sb.Append(line.Substring(30));
> >> > }
> >> > }
> >> > return sb.ToString();
> >> > }
> >> > }
> >> > }
> >> >
> >> > Thanks,
> >> >
> >> >
> >>
> >>
>
>
>