Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ColorPicker
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private bool IsMouseDown = false;
private int OldX;
private int OldY;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
string[] colors = new string[]{"AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue",
"BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk",
"Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenrod","DarkGray","DarkGreen","DarkKhaki","DarkMagenta",
"DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray",
"DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DodgerBlue","Firebrick","FloralWhite",
"ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","Goldenrod","Gray","Green","GreenYellow","Honeydew",
"HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon",
"LightBlue","LightCoral","LightCyan","LightGoldenrodYellow","LightGray","LightGreen","LightPink","LightSalmon",
"LightSeaGreen","LightSkyBlue","LightSlateGray","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen",
"Magenta","Maroon","MediumAquamarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen",
"MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose",
"Moccasin","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenrod","PaleGreen",
"PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple",
"Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver",
"SkyBlue","SlateBlue","SlateGray","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato",
"Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen","Transparent"};
Label[] labels = new Label[colors.Length];
int row = 0;
int column = 0;
int ColorLuminance;
for (int i=0; i<labels.Length; i++)
{
labels[i] = new Label();
labels[i].BorderStyle = label1.BorderStyle;
labels[i].TextAlign = label1.TextAlign;
labels[i].Font = label1.Font;
labels[i].Size = label1.Size;
labels[i].Top = row * label1.Height;
labels[i].Left = column * label1.Width;
labels[i].BackColor = Color.FromName(colors[i]);
ColorLuminance = labels[i].BackColor.R * 2 + labels[i].BackColor.G * 5 + labels[i].BackColor.B;
if (ColorLuminance < 1024)
labels[i].ForeColor = Color.White;
else
labels[i].ForeColor = Color.Black;
labels[i].MouseDown += new MouseEventHandler(eMouseDown);
labels[i].MouseUp += new MouseEventHandler(eMouseUp);
labels[i].MouseMove += new MouseEventHandler(eMouseMove);
if (colors[i].IndexOf("Gray") > -1)
labels[i].ForeColor = Color.Black;
labels[i].Text = colors[i] + " R" + labels[i].BackColor.R.ToString() + " G" + labels[i].BackColor.G.ToString()+
" B" + labels[i].BackColor.B.ToString() + " OLE " + ColorTranslator.ToOle(labels[i].BackColor).ToString();
if (column == 7)
{
row++;
column = 0;
}
else
column++;
}
Controls.AddRange(labels);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Location = new System.Drawing.Point(88, 56);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(112, 40);
this.panel1.TabIndex = 0;
this.panel1.Visible = false;
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(177)));
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 35);
this.label1.TabIndex = 1;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.Visible = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(930, 142);
this.Controls.Add(this.label1);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "Form1";
this.Text = "Colors";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void eMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
IsMouseDown = true;
Cursor = Cursors.Hand;
OldX = MousePosition.X;
OldY = MousePosition.Y;
}
private void eMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
IsMouseDown = false;
Cursor = Cursors.Default;
}
private void eMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (IsMouseDown)
{
Label tmpLbl = (Label)sender;
tmpLbl.BringToFront();
tmpLbl.Location = new Point(tmpLbl.Location.X + MousePosition.X - OldX, tmpLbl.Location.Y + MousePosition.Y - OldY);
OldX = MousePosition.X;
OldY = MousePosition.Y;
}
}
}
}
I did notice that link that RG posted in the 'blur line' thread. Made me think about adding some neat effects to this thing