private void PopulateLineList(int type, object data) { listBox2.SuspendLayout(); listBox2.Items.Clear(); // TODO delay update? richTextBox1.ResetText(); if (type != ISS) { var foo = data as List <atup2>; atup2 first = foo[0]; if (type == ERR) { textBox1.Text = string.Format("Error: {0}{2}, Count:{1}", first.Item1.Error, foo.Count, string.IsNullOrEmpty(first.Item1.Tag) ? "" : ", Tag:" + first.Item1.Tag); } else { textBox1.Text = string.Format("Unknown: {0}, Count:{1}", first.Item1.Tag, foo.Count); } foreach (var tuple in foo) { UnkRec unk = tuple.Item1; string val = string.Format("Lines:{0}-{1}", unk.Beg, unk.End); ListBoxItem2 lbi2 = new ListBoxItem2(); lbi2.txt = val; lbi2.err = unk; lbi2.rec = tuple.Item2; listBox2.Items.Add(lbi2); } } else { var foo = data as List <Issue>; Issue first = foo[0]; textBox1.Text = string.Format("Issue: {0}, Count:{1}", first.IssueId, foo.Count); foreach (var iss in foo) { string val = iss.Message(); ListBoxItem2 lbi2 = new ListBoxItem2(); lbi2.txt = val; lbi2.rec = null; // TODO need record link lbi2.iss = iss; listBox2.Items.Add(lbi2); } } if (listBox2.Items.Count > 0) { listBox2.SelectedIndex = 0; } listBox2.ResumeLayout(); }
private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { // 1. have a record // 2. get lines from file for the record // 3. determine range of lines for the error // 4. for each line from file: // 4a. if line is within error range // 4ai. set format to Red // 4aii. else // 4aiii. set format to black // 4b. append text // 4c. append environment.newline ListBoxItem2 lbi = listBox2.SelectedItem as ListBoxItem2; int beg = lbi.rec.BegLine; int end = lbi.rec.EndLine; if (_lastrec != lbi.rec) { _lastrec = lbi.rec; _lines = ReadLineSet(beg, end); } int errbeg = lbi.err.Beg; int errend = lbi.err.End; richTextBox1.Clear(); int errLoc = 0; // track location of error lines to insure visibility for (int i = beg; i <= end; i++) { string lin = _lines[i - beg]; if (i >= errbeg && i <= errend) { richTextBox1.SelectionColor = Color.Red; errLoc = richTextBox1.SelectionStart; } else { richTextBox1.SelectionColor = Color.Black; } richTextBox1.AppendText(lin); richTextBox1.AppendText(Environment.NewLine); } targetVCenter(errbeg - beg, errend - beg); //richTextBox1.SelectionStart = errLoc; // insure error lines are visible //richTextBox1.ScrollToCaret(); }