public Color OverrideColor(ColorTableGroup colorGroup, Color color) { var old = colors[colorGroup]; colors[colorGroup] = color; return(old); }
private void SetAlphaMenuItemClick(object sender, EventArgs e) { var item = sender as ToolStripItem; if (item == null) { return; } int alpha; if (int.TryParse(item.Text, out alpha)) { foreach (DataGridViewRow row in gridView.SelectedRows) { Color color = GetRowColor(row.Index); Color newColor = Color.FromArgb(alpha, color); ColorTableGroup group = GetRowColorGroup(row.Index); SetRow(row.Index, group, newColor); Renderer.ColorTable[group] = newColor; } gridView.Refresh(); Renderer.RefreshToolStrips(); } }
public Color ResetColor(ColorTableGroup colorGroup) { var baseColor = _defaultColors[colorGroup]; _colors[colorGroup] = baseColor; return(baseColor); }
public static void LoadFrom(CustomizableColorTable table, string filePath) { if (table == null) { throw new ArgumentNullException("table"); } if (filePath == null) { throw new ArgumentNullException("filePath"); } // VB or C#? bool vb = IsVbFile(filePath); Regex regex = new Regex( vb ? VbPattern : CsPattern, RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.IgnoreCase); // Try to open and read file. string text = File.ReadAllText(filePath); Match match = regex.Match(text); if (!match.Success) { throw new InvalidOperationException(); } // Reset all colors to their default values. table.InitFromBase(true); bool modified = false; while (match.Success) { string property = match.Groups["Property"].Value; string name = match.Groups["Name"].Value; Color color; if (!string.IsNullOrEmpty(name)) { color = Color.FromName(name); } else { int r = int.Parse(match.Groups["R"].Value); int g = int.Parse(match.Groups["G"].Value); int b = int.Parse(match.Groups["B"].Value); // Alpha chanel is optional. int a; if (!int.TryParse(match.Groups["A"].Value, out a)) { a = 255; } color = Color.FromArgb(a, r, g, b); } try { ColorTableGroup colorGroup = (ColorTableGroup)Enum.Parse( typeof(ColorTableGroup), property); table[colorGroup] = color; modified = true; } catch (ArgumentException) { } match = match.NextMatch(); } if (modified) { table.MakeColorsDefault(); } }
public Color this[ColorTableGroup colorGroup] { get { return(_colors[colorGroup]); } set { _colors[colorGroup] = value; } }
private void SetRow(int rowIndex, ColorTableGroup? colorGroup, Color color, string name = null) { var row = gridView.Rows[rowIndex]; var firstCell = row.Cells[ColorGroupColumnName]; var colorCell = row.Cells[ColorValueColumnName]; var imageCell = row.Cells[ColorColumnName]; var buttonCell = row.Cells[EditColumnName]; if (firstCell != null) { firstCell.Value = colorGroup == null ? name : colorGroup.ToString(); } if (colorCell != null) { colorCell.Value = color.IsNamedColor ? color.Name : string.Format(Resources.ColorText, color.A, color.R, color.G, color.B); } if (buttonCell != null) { buttonCell.Value = "..."; } if (imageCell != null) { imageCell.Value = CreateColorPreview(imageCell.Value as Image, color, Settings.Default.ColorWidth, Settings.Default.ColorHeight); } row.Tag = color; }
public Color OverrideColor(ColorTableGroup colorGroup, Color color) { var old = colors[colorGroup]; colors[colorGroup] = color; return old; }
public Color ResetColor(ColorTableGroup colorGroup) { Color baseColor = defaultColors[colorGroup]; colors[colorGroup] = baseColor; return baseColor; }
public Color this[ColorTableGroup colorGroup] { get { return colors[colorGroup]; } set { colors[colorGroup] = value; } }