using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Color_Slide
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.HScrollBar hScrollBar1;
private System.Windows.Forms.HScrollBar hScrollBar2;
private System.Windows.Forms.HScrollBar hScrollBar3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
int R = 0;
int G = 0;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
int B = 0;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
label2.Text = "R= " + R + "G= " + G + "B=" + B;
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
this.hScrollBar2 = new System.Windows.Forms.HScrollBar();
this.hScrollBar3 = new System.Windows.Forms.HScrollBar();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// hScrollBar1
//
this.hScrollBar1.Location = new System.Drawing.Point(16, 104);
this.hScrollBar1.Maximum = 264;
this.hScrollBar1.Name = "hScrollBar1";
this.hScrollBar1.Size = new System.Drawing.Size(256, 16);
this.hScrollBar1.TabIndex = 0;
this.hScrollBar1.ValueChanged += new System.EventHandler(this.hScrollBar1_ValueChanged);
//
// hScrollBar2
//
this.hScrollBar2.Location = new System.Drawing.Point(16, 136);
this.hScrollBar2.Maximum = 264;
this.hScrollBar2.Name = "hScrollBar2";
this.hScrollBar2.Size = new System.Drawing.Size(256, 16);
this.hScrollBar2.TabIndex = 1;
this.hScrollBar2.ValueChanged += new System.EventHandler(this.hScrollBar1_ValueChanged);
//
// hScrollBar3
//
this.hScrollBar3.Location = new System.Drawing.Point(16, 168);
this.hScrollBar3.Maximum = 264;
this.hScrollBar3.Name = "hScrollBar3";
this.hScrollBar3.Size = new System.Drawing.Size(256, 16);
this.hScrollBar3.TabIndex = 2;
this.hScrollBar3.ValueChanged += new System.EventHandler(this.hScrollBar1_ValueChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(248, 64);
this.label1.TabIndex = 3;
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 208);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(248, 32);
this.label2.TabIndex = 4;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 256);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(48, 20);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 256);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(48, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(216, 256);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(48, 20);
this.textBox3.TabIndex = 7;
this.textBox3.Text = "textBox3";
//
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(0)), ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(104, 288);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 8;
this.button1.Text = "enter";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(128)), ((System.Byte)(0)));
this.ClientSize = new System.Drawing.Size(292, 334);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.hScrollBar3);
this.Controls.Add(this.hScrollBar2);
this.Controls.Add(this.hScrollBar1);
this.Name = "Form1";
this.Text = "Color Slider";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void hScrollBar1_ValueChanged(object sender, System.EventArgs e)
{
R = hScrollBar1.Value;
G = hScrollBar2.Value;
B = hScrollBar3.Value;
Color c = Color.FromArgb(R, G, B);
label2.Text = "R= " + R + " G= " + G + " B=" + B;
label2.Text += "\nHexadecimal: " + c.Name.Substring(0, 6);
label1.BackColor = c;
}
private void button1_Click(object sender, System.EventArgs e)
{
R = Convert.ToInt32(textBox1.Text);
G = Convert.ToInt32(textBox2.Text);
B = Convert.ToInt32(textBox3.Text);
if (R < 256)
hScrollBar1.Value = R;
if (G < 256)
hScrollBar2.Value = G;
if (B < 256)
hScrollBar3.Value = B;
hScrollBar1_ValueChanged(null, null);
}
}
}