TrackBar ile Renk Kontrolü
Formunuza 3 adet TrackBar,4 adet Label ve 1 adet Panel ekleyin. Aşağıdaki şekli inceleyin.
Şekil 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
KirmiziTrackBar.BeginInit();
YesilTrackBar.BeginInit();
MaviTrackBar.BeginInit();
KirmiziTrackBar.Value = 0;
YesilTrackBar.Value = 0;
MaviTrackBar.Value = 0;
KirmiziTrackBar.TickFrequency = 5;
KirmiziTrackBar.TabIndex = 2;
KirmiziTrackBar.Maximum = 255;
KirmiziTrackBar.Scroll += new System.EventHandler(this.KirmiziTrackBar_Scroll);
YesilTrackBar.TickFrequency = 5;
YesilTrackBar.TabIndex = 2;
YesilTrackBar.Maximum = 255;
YesilTrackBar.Scroll += new System.EventHandler(this.KirmiziTrackBar_Scroll);
MaviTrackBar.TickFrequency = 5;
MaviTrackBar.TabIndex = 2;
MaviTrackBar.Maximum = 255;
MaviTrackBar.Scroll += new System.EventHandler(this.KirmiziTrackBar_Scroll);
KirmiziTrackBar.EndInit();
YesilTrackBar.EndInit();
MaviTrackBar.EndInit();
renk_deger();
}
private void KirmiziTrackBar_Scroll(object sender, EventArgs e)
{
renk_deger();
}
private void YesilTrackBar_Scroll(object sender, EventArgs e)
{
renk_deger();
}
private void MaviTrackBar_Scroll(object sender, EventArgs e)
{
renk_deger();
}
private void renk_deger()
{
Color renk = Color.FromArgb(KirmiziTrackBar.Value, YesilTrackBar.Value, MaviTrackBar.Value);
panel1.BackColor = renk;
label4.Text = "Renk Değer: " + "(" + KirmiziTrackBar.Value + ", " + YesilTrackBar.Value + " ," + MaviTrackBar.Value + ")";
}
}
}
//Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN