public void copy_from(print_info other) { fg = other.fg; bg = other.bg; underline = other.underline; bold = other.bold; italic = other.italic; font_name = other.font_name; text = other.text; }
public Color print_bg_color(OLVListItem item, print_info print) { match_item i = item.RowObject as match_item; Color bg = print.bg != util.transparent ? print.bg : util.darker_color(i.bg(parent_)); if (bg == util.transparent) { bg = app.inst.bg; } return(bg); }
public void copy_from(print_info other) { fg = other.fg; bg = other.bg; underline = other.underline; bold = other.bold; italic = other.italic; font_name = other.font_name; text = other.text; is_typed_search = other.is_typed_search; }
public Color print_fg_color(OLVListItem item, print_info print) { match_item i = item.RowObject as match_item; Color fg = i.fg(parent_); Color print_fg = print.fg != util.transparent ? print.fg : fg; if (print_fg == util.transparent) { print_fg = app.inst.fg; } return(print_fg); }
private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, print_info print) { int width = text_width(g, sub); if (print != default_print_) { 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( print.fg) , sub_r, fmt); }
public search_renderer(log_view parent, search_form search) { search_ = search; drawer_ = new log_view_item_draw_ui(parent); drawer_.set_font(parent.list.Font); Color normal_fg_ = app.inst.fg, normal_bg_ = app.inst.bg; default_print_ = new print_info { fg = normal_fg_, bg = normal_bg_, }; Color search_line_fg_ = app.inst.search_found_full_line_fg, search_line_bg_ = app.inst.bg; search_line_print_ = new print_info { fg = search_line_fg_, bg = search_line_bg_ }; Color search_fg_ = app.inst.search_found_fg, search_bg_ = util.darker_color(app.inst.bg); search_print_ = new print_info { text = "not important", fg = search_fg_, bg = search_bg_, bold = true, italic = false }; }
private void parse_format(string format, ref print_info print, ref string link) { switch (format) { case "b": print.bold = true; return; case "/b": print.bold = false; return; case "i": print.italic = true; return; case "/i": print.italic = false; return; case "/a": link = ""; print.underline = false; return; case "/fg": print.fg = util.transparent; return; case "/bg": print.bg = util.transparent; return; case "/font": print.font_name = ""; break; } if (format.StartsWith("a ")) { format = format.Substring(2).Trim(); print.underline = true; link = format; } else if (format.StartsWith("fg ")) { format = format.Substring(3).Trim(); print.fg = util.str_to_color(format); } else if (format.StartsWith("bg ")) { format = format.Substring(3).Trim(); print.bg = util.str_to_color(format); } else if (format.StartsWith("font ")) { format = format.Substring(5).Trim(); print.font_name = format; } else Debug.Assert(false); }
// <a link> ... </a> // <b> ... </b> // <i> ... </i> // <fg #col>.... </fg> // <bg #col>.... </bg> // <font name>... </font> public void set_text(string text) { print_info cur_print = new print_info(); string cur_link = ""; parts_.Clear(); while (text != "") { int delimeter = text.IndexOf("<"); if (delimeter > 0) { var new_ = new part { text = text.Substring(0, delimeter), link = cur_link }; cur_link = ""; new_.print.copy_from(cur_print); if ( new_.link != "") new_.print.fg = Color.DodgerBlue; parts_.Add(new_); int end_delimeter = text.IndexOf(">", delimeter); string format = text.Substring(delimeter + 1, end_delimeter - delimeter - 1); parse_format(format, ref cur_print, ref cur_link); text = text.Substring(end_delimeter + 1); } else { // it was the last part var last = new part { text = text }; last.print.copy_from(cur_print); parts_.Add(last); text = ""; } } // also, it must allow for multiline (if so, print one line, and scroll at a give time) for (int i = 0; i < parts_.Count; ++i) { int enter = parts_[i].text.IndexOf("\r\n"); if (enter >= 0) { string before = parts_[i].text.Substring(0, enter); string after = parts_[i].text.Substring(enter + 2); parts_[i].text = before; parts_[i].ends_line = true; if (after != "") { var new_ = new part() {text = after, link = parts_[i].link}; new_.print.copy_from(parts_[i].print); parts_.Insert(i + 1, new_); } } } cur_line_idx_ = 0; Invalidate(); Update(); update_tip(); }
private List<Tuple<int, int, print_info>> override_print_from_all_places(log_view parent, string text, int col_idx) { List<Tuple<int, int, print_info>> print = new List<Tuple<int, int, print_info>>(); // 1.2.6 - for now, just for msg do match-color if (col_idx == parent.msgCol.fixed_index()) { var from_filter = parent.filter.match_indexes(base.line, info_type.msg); foreach ( var ff in from_filter) print.Add( new Tuple<int, int, print_info>( ff.start, ff.len, new print_info { bg = ff.bg, fg = ff.fg, text = new string('?', ff.len), bold = true } )); } string sel = parent.edit.sel_text.ToLower(); if ((col_idx == parent.sel_col_idx || col_idx == parent.search_found_col_idx) && sel != "") { // look for the text typed by the user var matches = util.find_all_matches(text.ToLower(), sel); if (matches.Count > 0) { print_info print_sel = new print_info { bold = true, text = sel, is_typed_search = true }; foreach ( var match in matches) print.Add( new Tuple<int, int, print_info>(match, sel.Length, print_sel)); } } string find = parent.cur_search != null ? parent.cur_search.text : ""; var col_type = log_view_cell.cell_idx_to_type(col_idx); if (parent.cur_search != null && parent.cur_search.is_column_searchable(col_type) && find != "") { var matches = string_search.match_indexes(text, parent.cur_search); if (matches.Count > 0) { // if we're showing both selected text and the results of a find, differentiate them visually bool italic = sel != ""; print_info print_sel = new print_info { text = find, bg = parent.cur_search.bg, fg = parent.cur_search.fg, bold = true, italic = italic, is_typed_search = italic }; foreach ( var match in matches) print.Add( new Tuple<int, int, print_info>(match.Item1, match.Item2, print_sel)); } } if ( util.is_debug) foreach ( var p in print) Debug.Assert(p.Item1 >= 0 && p.Item2 >= 0); return print; }
public Font font(print_info print) { Font f = print.bold ? (print.italic ? bi_font : b_font) : (print.italic ? i_font : font_); return(f); }
protected bool Equals(print_info other) { return fg.Equals(other.fg) && bg.Equals(other.bg) && bold == other.bold && italic == other.italic && String.Equals(font_name, other.font_name); }
public Color print_fg_color(OLVListItem item, print_info print) { match_item i = item.RowObject as match_item; Color fg = i.fg(parent_); Color print_fg = print.fg != util.transparent ? print.fg : fg; if (print_fg == util.transparent) print_fg = app.inst.fg; return print_fg; }
public Color print_bg_color(OLVListItem item, print_info print) { match_item i = item.RowObject as match_item; Color bg = print.bg != util.transparent ? print.bg : util.darker_color( i.bg(parent_) ); if (bg == util.transparent) bg = app.inst.bg; return bg; }
private List <Tuple <int, int, print_info> > override_print_from_all_places(log_view parent, string text, int col_idx) { List <Tuple <int, int, print_info> > print = new List <Tuple <int, int, print_info> >(); // 1.2.6 - for now, just for msg do match-color if (col_idx == parent.msgCol.fixed_index()) { var from_filter = parent.filter.match_indexes(base.line, info_type.msg); foreach (var ff in from_filter) { print.Add(new Tuple <int, int, print_info>(ff.start, ff.len, new print_info { bg = ff.bg, fg = ff.fg, text = new string('?', ff.len), bold = true })); } } string sel = parent.edit.sel_text.ToLower(); if ((col_idx == parent.sel_col_idx || col_idx == parent.search_found_col_idx) && sel != "") { // look for the text typed by the user var matches = util.find_all_matches(text.ToLower(), sel); if (matches.Count > 0) { print_info print_sel = new print_info { bold = true, text = sel, is_typed_search = true }; foreach (var match in matches) { print.Add(new Tuple <int, int, print_info>(match, sel.Length, print_sel)); } } } string find = parent.cur_search != null ? parent.cur_search.text : ""; if (col_idx == parent.msgCol.fixed_index() && find != "") { var matches = string_search.match_indexes(text, parent.cur_search); if (matches.Count > 0) { // if we're showing both selected text and the results of a find, differentiate them visually bool italic = sel != ""; print_info print_sel = new print_info { text = find, bg = parent.cur_search.bg, fg = parent.cur_search.fg, bold = true, italic = italic, is_typed_search = italic }; foreach (var match in matches) { print.Add(new Tuple <int, int, print_info>(match.Item1, match.Item2, print_sel)); } } } if (util.is_debug) { foreach (var p in print) { Debug.Assert(p.Item1 >= 0 && p.Item2 >= 0); } } return(print); }
protected bool Equals(print_info other) { return(fg.Equals(other.fg) && bg.Equals(other.bg) && bold == other.bold && italic == other.italic && String.Equals(font_name, other.font_name)); }
private void parse_format(string format, ref print_info print, ref string link) { switch (format) { case "b": print.bold = true; return; case "/b": print.bold = false; return; case "i": print.italic = true; return; case "/i": print.italic = false; return; case "/a": link = ""; print.underline = false; return; case "/fg": print.fg = util.transparent; return; case "/bg": print.bg = util.transparent; return; case "/font": print.font_name = ""; break; } if (format.StartsWith("a ")) { format = format.Substring(2).Trim(); print.underline = true; link = format; } else if (format.StartsWith("fg ")) { format = format.Substring(3).Trim(); print.fg = util.str_to_color(format); } else if (format.StartsWith("bg ")) { format = format.Substring(3).Trim(); print.bg = util.str_to_color(format); } else if (format.StartsWith("font ")) { format = format.Substring(5).Trim(); print.font_name = format; } else { Debug.Assert(false); } }
// <a link> ... </a> // <b> ... </b> // <i> ... </i> // <fg #col>.... </fg> // <bg #col>.... </bg> // <font name>... </font> public void set_text(string text) { print_info cur_print = new print_info(); string cur_link = ""; parts_.Clear(); while (text != "") { int delimeter = text.IndexOf("<"); if (delimeter > 0) { var new_ = new part { text = text.Substring(0, delimeter), link = cur_link }; cur_link = ""; new_.print.copy_from(cur_print); if (new_.link != "") { new_.print.fg = Color.DodgerBlue; } parts_.Add(new_); int end_delimeter = text.IndexOf(">", delimeter); string format = text.Substring(delimeter + 1, end_delimeter - delimeter - 1); parse_format(format, ref cur_print, ref cur_link); text = text.Substring(end_delimeter + 1); } else { // it was the last part var last = new part { text = text }; last.print.copy_from(cur_print); parts_.Add(last); text = ""; } } // also, it must allow for multiline (if so, print one line, and scroll at a give time) for (int i = 0; i < parts_.Count; ++i) { int enter = parts_[i].text.IndexOf("\r\n"); if (enter >= 0) { string before = parts_[i].text.Substring(0, enter); string after = parts_[i].text.Substring(enter + 2); parts_[i].text = before; parts_[i].ends_line = true; if (after != "") { var new_ = new part() { text = after, link = parts_[i].link }; new_.print.copy_from(parts_[i].print); parts_.Insert(i + 1, new_); } } } cur_line_idx_ = 0; Invalidate(); Update(); update_tip(); }
private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, print_info print) { int width = text_width(g, sub); if (print != default_print_) { 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(print.fg), sub_r, fmt); }
public Font font(print_info print) { Font f = print.bold ? (print.italic ? bi_font : b_font) : (print.italic ? i_font : font_); return f; }
public Brush print_fg_brush(OLVListItem item, print_info print) { return brush_.brush(print_fg_color(item, print)); }
public Brush print_fg_brush(OLVListItem item, print_info print) { return(brush_.brush(print_fg_color(item, print))); }