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

namespace Project1
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.TextBox textBox1;
		private AxIMAGEKIT7Lib.AxImageKit ImageKit1;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ComboBox comboBox2;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.CheckBox checkBox2;
		private System.Windows.Forms.CheckBox checkBox3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.ImageKit1 = new AxIMAGEKIT7Lib.AxImageKit();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.checkBox3 = new System.Windows.Forms.CheckBox();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.comboBox2 = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			((System.ComponentModel.ISupportInitialize)(this.ImageKit1)).BeginInit();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(480, 80);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(136, 32);
			this.button1.TabIndex = 0;
			this.button1.Text = "Load Image";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(472, 392);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(144, 32);
			this.button2.TabIndex = 1;
			this.button2.Text = "End";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// ImageKit1
			// 
			this.ImageKit1.Location = new System.Drawing.Point(8, 72);
			this.ImageKit1.Name = "ImageKit1";
			this.ImageKit1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("ImageKit1.OcxState")));
			this.ImageKit1.Size = new System.Drawing.Size(456, 384);
			this.ImageKit1.TabIndex = 2;
			this.ImageKit1.MouseMoveImage += new AxIMAGEKIT7Lib._IImageKitEvents_MouseMoveImageEventHandler(this.ImageKit1_MouseMoveImage);
			// 
			// 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(8, 0);
			this.textBox1.Multiline = true;
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(608, 64);
			this.textBox1.TabIndex = 3;
			this.textBox1.Text = @"The Magnifier can be used to magnify a portion of an image. Placing magnifier code in the MouseMoveImage event allows the magnifier to move with the mouse. Set magnifier size, display or hide borders, change its shape, show or hide the mouse cursor, etc. If you are displaying multiple images at the same time, you can enable the magnifier for specific image layers and disable it for others.";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.checkBox3);
			this.groupBox1.Controls.Add(this.checkBox2);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.textBox3);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.textBox2);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.comboBox2);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.comboBox1);
			this.groupBox1.Controls.Add(this.checkBox1);
			this.groupBox1.Location = new System.Drawing.Point(472, 128);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(152, 216);
			this.groupBox1.TabIndex = 4;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Magnifier Properties";
			// 
			// checkBox3
			// 
			this.checkBox3.Checked = true;
			this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox3.Location = new System.Drawing.Point(24, 184);
			this.checkBox3.Name = "checkBox3";
			this.checkBox3.Size = new System.Drawing.Size(104, 16);
			this.checkBox3.TabIndex = 10;
			this.checkBox3.Text = "Show Border";
			// 
			// checkBox2
			// 
			this.checkBox2.Checked = true;
			this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox2.Location = new System.Drawing.Point(24, 160);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(96, 16);
			this.checkBox2.TabIndex = 9;
			this.checkBox2.Text = "Show Cursor";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 128);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(40, 16);
			this.label4.TabIndex = 8;
			this.label4.Text = "Width";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(64, 128);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(24, 20);
			this.textBox3.TabIndex = 7;
			this.textBox3.Text = "100";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 104);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(40, 16);
			this.label3.TabIndex = 6;
			this.label3.Text = "Height";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(64, 104);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(24, 20);
			this.textBox2.TabIndex = 5;
			this.textBox2.Text = "100";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 72);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(40, 16);
			this.label2.TabIndex = 4;
			this.label2.Text = "Shape";
			// 
			// comboBox2
			// 
			this.comboBox2.Items.AddRange(new object[] {
														   "Rectangle",
														   "RoundRect",
														   "Ellipse"});
			this.comboBox2.Location = new System.Drawing.Point(64, 72);
			this.comboBox2.Name = "comboBox2";
			this.comboBox2.Size = new System.Drawing.Size(80, 21);
			this.comboBox2.TabIndex = 3;
			this.comboBox2.Text = "Rectangle";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "Magnification";
			// 
			// comboBox1
			// 
			this.comboBox1.Items.AddRange(new object[] {
														   "0.5",
														   "1.0",
														   "1.5",
														   "2.0",
														   "2.5",
														   "3.0",
														   "3.5",
														   "4.0"});
			this.comboBox1.Location = new System.Drawing.Point(88, 48);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(48, 21);
			this.comboBox1.TabIndex = 1;
			this.comboBox1.Text = "2.0";
			// 
			// checkBox1
			// 
			this.checkBox1.Checked = true;
			this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox1.Location = new System.Drawing.Point(16, 24);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(120, 16);
			this.checkBox1.TabIndex = 0;
			this.checkBox1.Text = "Display Magnifier";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(624, 478);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.ImageKit1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Magnifier";
			((System.ComponentModel.ISupportInitialize)(this.ImageKit1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

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

		private void button1_Click(object sender, System.EventArgs e)
		{
			if (ImageKit1.File.OpenFileDialog() == false) 
				return;			
			
			//load the image file...
			ImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad);
			
			//enable scroll bars and display image in actual size
			ImageKit1.ScrollBar = true;
			ImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikActualSize);

		}

		private void ImageKit1_MouseMoveImage(object sender, AxIMAGEKIT7Lib._IImageKitEvents_MouseMoveImageEvent e)
		{
			bool ret;
			
			ImageKit1.Magnifier.Height = Convert.ToInt16(textBox2.Text);
			ImageKit1.Magnifier.Width = Convert.ToInt16(textBox3.Text);
			ImageKit1.Magnifier.ShowCursor = Convert.ToBoolean(checkBox2.CheckState);
			ImageKit1.Magnifier.Edge = Convert.ToBoolean(checkBox3.CheckState);
			if(comboBox2.SelectedIndex==0)
			{
				ImageKit1.Magnifier.Type = IMAGEKIT7Lib.MagnifierTypeConstants.ikRectangleMagnifier;
			}
			else if(comboBox2.SelectedIndex==1)
			{
				ImageKit1.Magnifier.Type = IMAGEKIT7Lib.MagnifierTypeConstants.ikRoundRectMagnifier;
			}
			else if(comboBox2.SelectedIndex==2)
			{
				ImageKit1.Magnifier.Type = IMAGEKIT7Lib.MagnifierTypeConstants.ikEllipseMagnifier;
			}


			ret = ImageKit1.Magnifier.Show(Convert.ToBoolean(checkBox1.CheckState), e.x, e.y, Convert.ToDouble(comboBox1.Text));
		}


	}
}
