private void preview_FormatRow(object sender, BrightIdeasSoftware.FormatRowEventArgs e) { if (e.RowIndex < 0) { return; } var row = preview.GetItem(e.RowIndex); var indexes = preview_indexes_array(); Debug.Assert(e.RowIndex < indexes.Length); var sel_index = preview_selected_index(); List <category_colors> colors = new List <category_colors>(); int color_index = 0; for (int i = 0; i < 3; ++i) { if (color_index == sel_index) { ++color_index; } colors.Add(color_index < colors_.Count ? colors_[color_index] : null); ++color_index; } // add sel + selected -sel now category_colors sel_color = sel_index >= 0 ? colors_[sel_index] : null; colors.Add(sel_color); colors.Add(sel_color); Color default_ = Color.White; var index = indexes[e.RowIndex]; Color bg = default_; if (colors[index] != null) { if (index == 4) { bg = util.darker_color(colors[index].this_category_bg, app.inst.selection_dark_effect); } else if (index == 3) { bg = colors[index].this_category_bg; } else { bg = colors[index].same_category_bg; } } row.BackColor = bg; }
public List <category_colors> get_colors(info_type type, List <string> possible_values) { List <category_colors> existing = new List <category_colors>(); var colors_now = sett_.get(type.ToString()).Split(new [] { color_delim }, StringSplitOptions.RemoveEmptyEntries); foreach (var str in colors_now) { var cur_col = str.Split(new[] { inside_color_delim }, StringSplitOptions.None); Debug.Assert(cur_col.Length == 4); category_colors cur_colors = new category_colors { name = cur_col[0], bg_color = util.str_to_color(cur_col[1]) }; if (cur_col[2] != "") { cur_colors.raw_same_category_bg = util.str_to_color(cur_col[2]); } if (cur_col[3] != "") { cur_colors.raw_this_category_bg = util.str_to_color((cur_col[3])); } existing.Add(cur_colors); } List <category_colors> result = new List <category_colors>(); foreach (var value in possible_values) { var found = existing.FirstOrDefault(x => x.name == value); if (found != null) { result.Add(found); } else { result.Add(new category_colors { name = value }); } } return(result); }
public item(category_colors colors) { colors_ = colors; }