Archive Browser
Download Cyotek.Windows.Forms.ColorPicker-1.0.2.0.zip version 1.0.2.0, last updated 13/07/2013 (382.27 KB)
Download- md5: 34597ba8a4143a1794524236d9f43524
using System;
using System.Drawing;
using System.IO;
using System.Linq;
namespace Cyotek.Windows.Forms.ColorPicker.Demo
{
// Cyotek Color Picker controls library
// Copyright © 2013 Cyotek. All Rights Reserved.
// http://cyotek.com/blog/tag/colorpicker
// If you use this code in your applications, donations or attribution are welcome
internal partial class ColorGridDemoForm : BaseForm
{
#region Constructors
public ColorGridDemoForm()
{
InitializeComponent();
}
#endregion
#region Overridden Members
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
colorGrid.Color = Color.SeaGreen;
}
#endregion
#region Event Handlers
private void addCustomColorsButton_Click(object sender, EventArgs e)
{
colorGrid.CustomColors = ColorPalettes.QbColors;
}
private void addNewColorButton_Click(object sender, EventArgs e)
{
int r;
int g;
int b;
int a;
Random random;
random = new Random();
r = random.Next(0, 254);
g = random.Next(0, 254);
b = random.Next(0, 254);
a = random.Next(0, 254);
colorGrid.Color = Color.FromArgb(a, r, g, b);
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void colorGrid_ColorChanged(object sender, EventArgs e)
{
optionsSplitContainer.Panel2.BackColor = colorGrid.Color;
colorToolStripStatusLabel.Text = string.Format("{0}, {1}, {2}", colorGrid.Color.R, colorGrid.Color.G, colorGrid.Color.B);
}
private void grayScaleButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new ColorCollection(Enumerable.Range(0, 254).Select(i => Color.FromArgb(i, i, i)));
}
private void hexagonPaletteButton_Click(object sender, EventArgs e)
{
// NOTE: Predefined palettes can now be set via the Palette property
colorGrid.Colors = ColorPalettes.HexagonPalette;
}
private void jascPaletteFileButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new JascPaletteSerializer().Deserialize(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"palettes\Hex256.pal"));
}
private void loadGimpPaletteButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new GimpPaletteSerializer().Deserialize(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"palettes\db32.gpl"));
}
private void office2010Button_Click(object sender, EventArgs e)
{
// NOTE: Predefined palettes can now be set via the Palette property (this does not affect other properties such as Columns below though!)
colorGrid.Colors = ColorPalettes.Office2010Standard;
colorGrid.Columns = 10;
}
private void paintNetPaletteButton_Click(object sender, EventArgs e)
{
// NOTE: Predefined palettes can now be set via the Palette property
colorGrid.Colors = ColorPalettes.PaintPalette;
}
private void paintNetPaletteFileButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new PaintNetPaletteSerializer().Deserialize(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"palettes\PaintNet.txt"));
}
private void resetCustomColorsButton_Click(object sender, EventArgs e)
{
colorGrid.CustomColors = new ColorCollection(Enumerable.Repeat(Color.White, 32));
}
private void shadesOfBlueButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new ColorCollection(Enumerable.Range(0, 254).Select(i => Color.FromArgb(0, 0, i)));
}
private void shadesOfGreenButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new ColorCollection(Enumerable.Range(0, 254).Select(i => Color.FromArgb(0, i, 0)));
}
private void shadesOfRedButton_Click(object sender, EventArgs e)
{
colorGrid.Colors = new ColorCollection(Enumerable.Range(0, 254).Select(i => Color.FromArgb(i, 0, 0)));
}
private void standardColorsButton_Click(object sender, EventArgs e)
{
// NOTE: Predefined palettes can now be set via the Palette property
colorGrid.Colors = ColorPalettes.NamedColors;
}
#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