// if ignore_color, it's a "Default Color" include filter private bool include_lines(bool starting_with, bool color_full_line, bool case_sensitive, bool ignore_color = false) { Color col = util.transparent; if (!ignore_color) { string header = (color_full_line ? "Color" : "Match Color") + " for Lines " + (starting_with ? "Starting With " : "Containing ") + parent_.smart_edit_sel_text + " " + (case_sensitive ? "" : "(case-INsensitive)"); var location = parent_.PointToScreen(carent_pos); var sel = new select_color_form(header, parent_.sel.fg(parent_), location); bool ok = sel.ShowDialog() == DialogResult.OK; if (!ok) { return(false); } col = sel.SelectedColor; } bool is_color_filter = col != util.transparent; bool is_include_lines = true; bool is_exclude_lines = false; string filter_str = "$msg " + (starting_with ? "startswith" : "contains") + " " + parent_.smart_edit_sel_text + (is_color_filter ? "\r\n" + (color_full_line ? "color" : "match_color") + " " + util.color_to_str(col) : "") + (case_sensitive ? "" : "\r\ncase-insensitive"); string filter_description = "include lines " + (starting_with ? "starting with " : "containing") + " " + parent_.smart_edit_sel_text; do_add_filter(filter_str, filter_description, is_color_filter, is_include_lines, is_exclude_lines); return(true); }
private void toFilter_Click(object sender, EventArgs e) { search_ = current_search(); if (search_.fg == util.transparent) { var sel = new select_color_form("Filter Foreground Color", Color.Red); if (sel.ShowDialog() == DialogResult.OK) { fg.BackColor = sel.SelectedColor; search_ = current_search(); Debug.Assert(search_.fg != util.transparent); } else { // user did not select a foreground - this is required return; } } if (markAsNewEntry.Checked) { unique_search_id_ = 0; } search_.unique_id = unique_search_id_; wants_to_filter_ = true; DialogResult = DialogResult.OK; }
private void bg_Click(object sender, EventArgs e) { var sel = new select_color_form("Background Color", fg.BackColor); if (sel.ShowDialog() == DialogResult.OK) { bg.BackColor = sel.SelectedColor; update_to_filter_button(); } }
private void categories_CellClick(object sender, BrightIdeasSoftware.CellClickEventArgs e) { // logger.Debug("cell click " + e.ColumnIndex); if (e.RowIndex < 0) { return; } if (e.ColumnIndex < 1) { return; } var row = categories.GetItem(e.RowIndex).RowObject as item; var color = row.color_by_index(e.ColumnIndex); var sel = new select_color_form("Choose color...", color); if (sel.ShowDialog() == DialogResult.OK) { var old_color = row.color_by_index(e.ColumnIndex); row.color_by_index(e.ColumnIndex, sel.SelectedColor); categories.RefreshObject(row); bool click_on_bg_color = e.ColumnIndex == 1; if (click_on_bg_color) { bool color_already_used = false; for (int i = 0; i < categories.GetItemCount() && !color_already_used; ++i) { if (i != e.RowIndex) { if ((categories.GetItem(i).RowObject as item).colors.bg_color.ToArgb() == sel.SelectedColor.ToArgb()) { // in this case, the user selected a color that is already used // have the former row use our old color (categories.GetItem(i).RowObject as item).colors.bg_color = old_color; color_already_used = true; categories.RefreshItem(categories.GetItem(i)); } } } if (!color_already_used) { unused_.Add(old_color); } } update_preview(); on_category_colors_change(colors_); } }
// if ignore_color, it's a "Default Color" include filter private bool include_lines(bool starting_with, bool color_full_line, bool case_sensitive, bool ignore_color = false) { Color col = util.transparent; if (!ignore_color) { string header = (color_full_line ? "Color" : "Match Color") + " for Lines " + (starting_with ? "Starting With " : "Containing ") + parent_.smart_edit_sel_text + " " + (case_sensitive ? "" : "(case-INsensitive)") ; var location = parent_.PointToScreen( carent_pos); var sel = new select_color_form(header, parent_.sel.fg(parent_), location ); bool ok = sel.ShowDialog() == DialogResult.OK; if (!ok) return false; col = sel.SelectedColor; } bool is_color_filter = col != util.transparent; bool is_include_lines = true; bool is_exclude_lines = false; string filter_str = "$msg " + (starting_with ? "startswith" : "contains") + " " + parent_.smart_edit_sel_text + (is_color_filter ? "\r\n" + (color_full_line ? "color" : "match_color") + " " + util.color_to_str(col) : "") + (case_sensitive ? "" : "\r\ncase-insensitive"); string filter_description = "include lines " + (starting_with ? "starting with " : "containing") + " " + parent_.smart_edit_sel_text; do_add_filter(filter_str, filter_description, is_color_filter, is_include_lines, is_exclude_lines); return true; }
private void selectColor_Click(object sender, EventArgs e) { if (filterCtrl.SelectedIndex < 0) { return; // there's nothing selected } var sel = new select_color_form(); if (sel.ShowDialog() == DialogResult.OK) { string sel_color = util.color_to_str(sel.SelectedColor); var lines = curFilterCtrl.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList(); int sel_start = curFilterCtrl.SelectionStart; int edited_line = util.index_to_line(curFilterCtrl.Text, sel_start); if (edited_line >= 0 && !filter_line.is_color_or_font_line(lines[edited_line])) { // user is editing a line that is not a color line edited_line = -1; } if (edited_line == -1) { // it's not with the cursor on a line - find the first line that would actually be a color for (int i = 0; i < lines.Count && edited_line == -1; ++i) { if (filter_line.is_color_or_font_line(lines[i])) { edited_line = i; } } } if (edited_line != -1) { // in this case, he's editing the color from a given line bool is_color_line = filter_line.is_color_or_font_line(lines[edited_line]); bool is_replacing = lines[edited_line].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length <= 2 && lines[edited_line].TrimEnd() == lines[edited_line]; if (is_color_line) { if (is_replacing) { lines[edited_line] = (lines[edited_line].Trim().StartsWith("color ") ? "color" : "match_color") + " " + sel_color; } else { lines[edited_line] += " " + sel_color; } } else { // the edited line does not contain any color, thus, we append the color line edited_line = -1; } } if (edited_line == -1) { lines.Add("color " + sel_color); sel_start = -1; } curFilterCtrl.Text = util.concatenate(lines, "\r\n"); if (sel_start >= 0 && sel_start < curFilterCtrl.TextLength) { curFilterCtrl.SelectionStart = sel_start; } ui_to_view(view_idx_); on_save(); do_refresh(); } }
private void selectColor_Click(object sender, EventArgs e) { if (filterCtrl.SelectedIndex < 0) return; // there's nothing selected var sel = new select_color_form(); if (sel.ShowDialog() == DialogResult.OK) { string sel_color = util.color_to_str( sel.SelectedColor); var lines = curFilterCtrl.Text.Split( new string[] { "\r\n" }, StringSplitOptions.None ).ToList(); int sel_start = curFilterCtrl.SelectionStart; int edited_line = util.index_to_line(curFilterCtrl.Text, sel_start); if (edited_line >= 0 && !filter_line.is_color_or_font_line(lines[edited_line])) // user is editing a line that is not a color line edited_line = -1; if (edited_line == -1) { // it's not with the cursor on a line - find the first line that would actually be a color for ( int i = 0; i < lines.Count && edited_line == -1; ++i) if (filter_line.is_color_or_font_line( lines[i])) edited_line = i; } if (edited_line != -1) { // in this case, he's editing the color from a given line bool is_color_line = filter_line.is_color_or_font_line( lines[edited_line]); bool is_replacing = lines[edited_line].Split(new string[] {" "}, StringSplitOptions.RemoveEmptyEntries).Length <= 2 && lines[edited_line].TrimEnd() == lines[edited_line]; if (is_color_line) { if (is_replacing) lines[edited_line] = (lines[edited_line].Trim().StartsWith("color ") ? "color" : "match_color") + " " + sel_color; else lines[edited_line] += " " + sel_color; } else // the edited line does not contain any color, thus, we append the color line edited_line = -1; } if (edited_line == -1) { lines.Add("color " + sel_color); sel_start = -1; } curFilterCtrl.Text = util.concatenate(lines, "\r\n"); if ( sel_start >= 0 && sel_start < curFilterCtrl.TextLength) curFilterCtrl.SelectionStart = sel_start; ui_to_view(view_idx_); on_save(); do_refresh(); } }
private void selectColor_Click(object sender, EventArgs e) { if (notesCtrl.SelectedIndex < 0) return; var i = notesCtrl.GetItem(notesCtrl.SelectedIndex).RowObject as note_item; if (i.the_note == null) { Debug.Assert(false); return; } var sel = new select_color_form(); if (sel.ShowDialog() == DialogResult.OK) { string sel_color = util.color_to_str( sel.SelectedColor); string old_text = i.the_note.note_text; string new_text = old_text; if (old_text.Trim().StartsWith("#")) { old_text = old_text.Trim(); int space = old_text.IndexOf(' '); if (space > 0) old_text = old_text.Substring(space + 1).Trim(); else old_text = ""; // it contained only the color new_text = old_text; } i.the_note.note_text = "#" + sel_color + " " + new_text; refresh_note(i); dirty_ = true; ++ignore_change_; curNote.Text = i.the_note.note_text; curNote.SelectionStart = curNote.TextLength; curNote.Focus(); --ignore_change_; } }
private void categories_CellClick(object sender, BrightIdeasSoftware.CellClickEventArgs e) { // logger.Debug("cell click " + e.ColumnIndex); if (e.RowIndex < 0) return; if (e.ColumnIndex < 1) return; var row = categories.GetItem( e.RowIndex).RowObject as item; var color = row.color_by_index(e.ColumnIndex); var sel = new select_color_form("Choose color...", color); if (sel.ShowDialog() == DialogResult.OK) { var old_color = row.color_by_index(e.ColumnIndex); row.color_by_index(e.ColumnIndex, sel.SelectedColor); categories.RefreshObject(row); bool click_on_bg_color = e.ColumnIndex == 1; if (click_on_bg_color) { bool color_already_used = false; for (int i = 0; i < categories.GetItemCount() && !color_already_used; ++i) if (i != e.RowIndex) if ((categories.GetItem(i).RowObject as item).colors.bg_color.ToArgb() == sel.SelectedColor.ToArgb()) { // in this case, the user selected a color that is already used // have the former row use our old color (categories.GetItem(i).RowObject as item).colors.bg_color = old_color; color_already_used = true; categories.RefreshItem( categories.GetItem(i) ); } if ( !color_already_used) unused_.Add(old_color); } update_preview(); on_category_colors_change(colors_); } }
private void toFilter_Click(object sender, EventArgs e) { search_ = current_search(); if (search_.fg == util.transparent) { var sel = new select_color_form("Filter Foreground Color", Color.Red); if (sel.ShowDialog() == DialogResult.OK) { fg.BackColor = sel.SelectedColor; search_ = current_search(); Debug.Assert(search_.fg != util.transparent); } else // user did not select a foreground - this is required return; } if ( markAsNewEntry.Checked) unique_search_id_ = 0; search_.unique_id = unique_search_id_; wants_to_filter_ = true; DialogResult = DialogResult.OK; }