public void AddColor(IColor c) { ListViewItem lvi = new ListViewItem(); lvi.Tag = c; // TODO: make this configurable lvi.Text = c.ToRgb().ToHtml(); il.Images.Add(c.GetHashCode().ToString(), RenderColorIcon.RenderBitmap(c.ToRgb())); lvi.ImageKey = c.GetHashCode().ToString(); Items.Add(lvi); }
public void UpdateTransparencyIndex() { var color = _palette?.Colors.Skip((int)transparencyIndexBox.Value).FirstOrDefault(); // that's a bit too much, should cut down if (_palette != null && _palette is ActPalette && ((ActPalette)_palette).TransparentIndex != null && color != null) { transparencyRenderBox.Image = RenderColorIcon.RenderBitmap(color.Color.ToRgb(), transparencyRenderBox.Width, transparencyRenderBox.Width); transparencyRenderLabel.Text = string.Format("{0} ({1})", color.Name, color.Color.ToRgb().ToHtml()); } else { transparencyRenderBox.Image = null; transparencyRenderLabel.Text = string.Empty; } }
private void ColorComboBox_DrawItem(object sender, DrawItemEventArgs e) { // Draw the background of the item. e.DrawBackground(); var rectangle = new Rectangle(3, e.Bounds.Top + 2, e.Bounds.Height > 16 ? 16 : e.Bounds.Height, e.Bounds.Height > 16 ? 16 : e.Bounds.Height); //e.Graphics.FillRectangle(new SolidBrush(color), rectangle); //e.Graphics.DrawRectangle(Pens.Black, rectangle); // Draw each string in the array, using a different size, color, // and font for each item. if (e.Index > -1 && Items[e.Index] is PaletteColor) { var pc = (PaletteColor)Items[e.Index]; e.Graphics.DrawImage(RenderColorIcon.RenderBitmap(pc.Color.ToRgb()), rectangle); e.Graphics.DrawString(pc.Name, e.Font, new SolidBrush(e.ForeColor), new RectangleF(e.Bounds.X + rectangle.Width + 4, e.Bounds.Y + 4, e.Bounds.Width, e.Font.Height)); } else if (e.Index > -1 && Items[e.Index] is IColor) { var c = (IColor)Items[e.Index]; e.Graphics.DrawImage(RenderColorIcon.RenderBitmap(c.ToRgb()), rectangle); e.Graphics.DrawString(c.ToString(), e.Font, new SolidBrush(e.ForeColor), new RectangleF(e.Bounds.X + rectangle.Width + 4, e.Bounds.Y + 4, e.Bounds.Width, e.Font.Height)); } // Draw the focus rectangle if the mouse hovers over an item. e.DrawFocusRectangle(); }
public void SyncAppPalState(object sender, EventArgs e) { colorGrid1.Palette = appPal.Palette; paletteList.SuspendLayout(); paletteList.Items.Clear(); paletteListImages.Images.Clear(); var i = 0; foreach (PaletteColor pc in appPal.Palette.Colors) { var lvi = new ListViewItem(pc.Name); paletteListImages.Images.Add(RenderColorIcon.RenderBitmap(pc.Color.ToRgb())); lvi.Tag = pc; lvi.ImageIndex = i++; lvi.SubItems.Add(NativeFormat ? pc.Color.ToString() : pc.Color.ToRgb().ToHtml()); lvi.ToolTipText = pc.Metadata; paletteList.Items.Add(lvi); } paletteList.ResumeLayout(false); UpdateUI(); }
public ColorChangeTextForm(string title, string text, PaletteColor pc) : this() { Text = title; valueBox.Text = text; Icon = RenderColorIcon.RenderIcon(pc.Color.ToRgb()); }