using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Brightness
{
	/// <summary>
	///
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private AxIMAGEKIT7Lib.AxImageKit axImageKit1;
		public System.Windows.Forms.CheckBox Check3;
		public System.Windows.Forms.CheckBox Check2;
		public System.Windows.Forms.CheckBox Check1;
		public System.Windows.Forms.GroupBox Frame2;
		public System.Windows.Forms.HScrollBar HScroll1;
		public System.Windows.Forms.GroupBox Frame1;
		public System.Windows.Forms.Button Command2;
		public System.Windows.Forms.Button Command1;
		private System.Windows.Forms.TextBox textBox1;
		/// <summary>
		///
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// 
			//
			InitializeComponent();

			//
			// 
			//
		}

		/// <summary>
		/// 
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region ""
		/// <summary>
		/// 
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.axImageKit1 = new AxIMAGEKIT7Lib.AxImageKit();
			this.Check3 = new System.Windows.Forms.CheckBox();
			this.Check2 = new System.Windows.Forms.CheckBox();
			this.Check1 = new System.Windows.Forms.CheckBox();
			this.Frame2 = new System.Windows.Forms.GroupBox();
			this.HScroll1 = new System.Windows.Forms.HScrollBar();
			this.Frame1 = new System.Windows.Forms.GroupBox();
			this.Command2 = new System.Windows.Forms.Button();
			this.Command1 = new System.Windows.Forms.Button();
			this.textBox1 = new System.Windows.Forms.TextBox();
			((System.ComponentModel.ISupportInitialize)(this.axImageKit1)).BeginInit();
			this.SuspendLayout();
			// 
			// axImageKit1
			// 
			this.axImageKit1.Location = new System.Drawing.Point(12, 72);
			this.axImageKit1.Name = "axImageKit1";
			this.axImageKit1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axImageKit1.OcxState")));
			this.axImageKit1.Size = new System.Drawing.Size(436, 320);
			this.axImageKit1.TabIndex = 0;
			// 
			// Check3
			// 
			this.Check3.BackColor = System.Drawing.SystemColors.Control;
			this.Check3.Checked = true;
			this.Check3.CheckState = System.Windows.Forms.CheckState.Checked;
			this.Check3.Cursor = System.Windows.Forms.Cursors.Default;
			this.Check3.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Check3.Location = new System.Drawing.Point(24, 452);
			this.Check3.Name = "Check3";
			this.Check3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Check3.Size = new System.Drawing.Size(57, 16);
			this.Check3.TabIndex = 13;
			this.Check3.Text = "Blue";
			this.Check3.Click += new System.EventHandler(this.Check3_Click);
			// 
			// Check2
			// 
			this.Check2.BackColor = System.Drawing.SystemColors.Control;
			this.Check2.Checked = true;
			this.Check2.CheckState = System.Windows.Forms.CheckState.Checked;
			this.Check2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Check2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Check2.Location = new System.Drawing.Point(24, 436);
			this.Check2.Name = "Check2";
			this.Check2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Check2.Size = new System.Drawing.Size(57, 16);
			this.Check2.TabIndex = 12;
			this.Check2.Text = "Green";
			this.Check2.Click += new System.EventHandler(this.Check2_Click);
			// 
			// Check1
			// 
			this.Check1.BackColor = System.Drawing.SystemColors.Control;
			this.Check1.Checked = true;
			this.Check1.CheckState = System.Windows.Forms.CheckState.Checked;
			this.Check1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Check1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Check1.Location = new System.Drawing.Point(24, 420);
			this.Check1.Name = "Check1";
			this.Check1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Check1.Size = new System.Drawing.Size(57, 16);
			this.Check1.TabIndex = 11;
			this.Check1.Text = "Red";
			this.Check1.Click += new System.EventHandler(this.Check1_Click);
			// 
			// Frame2
			// 
			this.Frame2.BackColor = System.Drawing.SystemColors.Control;
			this.Frame2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame2.Location = new System.Drawing.Point(16, 404);
			this.Frame2.Name = "Frame2";
			this.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame2.Size = new System.Drawing.Size(89, 72);
			this.Frame2.TabIndex = 10;
			this.Frame2.TabStop = false;
			this.Frame2.Text = "Color Plane";
			// 
			// HScroll1
			// 
			this.HScroll1.Cursor = System.Windows.Forms.Cursors.Default;
			this.HScroll1.Location = new System.Drawing.Point(136, 432);
			this.HScroll1.Maximum = 255;
			this.HScroll1.Minimum = -255;
			this.HScroll1.Name = "HScroll1";
			this.HScroll1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.HScroll1.Size = new System.Drawing.Size(257, 19);
			this.HScroll1.SmallChange = 2;
			this.HScroll1.TabIndex = 9;
			this.HScroll1.TabStop = true;
			this.HScroll1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.HScroll1_Scroll);
			// 
			// Frame1
			// 
			this.Frame1.BackColor = System.Drawing.SystemColors.Control;
			this.Frame1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame1.Location = new System.Drawing.Point(120, 408);
			this.Frame1.Name = "Frame1";
			this.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame1.Size = new System.Drawing.Size(289, 62);
			this.Frame1.TabIndex = 8;
			this.Frame1.TabStop = false;
			this.Frame1.Text = "Brightness";
			// 
			// Command2
			// 
			this.Command2.BackColor = System.Drawing.SystemColors.Control;
			this.Command2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Command2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Command2.Location = new System.Drawing.Point(452, 412);
			this.Command2.Name = "Command2";
			this.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Command2.Size = new System.Drawing.Size(81, 36);
			this.Command2.TabIndex = 15;
			this.Command2.Text = "End";
			this.Command2.Click += new System.EventHandler(this.Command2_Click);
			// 
			// Command1
			// 
			this.Command1.BackColor = System.Drawing.SystemColors.Control;
			this.Command1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Command1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Command1.Location = new System.Drawing.Point(460, 76);
			this.Command1.Name = "Command1";
			this.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Command1.Size = new System.Drawing.Size(81, 35);
			this.Command1.TabIndex = 14;
			this.Command1.Text = "Load Image";
			this.Command1.Click += new System.EventHandler(this.Command1_Click);
			// 
			// textBox1
			// 
			this.textBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(0)), ((System.Byte)(0)));
			this.textBox1.Location = new System.Drawing.Point(4, 4);
			this.textBox1.Multiline = true;
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(532, 60);
			this.textBox1.TabIndex = 16;
			this.textBox1.Text = @"In this sample, changes in brightness are acheived by adjusting RGB values using the RGBLevel method. The individual color planes can be selected or deselected so that only those color plane values are adjusted. The ImageKit also supports Y, Cr, Cb color planes. An alternative way of altering brightness would be to use the YCCLevel method and alter only the Y (luminance) value";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(548, 490);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.Command2);
			this.Controls.Add(this.Command1);
			this.Controls.Add(this.Check3);
			this.Controls.Add(this.Check2);
			this.Controls.Add(this.Check1);
			this.Controls.Add(this.Frame2);
			this.Controls.Add(this.HScroll1);
			this.Controls.Add(this.Frame1);
			this.Controls.Add(this.axImageKit1);
			this.Name = "Form1";
			this.Text = "Form1";
			((System.ComponentModel.ISupportInitialize)(this.axImageKit1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private int ImgHandle = 0;

		private void Command1_Click(object sender, System.EventArgs e)
		{
	        // Displays the Open File dialog to select an image...
		    if (!axImageKit1.File.OpenFileDialog())
			    return;

	        // Loads the image...
		    axImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad);

	        //display the image is scale display mode...
		    axImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikScale);
	
		    ImgHandle = axImageKit1.CopyImage(0);
		}

		private void Check1_Click(object sender, System.EventArgs e)
		{
		}

		private void Check2_Click(object sender, System.EventArgs e)
		{
		}

		private void Check3_Click(object sender, System.EventArgs e)
		{
		}

		private void HScroll1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
		{
	        bool ret;
			int []x = new int[1];
			int []y = new int[1];
			int redCheck;
			int greenCheck;
			int blueCheck;

			if (Check1.Checked)
				redCheck = 1;
			else
				redCheck = 0;

			if (Check2.Checked)
				greenCheck = 1;
			else
				greenCheck = 0;

			if (Check3.Checked)
				blueCheck = 1;
			else
				blueCheck = 0;

			//Process the original image
			axImageKit1.ImageHandle = axImageKit1.CopyImage(ImgHandle);

	        //process the total image...
		    axImageKit1.Effect.SelectMode = IMAGEKIT7Lib.AreaSelectModeConstants.ikEffectAll;

	        //execute the RGBLevel method on each color plane that was checked...
		    ret = axImageKit1.Effect.RGBLevel(ref x[0], ref y[0], 0, redCheck * e.NewValue, greenCheck * e.NewValue, blueCheck * e.NewValue);

	        //display the image is scale display mode...
		    if (ret)
			    axImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikScale);
		}

		private void Command2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}
