Archive Browser
Download PhotoshopColorSwatchWriter.zip version 1.0.0.0, last updated 28/01/2014 (16.86 KB)
Download- md5: c5498aad2487ba4d5b87707f27e9eb30
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace PhotoshopColorSwatchWriter
{
internal class PalettePanel : BufferedPanel
{
#region Constants
private const int DefaultX = 6;
private const int DefaultY = 6;
private const int Spacing = 6;
private const int CellSize = 16;
#endregion
#region Instance Fields
private List<Color> _colors;
#endregion
#region Overridden Methods
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data. </param>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this.Colors != null)
{
int x;
int y;
x = DefaultX;
y = DefaultY;
e.Graphics.Clear(this.BackColor);
foreach (Color color in this.Colors)
{
Rectangle bounds;
if (x > this.ClientSize.Width - (CellSize + DefaultX))
{
x = DefaultX;
y += DefaultY + CellSize + Spacing;
}
bounds = new Rectangle(x, y, CellSize, CellSize);
using (Brush brush = new SolidBrush(color))
e.Graphics.FillRectangle(brush, bounds);
e.Graphics.DrawRectangle(Pens.Black, bounds);
x += (CellSize + Spacing);
}
}
}
#endregion
#region Public Properties
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public List<Color> Colors
{
get { return _colors; }
set
{
_colors = value;
this.Invalidate();
}
}
#endregion
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate