private void set_text(log_view lv) { if (drawer_ == null) { drawer_ = new log_view_item_draw_ui(lv) { ignore_selection = true }; txt.Font = drawer_.default_font; } drawer_.set_parent(lv); int msg_col = lv.msgCol.fixed_index(); string msg_txt = lv.sel_line_text; txt.Clear(); txt.AppendText(msg_txt); var prints = lv.sel.override_print(lv, msg_txt, msg_col); var full_row = lv.list.GetItem(lv.sel_row_idx); BackColor = txt.BackColor = drawer_.bg_color(full_row, msg_col); int last_idx = 0; for (int print_idx = 0; print_idx < prints.Count; ++print_idx) { int cur_idx = prints[print_idx].Item1, cur_len = prints[print_idx].Item2; string before = msg_txt.Substring(last_idx, cur_idx - last_idx); if (before != "") { txt.Select(last_idx, cur_idx - last_idx); txt.SelectionColor = drawer_.print_fg_color(full_row, default_print_); txt.SelectionBackColor = drawer_.bg_color(full_row, msg_col); } txt.Select(cur_idx, cur_len); txt.SelectionColor = drawer_.print_fg_color(full_row, prints[print_idx].Item3); txt.SelectionBackColor = drawer_.print_bg_color(full_row, prints[print_idx].Item3); last_idx = cur_idx + cur_len; } last_idx = prints.Count > 0 ? prints.Last().Item1 + prints.Last().Item2 : 0; if (last_idx < msg_txt.Length) { txt.Select(last_idx, msg_txt.Length - last_idx); txt.SelectionColor = drawer_.print_fg_color(full_row, default_print_); txt.SelectionBackColor = drawer_.bg_color(full_row, msg_col); } txt.SelectionStart = 0; txt.SelectionLength = 0; }
private void set_text(log_view lv) { if (drawer_ == null) { drawer_ = new log_view_item_draw_ui(lv) { ignore_selection = true }; txt.Font = drawer_.default_font; } drawer_.set_parent(lv); int msg_col = lv.msgCol.fixed_index(); string msg_txt = lv.sel_line_text; txt.Clear(); txt.AppendText(msg_txt); var prints = lv.sel.override_print(lv, msg_txt, msg_col, column_formatter_base.format_cell.location_type.msg_description).format_text; var full_row = lv.list.GetItem(lv.sel_row_idx); BackColor = txt.BackColor = drawer_.bg_color(full_row, msg_col, prints); var parts = prints.parts(default_print_); foreach (var part in parts) { txt.Select(part.start, part.len); txt.SelectionColor = drawer_.print_fg_color(full_row, part); txt.SelectionBackColor = drawer_.print_bg_color(full_row, part); } txt.SelectionStart = 0; txt.SelectionLength = 0; }
private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, text_part print) { int width = drawer_.text_width(g, sub, drawer_.font(print)); Color print_bg = drawer_.print_bg_color(ListItem, print); if (print_bg.ToArgb() != bg_color_.ToArgb()) { Rectangle here = new Rectangle(r.Location, r.Size); here.X += left; here.Width = width + 1; g.FillRectangle(brush_.brush(print_bg), here); } Rectangle sub_r = new Rectangle(r.Location, r.Size); sub_r.X += left; sub_r.Width -= left; g.DrawString(sub, drawer_.font(print), brush_.brush(drawer_.print_fg_color(ListItem, print)), sub_r, fmt); }