Archive Browser
Download RiffPaletteWriter.zip version 1.0.0.0, last updated 04/03/2017 (14.94 KB)
Download- md5: 2864394d3c1cc948887ced13c5d5bedf
- sha1: dc44b4f4d8d6318030d6460a5f88f43aa345ce2f
- sha256: 8781446c207bc5faf4021226bdbd3789c6acdd21efbaeaa101dbcca0a2749abf
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using PhotoshopColorSwatchWriter;
// Writing Microsoft RIFF Palette (pal) files with C#
// http://cyotek.com/blog/writing-microsoft-riff-palette-pal-files-with-csharp
namespace Cyotek.Demonstrations.RiffPaletteWriter
{
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 RiffPalette _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 RiffPalette 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