public virtual Color fg(log_view parent) { Color result; #if old_code if (parent.has_bookmark(base.line_idx)) { result = parent.bookmark_fg; } else #endif if (override_fg != util.transparent) { result = override_fg; } else if (parent.filter.matches.binary_search(line_idx).Item2 < 0) { result = font_info.full_log_gray.fg; } else { result = font.fg; } if (result == util.transparent) { result = app.inst.fg; } return(result); }
static internal string save_column_positions(log_view lv) { if (lv.visible_columns_refreshed_ < MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { // in this case, we're not sure what columns are visible for sure or not, so don't do anything return(""); } string positions = ""; // column: display index, width, visible for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; int display_index = col.DisplayIndex >= 0 ? col.DisplayIndex : col.LastDisplayIndex; if (col.Width > 0) { // "2" - I don't have this column in my current log - so I don't show it, but, when another log might have this column, do show it // "1" - column is to be shown // "0" - user manually chose to hide this column string visible = lv.visible_columns.Contains(log_view_cell.cell_idx_to_type(col_idx)) ? (col.IsVisible ? "1" : "0") : "2"; positions += "" + col_idx + "," + display_index + "," + col.Width + "," + visible + ";"; } } if (positions == default_column_positions_string(lv)) { // user hasn't changed anything return(""); } return(positions); }
static internal void apply_column_positions(log_view lv) { if (lv.column_positions != "") { load_column_positions(lv, lv.column_positions); } }
static public void refresh_visible_columns(List <log_view> all_views, log_view full_log) { Debug.Assert(full_log.is_full_log); if (refresh_visible_columns_any_change(full_log)) { // notify all other views foreach (log_view lv in all_views) { lv.visible_columns = full_log.visible_columns; refresh_visible_columns(lv, full_log); } if (full_log.visible_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { foreach (log_view lv in all_views) { // in tihs case, we consider knowing the visible-columns for ALL views lv.visible_columns_refreshed_ = MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS; } } // now, apply the saved-custom-positions, if any foreach (log_view lv in all_views) { apply_column_positions(lv); } apply_column_positions(full_log); full_log.update_column_names(); foreach (log_view lv in all_views) { lv.update_column_names(); } } }
static internal string column_positions_as_string(log_view lv) { string positions = ""; // column: display index, width, visible for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; int display_index = col.DisplayIndex >= 0 ? col.DisplayIndex : col.LastDisplayIndex; if (col.Width > 0) { // "2" - I don't have this column in my current log - so I don't show it, but, when another log might have this column, do show it // "1" - column is to be shown // "0" - user manually chose to hide this column string visible = lv.available_columns.Contains(log_view_cell.cell_idx_to_type(col_idx)) ? (col.is_visible() ? "1" : "0") : "2"; positions += "" + col_idx + "," + display_index + "," + col.col_width() + "," + visible + ";"; } } if (positions == default_column_positions_string(lv)) { // user hasn't changed anything return(""); } return(positions); }
// allow overriding the parent public void set_parent(log_view parent) { Debug.Assert(parent != null); if (parent == parent_) return; parent_ = parent; }
static private bool has_value_at_column(log_view lv, info_type type, int max_rows_to_check) { // msg is always shown if (type == info_type.msg) return true; if (type == info_type.line || type == info_type.view) return true; if (max_rows_to_check == 0) // before reading anything from the log return false; var aliases = lv.filter.log.aliases; // 1.5.4+ if the user has already specified clearly that we have this column, we consider it true if (aliases.has_column(type)) return true; for (int idx = 0; idx < max_rows_to_check; ++idx) { var i = lv.item_at(idx) ; if (i.line_idx < 0) continue; if (log_view_cell.cell_value_by_type(i, type) != "") return true; } return false; }
private void load_surrounding_rows(log_view lv) { int sel = lv.sel_row_idx; if (sel < 0) { sel = 0; } // get as many rows as possible, in both directions int max_count = Math.Min(app.inst.look_around_find, lv.item_count); var surrounding = util.surrounding(sel, max_count, 0, lv.item_count); int min = surrounding.Item1, max = surrounding.Item2; // at this point, we know the start and end for (int idx = min; idx < max; ++idx) { var i = lv.item_at(idx); List <string> row = new List <string>(); foreach (int col_idx in column_indexes_) { row.Add(log_view_cell.cell_value(i, col_idx)); } preview_items_.Add(row); } for (int match_idx = 0; match_idx < preview_items_.Count; ++match_idx) { matches_.Add(match_idx); } }
private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) { match_item item = lv.sel; int row = lv.sel_row_idx; string txt = (item as filter.match).line.part(type); int col_idx = log_view_cell.info_type_to_cell_idx(type); var prints = lv.sel.override_print(lv, txt, col_idx, column_formatter_base.format_cell.location_type.details_pane).format_text.to_single_enter_char(); // ... text has changed txt = prints.text; text_ctrl.Clear(); text_ctrl.AppendText(txt); var full_row = lv.list.GetItem(row); text_ctrl.BackColor = drawer_.bg_color(full_row, col_idx, prints); var parts = prints.parts(default_print_); foreach (var part in parts) { text_ctrl.Select(part.start, part.len); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, part); text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, part); } }
public search_renderer(log_view parent, search_form search) { search_ = search; drawer_ = new log_view_item_draw_ui(parent); Color normal_fg_ = app.inst.fg, normal_bg_ = app.inst.bg; default_ = new text_part(0, 0) { fg = normal_fg_, bg = normal_bg_, }; Color search_line_fg_ = app.inst.search_found_full_line_fg, search_line_bg_ = app.inst.bg; around_search_ = new text_part(0, 0) { 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_text_ = new text_part(0, 0) { text = "not important", fg = search_fg_, bg = search_bg_, bold = true, italic = false }; }
public log_view_item_draw_ui(log_view parent) { parent_ = parent; font_ = parent_.list.Font; b_font = new Font(font_.FontFamily, font_.Size, FontStyle.Bold); bi_font = new Font(font_.FontFamily, font_.Size, FontStyle.Bold | FontStyle.Italic); i_font = new Font(font_.FontFamily, font_.Size, FontStyle.Italic); }
internal static OLVColumn column(log_view lv, info_type type) { switch (type) { case info_type.line: return(lv.lineCol); case info_type.view: return(lv.viewCol); case info_type.msg: return(lv.msgCol); case info_type.time: return(lv.timeCol); case info_type.date: return(lv.dateCol); case info_type.level: return(lv.levelCol); case info_type.thread: return(lv.threadCol); case info_type.file: return(lv.fileCol); case info_type.func: return(lv.funcCol); case info_type.class_: return(lv.classCol); case info_type.ctx1: return(lv.ctx1Col); case info_type.ctx2: return(lv.ctx2Col); case info_type.ctx3: return(lv.ctx3Col); case info_type.ctx4: return(lv.ctx4Col); case info_type.ctx5: return(lv.ctx5Col); case info_type.ctx6: return(lv.ctx6Col); case info_type.ctx7: return(lv.ctx7Col); case info_type.ctx8: return(lv.ctx8Col); case info_type.ctx9: return(lv.ctx9Col); case info_type.ctx10: return(lv.ctx10Col); case info_type.ctx11: return(lv.ctx11Col); case info_type.ctx12: return(lv.ctx12Col); case info_type.ctx13: return(lv.ctx13Col); case info_type.ctx14: return(lv.ctx14Col); case info_type.ctx15: return(lv.ctx15Col); } Debug.Assert(false); return(lv.msgCol); }
private List <text_part> override_print_from_all_places(log_view parent, string text, int col_idx) { List <text_part> print = new List <text_part>(); // 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 text_part(ff.start, ff.len) { 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) { foreach (var match in matches) { print.Add(new text_part(match, sel.Length) { bold = true, text = sel, is_typed_search = true }); } } } 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 != ""; foreach (var match in matches) { print.Add(new text_part(match.Item1, match.Item2) { text = find, bg = parent.cur_search.bg, fg = parent.cur_search.fg, bold = true, italic = italic, is_find_search = true }); } } } return(print); }
// allow overriding the parent public void set_parent(log_view parent) { Debug.Assert(parent != null); if (parent == parent_) { return; } parent_ = parent; }
public void init(log_view parent) { parent_ = parent; drawer_ = new log_view_item_draw_ui(parent); util.postpone(update_ui, 10); // ... easier testing // if ( util.is_debug) // BorderStyle = BorderStyle.FixedSingle; }
public override Color bg(log_view parent) { var result = parent.lv_parent.full_log_row_colors(line_idx).Item2; if (result == util.transparent) { result = app.inst.bg; } return(result); }
static public void refresh_visible_columns(List <log_view> all_views, log_view full_log) { Debug.Assert(full_log.is_full_log); if (refresh_visible_columns_any_change(full_log)) { if (full_log.available_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { // at this point, we need to apply custom positions to all views // if they were cached (computed before) -> we already have them // if they were not cached, we force them now if (full_log.column_positions == "") { full_log.column_positions = column_positions_as_string(full_log); } foreach (log_view lv in all_views) { if (lv.column_positions == "") { lv.column_positions = full_log.column_positions; } } } foreach (log_view lv in all_views) { lv.list.SuspendLayout(); } full_log.list.SuspendLayout(); // notify all other views foreach (log_view lv in all_views) { refresh_visible_columns(lv); } // now, apply the saved-custom-positions, if any foreach (log_view lv in all_views) { apply_column_positions(lv); } apply_column_positions(full_log); full_log.update_column_names(); foreach (log_view lv in all_views) { lv.update_column_names(); } foreach (log_view lv in all_views) { lv.list.ResumeLayout(true); } full_log.list.ResumeLayout(true); } }
internal snoop_filter(log_view view) { view_ = view; // add the most of possible snoops foreach ( info_type type in Enum.GetValues(typeof(info_type))) if (info_type_io.is_snoopable(type)) { var form = new snoop_around_form(); form.on_apply = on_apply; form.on_snoop = on_snoop; unused_.Add( new snoop_form_info { form = form } ); } }
public log_view_data_source(VirtualObjectListView lv, log_view parent) : base(lv) { lv_ = lv; parent_ = parent; items_ = parent.filter.matches; change_event_.current_thread_is_owner(); new Thread(update_filter_thread) { IsBackground = true }.Start(); }
static internal void apply_column_positions(log_view lv) { if (lv.column_positions != "") { if (lv.column_positions == column_positions_as_string(lv)) { // in this case, nothing changed return; } load_column_positions(lv, lv.column_positions); } }
public search_renderer(log_view parent, search_form search) { search_ = search; drawer_ = new log_view_item_draw_ui(parent); Color normal_fg_ = app.inst.fg, normal_bg_ = app.inst.bg; default_ = new text_part(0,0) { fg = normal_fg_, bg = normal_bg_, }; Color search_line_fg_ = app.inst.search_found_full_line_fg, search_line_bg_ = app.inst.bg; around_search_ = new text_part(0,0) { 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_text_ = new text_part(0,0) { text = "not important", fg = search_fg_, bg = search_bg_, bold = true, italic = false }; }
private void find_result_columns(log_view lv) { // see which columns actually have useful data List <Tuple <int, int> > columns_and_displayidx = new List <Tuple <int, int> >(); var available_columns = lv.available_columns; // ... getting available columns: time-consuming for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { if (lv.list.AllColumns[col_idx].Width > 0) { if (col_idx != lv.viewCol.fixed_index() && available_columns.Contains(log_view_cell.cell_idx_to_type(col_idx))) { columns_and_displayidx.Add(new Tuple <int, int>(col_idx, lv.list.AllColumns[col_idx].DisplayIndex)); } } } column_indexes_ = columns_and_displayidx.OrderBy(x => x.Item2).Select(x => x.Item1).ToList(); searchable_columns_.Clear(); searchable_columns_msg_only_.Clear(); int preview_col_idx = 0; foreach (int col_idx in column_indexes_) { result.AllColumns[preview_col_idx].Width = lv.list.AllColumns[col_idx].Width; result.AllColumns[preview_col_idx].Text = lv.list.AllColumns[col_idx] != lv.msgCol ? lv.list.AllColumns[col_idx].Text : "Message"; result.AllColumns[preview_col_idx].FillsFreeSpace = lv.list.AllColumns[col_idx].FillsFreeSpace; // note: the line column never enters the search bool is_searchable = info_type_io.is_searchable(log_view_cell.cell_idx_to_type(col_idx)); if (is_searchable) { searchable_columns_.Add(preview_col_idx); } if (lv.msgCol == lv.list.AllColumns[col_idx]) { searchable_columns_msg_only_.Add(preview_col_idx); } if (lv.lineCol != lv.list.AllColumns[col_idx]) { result.AllColumns[preview_col_idx].Renderer = render_; } ++preview_col_idx; } for (; preview_col_idx < result.AllColumns.Count; ++preview_col_idx) { result.AllColumns[preview_col_idx].IsVisible = false; } result.RebuildColumns(); }
static private void show_column(log_view lv, OLVColumn col, int width, bool show) { //if( lv.is_full_log) // logger.Debug("showing column " + col.Text + " w=" + width +" visible=" + show); if (col.Width == 0) { col.Width = width; } if (col.IsVisible == show) { return; } col.Width = width; col.IsVisible = show; }
static private string default_column_positions_string(log_view lv) { string positions = ""; // column: display index, width, visible for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; int display_index = col.DisplayIndex >= 0 ? col.DisplayIndex : col.LastDisplayIndex; if (col.Width > 0) { positions += "" + col_idx + "," + display_index + "," + (col == lv.msgCol ? col.Width : DEFAULT_COL_WIDTH) + "," + "1" + ";"; } } return(positions); }
public virtual Color bg(log_view parent) { Color result; #if old_code if (parent.has_bookmark(base.line_idx)) { result = parent.bookmark_bg; } else #endif if (override_bg != util.transparent) { result = override_bg; } else { result = font.bg; } // 1.6.6 - if user has searched for something only visible in description pane, show it a bit darker, so the user knows it's a match on this line if (result == util.transparent) { if (parent.is_searching) { var view_visible = parent.view_visible_column_types(); bool search_matches_view = search_matches_any_column(parent, view_visible); if (!search_matches_view) { var all_visible = parent.all_visible_column_types(); var details_visible = all_visible.Where(x => !view_visible.Contains(x)).ToList(); if (search_matches_any_column(parent, details_visible)) { result = search_form_history.inst.default_search.bg; } } } } if (result == util.transparent) { result = app.inst.bg; } return(result); }
public edit_column_formatters_form(log_view lv, string format_syntax, bool apply_only_to_me) { lv_ = lv; InitializeComponent(); list.VirtualMode = false; list.Font = lv.list.Font; var formatter = new column_formatter_array(); formatter.load(format_syntax); render_ = new column_formatter_renderer(lv, list); render_.formatter = formatter; syntax.Text = prev_syntax_ = render_.formatter.syntax; applyToCurrentViewOnly.Checked = apply_only_to_me; update_column_visibility(); load_surrounding_rows(); }
static private void refresh_visible_columns(log_view lv, log_view full_log) { Debug.Assert(!lv.is_full_log); for (int idx = 0; idx < lv.list.AllColumns.Count; ++idx) { var col = lv.list.AllColumns[idx]; if (col != lv.viewCol) { show_column(lv, col, full_log.list.AllColumns[idx].Width, full_log.list.AllColumns[idx].IsVisible); } else { show_column(lv, col, DEFAULT_COL_WIDTH, false); } } lv.list.RebuildColumns(); }
static private bool has_value_at_column(log_view lv, info_type type, int max_rows_to_check) { // msg is always shown if (type == info_type.msg) { return(true); } if (type == info_type.line || type == info_type.view) { return(true); } if (max_rows_to_check == 0) { // before reading anything from the log return(false); } var aliases = lv.filter.log.aliases; // 1.5.4+ if the user has already specified clearly that we have this column, we consider it true if (aliases.has_column(type)) { return(true); } int value_count = 0; for (int idx = 0; idx < max_rows_to_check; ++idx) { var i = lv.item_at(idx); if (i.line_idx < 0) { continue; } if (log_view_cell.cell_value_by_type(i, type) != "") { ++value_count; } } bool has_values = (value_count > 0); return(has_values); }
static private void refresh_visible_columns(log_view lv) { Debug.Assert(!lv.is_full_log); if (lv.column_positions != "") { // in this case, we know everything about how to position the columns, and which is visible/invisible return; } var available = lv.available_columns; for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; var col_type = log_view_cell.cell_idx_to_type(col_idx); show_column(col, DEFAULT_COL_WIDTH, available.Contains(col_type) && col != lv.viewCol); } lv.list.RebuildColumns(); }
private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) { match_item item = lv.sel; int row = lv.sel_row_idx; string txt = (item as filter.match).line.part(type); int col = log_view_cell.info_type_to_cell_idx(type); var prints = lv.sel.override_print(lv, txt, col); print_info.to_single_enter_char(ref txt, ref prints); text_ctrl.Clear(); text_ctrl.AppendText(txt); var full_row = lv.list.GetItem(row); text_ctrl.BackColor = drawer_.bg_color(full_row, 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 = txt.Substring(last_idx, cur_idx - last_idx); if (before != "") { text_ctrl.Select(last_idx, cur_idx - last_idx); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_); text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col); } text_ctrl.Select(cur_idx, cur_len); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, prints[print_idx].Item3); text_ctrl.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 < txt.Length) { text_ctrl.Select(last_idx, txt.Length - last_idx); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_); text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col); } }
static private bool refresh_visible_columns_any_change(log_view full_log) { Debug.Assert(full_log.is_full_log); if (full_log.visible_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { return(false); } int count = full_log.item_count; bool needs_refresh = count != full_log.visible_columns_refreshed_; if (needs_refresh) { List <info_type> visible_columns = new List <info_type>(); int row_count = Math.Min(count, MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS); foreach (info_type type in Enum.GetValues(typeof(info_type))) { if (type == info_type.max) { continue; } bool is_visible = has_value_at_column(full_log, type, row_count); show_column(full_log, log_view_cell.column(full_log, type), DEFAULT_COL_WIDTH, is_visible); if (is_visible) { visible_columns.Add(type); } } full_log.visible_columns_refreshed_ = count; full_log.visible_columns = visible_columns; logger.Debug("visible columns (" + row_count + ") - " + util.concatenate(visible_columns, ", ")); full_log.list.RebuildColumns(); } if (count >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { full_log.visible_columns_refreshed_ = MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS; } return(needs_refresh); }
public void update(log_view view, int top_offset, int bottom_offset, bool force_update) { Rectangle wizard_rect = (wizard_parent_ as log_view_parent).client_rect_no_filter; Rectangle wizard_screen = wizard_parent_.RectangleToScreen(wizard_rect); // ... care about the lower buttons wizard_rect.Y += top_offset; wizard_rect.Height -= bottom_offset + top_offset; string sel = view.sel_line_text; if (sel == "") { show(false); return; } if (sel == txt.Text && !force_update) return; // nothing changed if (view == force_hide_for_view_ && view.sel_row_idx == force_hide_for_row_) // user forced us to hide return; int height_offset = 10; var new_size = new Size( wizard_rect.Width, Math.Min( text_height(sel, wizard_rect.Width) + height_offset, MAX_HEIGHT) ); Size = new_size; Rectangle line_rect = view.sel_rect_screen; if (can_text_fit_in_width(sel, line_rect.Width)) { show(false); return; } int distance_to_top = line_rect.Top - wizard_screen.Top; int distance_to_bottom = wizard_screen.Bottom - line_rect.Bottom; bool on_top = distance_to_top >= distance_to_bottom; // always prefer bottom var bottom_rect_screen = Parent.RectangleToScreen( new Rectangle(new Point(wizard_rect.Left, wizard_rect.Bottom - Height), new_size)); if (!line_rect.IntersectsWith(bottom_rect_screen)) on_top = false; var new_location = new Point(wizard_rect.Left, on_top ? wizard_rect.Top : wizard_rect.Bottom - Height); set_text(view); show(true, new_location); }
public void show_cur_item(log_view lv) { if (drawer_ == null) { drawer_ = new log_view_item_draw_ui(lv) { ignore_selection = true } } ; drawer_.set_parent(lv); if (lv.sel != null) { foreach (var col in column_to_controls_) { show_sub_item(lv, col.Key, col.Value.Item2); } } } }
/* Edit mode: * 1. if more than 1 entry, the combo is dropped down by default * 2. if you type any letter while the combo is first dropped down (or paste something), it will auto close the dropdown * 3. if you select any entry from the combo, you are EDITING that entry. If you don't select anything, you are ADDING */ // 1.2.7+ if there's something selected by the user, override what we had public search_form(Form parent, log_view lv, string smart_edit_search_for_text) { InitializeComponent(); TopMost = parent.TopMost; result.Font = lv.list.Font; lv_ = lv; render_ = new search_renderer(lv, this); history_ = search_form_history.inst.all_searches_cur_view_first(lv.name); // use the last ones... fg.BackColor = history_[0].fg; bg.BackColor = history_[0].bg; allColumns.Checked = history_[0].all_columns; load_combo(); find_result_columns(lv); if (smart_edit_search_for_text != "") { combo.Text = smart_edit_search_for_text; radioText.Checked = true; } update_autorecognize_radio(); update_negate(); update_to_filter_button(); prev_search_ = current_search(); util.postpone(() => { combo.Focus(); if (combo.Items.Count > 1) { dropped_first_time_ = true; combo.DroppedDown = true; } }, 1); new Thread(do_searches_thread) { IsBackground = true }.Start(); }
public Color sel_bg(log_view parent) { var bg = this.bg(parent); if (parent.needs_scroll) { // the idea is that if this view updates a LOT and we're at the last row, // it's disturbing to the eye to constantly have new rows added (thus the former "last" would go up - being marked as "selected", // then the selection would change to be the new "last", and so on) if (parent.filter.last_change.AddSeconds(3.5) > DateTime.Now) { return(bg); } } Color dark_bg = util.darker_color(bg); Color darker_bg = util.darker_color(dark_bg); var focus = win32.focused_ctrl(); bool is_focused = focus == parent.list || focus == parent.edit; return(is_focused ? darker_bg : dark_bg); }
static public void refresh_visible_columns(List<log_view> all_views, log_view full_log) { Debug.Assert(full_log.is_full_log); if (refresh_visible_columns_any_change(full_log)) { // notify all other views foreach (log_view lv in all_views) { lv.visible_columns = full_log.visible_columns; refresh_visible_columns(lv, full_log); } if ( full_log.visible_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) foreach (log_view lv in all_views) // in tihs case, we consider knowing the visible-columns for ALL views lv.visible_columns_refreshed_ = MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS; // now, apply the saved-custom-positions, if any foreach (log_view lv in all_views) apply_column_positions(lv); apply_column_positions(full_log); full_log.update_column_names(); foreach (log_view lv in all_views) lv.update_column_names(); } }
static public void refresh_visible_columns(List<log_view> all_views, log_view full_log) { Debug.Assert(full_log.is_full_log); if (refresh_visible_columns_any_change(full_log)) { if (full_log.available_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) { // at this point, we need to apply custom positions to all views // if they were cached (computed before) -> we already have them // if they were not cached, we force them now if ( full_log.column_positions == "") full_log.column_positions = column_positions_as_string(full_log); foreach (log_view lv in all_views) if (lv.column_positions == "") lv.column_positions = full_log.column_positions; } foreach (log_view lv in all_views) lv.list.SuspendLayout(); full_log.list.SuspendLayout(); // notify all other views foreach (log_view lv in all_views) refresh_visible_columns(lv); // now, apply the saved-custom-positions, if any foreach (log_view lv in all_views) apply_column_positions(lv); apply_column_positions(full_log); full_log.update_column_names(); foreach (log_view lv in all_views) lv.update_column_names(); foreach (log_view lv in all_views) lv.list.ResumeLayout(true); full_log.list.ResumeLayout(true); } }
private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) { match_item item = lv.sel; int row = lv.sel_row_idx; string txt = (item as filter.match).line.part(type); int col = log_view_cell.info_type_to_cell_idx(type); var prints = lv.sel.override_print(lv, txt, type); print_info.to_single_enter_char(ref txt, ref prints); text_ctrl.Clear(); text_ctrl.AppendText(txt); var full_row = lv.list.GetItem(row); text_ctrl.BackColor = drawer_.bg_color(full_row, 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 = txt.Substring(last_idx, cur_idx - last_idx); if (before != "") { text_ctrl.Select(last_idx, cur_idx - last_idx); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_); text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col); } text_ctrl.Select(cur_idx, cur_len); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, prints[print_idx].Item3); text_ctrl.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 < txt.Length) { text_ctrl.Select(last_idx, txt.Length - last_idx); text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_); text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col); } }
static internal string column_positions_as_string(log_view lv) { string positions = ""; // column: display index, width, visible for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; int display_index = col.DisplayIndex >= 0 ? col.DisplayIndex : col.LastDisplayIndex; if (col.Width > 0) { // "2" - I don't have this column in my current log - so I don't show it, but, when another log might have this column, do show it // "1" - column is to be shown // "0" - user manually chose to hide this column string visible = lv.available_columns.Contains(log_view_cell.cell_idx_to_type(col_idx)) ? (col.is_visible() ? "1" : "0") : "2"; positions += "" + col_idx + "," + display_index + "," + col.col_width() + "," + visible + ";"; } } if (positions == default_column_positions_string(lv)) // user hasn't changed anything return ""; return positions; }
static private string default_column_positions_string(log_view lv) { string positions = ""; // column: display index, width, visible for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; int display_index = col.DisplayIndex >= 0 ? col.DisplayIndex : col.LastDisplayIndex; if (col.Width > 0) positions += "" + col_idx + "," + display_index + "," + (col == lv.msgCol ? col.Width : DEFAULT_COL_WIDTH)+ "," + "1" + ";"; } return positions; }
static private void load_column_positions(log_view lv, string str) { if (str == "") return; // display index -> column index Dictionary<int, int > display_indexes = new Dictionary<int, int>(); foreach ( var pos in str.Split(';')) if (pos != "") { string[] infos = pos.Split(','); Debug.Assert(infos.Length == 4); int col_idx = int.Parse(infos[0]); int display_index = int.Parse(infos[1]); int width = int.Parse(infos[2]); bool visible = infos[3] != "0"; // this means this column is visible - so we can apply column positioning // (othwerise, this column doesn't even exist for this specific file - nothing to do) lv.list.AllColumns[col_idx].col_width( width); // 1.5.4+ - if we don't have a value in the given column, don't show it if (! lv.available_columns.Contains( log_view_cell.cell_idx_to_type(col_idx))) visible = false; if (!lv.is_full_log && log_view_cell.cell_idx_to_type(col_idx) == info_type.view) // View(s) only visible in Full Log visible = false; lv.list.AllColumns[col_idx].is_visible( visible); if (visible) { while (display_indexes.ContainsKey(display_index)) // this can happen when moving from one log to another, and they have very different columns ++display_index; display_indexes.Add(display_index, col_idx); } } // need to convert display indexes into what can be displayed - you can't have a display index bigger than // the number of shown columns Dictionary<int,int> index_to_loaded_index = new Dictionary<int, int>(); int cur_idx = 0; foreach ( var loaded_idx in display_indexes.Select(x => x.Key).OrderBy(x => x) ) index_to_loaded_index.Add(cur_idx++, loaded_idx); foreach (var raw_idx in index_to_loaded_index) { int display_index = raw_idx.Key; int original_display_index = raw_idx.Value; int col_idx = display_indexes[original_display_index]; var col = lv.list.AllColumns[col_idx]; col.LastDisplayIndex = display_index; } lv.list.RebuildColumns(); }
private void show(bool do_show, Point p = default(Point) ) { // 1.5.10 - when Description control is shown, we never show this do_show = do_show && !force_hide_; if (do_show) { force_hide_for_row_ = -1; force_hide_for_view_ = null; Location = p; BringToFront(); } else { txt.Text = ""; Location = new Point(-100000, -100000); } }
public void show_cur_item(log_view lv) { if ( drawer_ == null) drawer_ = new log_view_item_draw_ui(lv) { ignore_selection = true }; drawer_.set_parent(lv); if (lv.sel != null) { foreach (var col in column_to_controls_) show_sub_item(lv, col.Key, col.Value.Item2); } }
private void show(bool do_show, Point p = default(Point) ) { if (do_show) { force_hide_for_row_ = -1; force_hide_for_view_ = null; Location = p; BringToFront(); } else { txt.Text = ""; Location = new Point(-100000, -100000); } }
public override Color bg(log_view parent) { var result = parent.lv_parent.full_log_row_colors(line_idx).Item2; if (result == util.transparent) result = app.inst.bg; return result; }
public full_log_match_item(BitArray matches, font_info font, line line, int line_idx, log_view parent) : base(matches, font, line, line_idx, parent) { Debug.Assert(parent != null); parent_ = parent; }
public log_view_column_tag(log_view parent) { this.parent = parent; }
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; }
public void force_temporary_hide(log_view lv) { force_hide_for_view_ = lv; force_hide_for_row_ = lv.sel_row_idx; show(false); }
internal static OLVColumn column(log_view lv, info_type type) { switch (type) { case info_type.line: return lv.lineCol; case info_type.view: return lv.viewCol; case info_type.msg: return lv. msgCol; case info_type.time: return lv. timeCol; case info_type.date: return lv. dateCol; case info_type.level: return lv. levelCol; case info_type.thread: return lv. threadCol; case info_type.file: return lv. fileCol; case info_type.func: return lv. funcCol; case info_type.class_: return lv. classCol; case info_type.ctx1: return lv. ctx1Col; case info_type.ctx2: return lv. ctx2Col; case info_type.ctx3: return lv. ctx3Col; case info_type.ctx4: return lv. ctx4Col; case info_type.ctx5: return lv. ctx5Col; case info_type.ctx6: return lv. ctx6Col; case info_type.ctx7: return lv. ctx7Col; case info_type.ctx8: return lv. ctx8Col; case info_type.ctx9: return lv. ctx9Col; case info_type.ctx10: return lv. ctx10Col; case info_type.ctx11: return lv. ctx11Col; case info_type.ctx12: return lv. ctx12Col; case info_type.ctx13: return lv. ctx13Col; case info_type.ctx14: return lv. ctx14Col; case info_type.ctx15: return lv. ctx15Col; } Debug.Assert(false); return lv. msgCol; }
static internal void apply_column_positions(log_view lv) { if (lv.column_positions != "") { if (lv.column_positions == column_positions_as_string(lv)) // in this case, nothing changed return; load_column_positions(lv, lv.column_positions); } }
internal static info_type column_to_type(log_view lv, OLVColumn col) { if (col == lv.lineCol) return info_type.line; if (col == lv.viewCol) return info_type.view; if (col == lv.dateCol) return info_type.date; if (col == lv.timeCol) return info_type.time; if (col == lv.levelCol) return info_type.level; if (col == lv.threadCol) return info_type.thread; if (col == lv.fileCol) return info_type.file; if (col == lv.funcCol) return info_type.func; if (col == lv.classCol) return info_type.class_; if (col == lv.ctx1Col) return info_type.ctx1; if (col == lv.ctx2Col) return info_type.ctx2; if (col == lv.ctx3Col) return info_type.ctx3; if (col == lv.ctx4Col) return info_type.ctx4; if (col == lv.ctx5Col) return info_type.ctx5; if (col == lv.ctx6Col) return info_type.ctx6; if (col == lv.ctx7Col) return info_type.ctx7; if (col == lv.ctx8Col) return info_type.ctx8; if (col == lv.ctx9Col) return info_type.ctx9; if (col == lv.ctx10Col) return info_type.ctx10; if (col == lv.ctx11Col) return info_type.ctx11; if (col == lv.ctx12Col) return info_type.ctx12; if (col == lv.ctx13Col) return info_type.ctx13; if (col == lv.ctx14Col) return info_type.ctx14; if (col == lv.ctx15Col) return info_type.ctx15; if (col == lv.msgCol) return info_type.msg; Debug.Assert(false); return info_type.max; }
// note: only after I have at least MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS, can I know the available columns // even though I may have a valid column_positions string, I will use it only when we have enough rows (MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) static private bool refresh_visible_columns_any_change(log_view full_log) { Debug.Assert(full_log.is_full_log); bool force_refresh = false; // 1.6.13+ - if we already have the cached available columns (computed before), just use them if (full_log.available_columns_refreshed_ == -1) if (full_log.available_columns.Count > 0 ) { // at this point, I already have computed the columns - they were computed last time we ran full_log.use_previous_available_columns_ = true; // here, I make sure every other view reuses what we already have cached force_refresh = true; full_log.available_columns_refreshed_ = 0; } if (full_log.available_columns_refreshed_ >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) return false; int count = full_log.item_count; bool needs_refresh = count != full_log.available_columns_refreshed_; if (needs_refresh) { // if they were previously computed, the only time I recompute them, is after we have at least MIN_ROWS bool needs_recompute_now = count > 0 && ( !full_log.use_previous_available_columns_ || count >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS); full_log.available_columns_refreshed_ = count; if (needs_recompute_now) { full_log.list.SuspendLayout(); // this is the first time we compute the columns for this log - just in case they were moved around in the previous log(s), // we want to reset them back foreach (var column in full_log.list.AllColumns) column.LastDisplayIndex = column.fixed_index(); List<info_type> available_columns = new List<info_type>(); int row_count = Math.Min(count, MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS); foreach (info_type type in Enum.GetValues(typeof (info_type))) { if (type == info_type.max) continue; bool is_visible = has_value_at_column(full_log, type, row_count); show_column(log_view_cell.column(full_log, type), DEFAULT_COL_WIDTH, is_visible); if (is_visible) available_columns.Add(type); } full_log.available_columns = available_columns; logger.Debug("available columns (" + row_count + ") - " + util.concatenate(available_columns, ", ")); full_log.list.RebuildColumns(); full_log.list.ResumeLayout(true); } else // if we end up here, we've already refreshed the other views with what we have cached needs_refresh = false; if (!full_log.use_previous_available_columns_ && count >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) keep_only_important_columns(full_log); } if (count >= MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS) full_log.available_columns_refreshed_ = MIN_ROWS_FOR_COMPUTE_VISIBLE_COLUMNS; return needs_refresh || force_refresh; }
static private void keep_only_important_columns(log_view full_log) { Debug.Assert(full_log.is_full_log); // the idea is that we do this only the first time when showing the log // after that, the user can customize it as he wishes Debug.Assert( !full_log.use_previous_available_columns_ ); var available = full_log.available_columns.OrderBy(x => -info_type_io.show_in_view_by_default(x) ).ToList(); bool has_date_column = available.Contains(info_type.date); if (available.Count <= MAX_DEFAULT_VIEW_COLUMNS && !has_date_column) // we're fine return; // too many columns, hide a few full_log.list.SuspendLayout(); var to_erase = available.GetRange(MAX_DEFAULT_VIEW_COLUMNS, available.Count - MAX_DEFAULT_VIEW_COLUMNS); if ( has_date_column && !to_erase.Contains(info_type.date)) to_erase.Add(info_type.date); foreach ( var col_type in to_erase) show_column( log_view_cell.column(full_log, col_type), DEFAULT_COL_WIDTH, false ); full_log.list.RebuildColumns(); full_log.list.ResumeLayout(true); // recompute visible columns full_log.column_positions = column_positions_as_string(full_log); full_log.lv_parent.needs_details_pane(); }
static private void refresh_visible_columns(log_view lv) { Debug.Assert(!lv.is_full_log); if (lv.column_positions != "") // in this case, we know everything about how to position the columns, and which is visible/invisible return; var available = lv.available_columns; for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) { var col = lv.list.AllColumns[col_idx]; var col_type = log_view_cell.cell_idx_to_type(col_idx); show_column(col, DEFAULT_COL_WIDTH, available.Contains(col_type) && col != lv.viewCol); } lv.list.RebuildColumns(); }
public log_view_render(log_view parent) { parent_ = parent; drawer_ = new log_view_item_draw_ui(parent_); }