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

namespace Project1
{
	/// <summary>
	///
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		public System.Windows.Forms.RadioButton Option2;
		public Microsoft.VisualBasic.Compatibility.VB6.DriveListBox Drive1;
		public Microsoft.VisualBasic.Compatibility.VB6.DirListBox Dir1;
		public System.Windows.Forms.Label Label1;
		public System.Windows.Forms.Button Button1;
		public System.Windows.Forms.Button Button2;
		public System.Windows.Forms.Button Button3;
		/// <summary>
		///
		/// </summary>
		private System.ComponentModel.Container components = null;
		private AxIMAGEKIT7THUMBLib.AxImageKitThumb ImageKitThumb1;
		public System.Windows.Forms.RadioButton Option1;
		public System.Windows.Forms.RadioButton Option3;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.CheckBox checkBox2;
		private System.Windows.Forms.CheckBox checkBox3;
		private System.Windows.Forms.CheckBox checkBox4;
		private System.Windows.Forms.CheckBox checkBox5;

		private string CurrentDir;
		private int gImageNumber;

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

			//
			//
			//
		}

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

		#region Windows Form Designer generated code
		/// <summary>
		///
		///
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.Option2 = new System.Windows.Forms.RadioButton();
			this.Drive1 = new Microsoft.VisualBasic.Compatibility.VB6.DriveListBox();
			this.Dir1 = new Microsoft.VisualBasic.Compatibility.VB6.DirListBox();
			this.Label1 = new System.Windows.Forms.Label();
			this.Button1 = new System.Windows.Forms.Button();
			this.Button2 = new System.Windows.Forms.Button();
			this.Option1 = new System.Windows.Forms.RadioButton();
			this.Button3 = new System.Windows.Forms.Button();
			this.ImageKitThumb1 = new AxIMAGEKIT7THUMBLib.AxImageKitThumb();
			this.Option3 = new System.Windows.Forms.RadioButton();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.checkBox3 = new System.Windows.Forms.CheckBox();
			this.checkBox4 = new System.Windows.Forms.CheckBox();
			this.checkBox5 = new System.Windows.Forms.CheckBox();
			((System.ComponentModel.ISupportInitialize)(this.ImageKitThumb1)).BeginInit();
			this.SuspendLayout();
			// 
			// Option2
			// 
			this.Option2.BackColor = System.Drawing.SystemColors.Control;
			this.Option2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Option2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Option2.Location = new System.Drawing.Point(196, 393);
			this.Option2.Name = "Option2";
			this.Option2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Option2.Size = new System.Drawing.Size(81, 19);
			this.Option2.TabIndex = 16;
			this.Option2.TabStop = true;
			this.Option2.Text = "Custom";
			this.Option2.Click += new System.EventHandler(this.Option2_Click);
			// 
			// Drive1
			// 
			this.Drive1.BackColor = System.Drawing.SystemColors.Window;
			this.Drive1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Drive1.ForeColor = System.Drawing.SystemColors.WindowText;
			this.Drive1.Location = new System.Drawing.Point(336, 333);
			this.Drive1.Name = "Drive1";
			this.Drive1.Size = new System.Drawing.Size(201, 21);
			this.Drive1.TabIndex = 14;
			this.Drive1.SelectedIndexChanged += new System.EventHandler(this.Drive1_SelectedIndexChanged);
			// 
			// Dir1
			// 
			this.Dir1.BackColor = System.Drawing.SystemColors.Window;
			this.Dir1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Dir1.ForeColor = System.Drawing.SystemColors.WindowText;
			this.Dir1.IntegralHeight = false;
			this.Dir1.Location = new System.Drawing.Point(336, 359);
			this.Dir1.Name = "Dir1";
			this.Dir1.Size = new System.Drawing.Size(201, 112);
			this.Dir1.TabIndex = 13;
			// 
			// Label1
			// 
			this.Label1.AutoSize = true;
			this.Label1.BackColor = System.Drawing.SystemColors.Control;
			this.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(128)));
			this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label1.Location = new System.Drawing.Point(32, 316);
			this.Label1.Name = "Label1";
			this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label1.Size = new System.Drawing.Size(111, 21);
			this.Label1.TabIndex = 12;
			this.Label1.Text = "selected filename";
			// 
			// Button1
			// 
			this.Button1.BackColor = System.Drawing.SystemColors.Control;
			this.Button1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Button1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Button1.Location = new System.Drawing.Point(104, 341);
			this.Button1.Name = "Button1";
			this.Button1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Button1.Size = new System.Drawing.Size(81, 36);
			this.Button1.TabIndex = 9;
			this.Button1.Text = "Load Thumbnails";
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			// 
			// Button2
			// 
			this.Button2.BackColor = System.Drawing.SystemColors.Control;
			this.Button2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Button2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Button2.Location = new System.Drawing.Point(192, 341);
			this.Button2.Name = "Button2";
			this.Button2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Button2.Size = new System.Drawing.Size(81, 36);
			this.Button2.TabIndex = 10;
			this.Button2.Text = "End";
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			// 
			// Option1
			// 
			this.Option1.BackColor = System.Drawing.SystemColors.Control;
			this.Option1.Checked = true;
			this.Option1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Option1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Option1.Location = new System.Drawing.Point(24, 393);
			this.Option1.Name = "Option1";
			this.Option1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Option1.Size = new System.Drawing.Size(64, 19);
			this.Option1.TabIndex = 15;
			this.Option1.TabStop = true;
			this.Option1.Text = "Buttons";
			this.Option1.Click += new System.EventHandler(this.Option1_Click);
			// 
			// Button3
			// 
			this.Button3.BackColor = System.Drawing.SystemColors.Control;
			this.Button3.Cursor = System.Windows.Forms.Cursors.Default;
			this.Button3.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Button3.Location = new System.Drawing.Point(16, 341);
			this.Button3.Name = "Button3";
			this.Button3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Button3.Size = new System.Drawing.Size(81, 36);
			this.Button3.TabIndex = 11;
			this.Button3.Text = "Stop Loading";
			this.Button3.Click += new System.EventHandler(this.Button3_Click);
			// 
			// ImageKitThumb1
			// 
			this.ImageKitThumb1.Location = new System.Drawing.Point(16, 9);
			this.ImageKitThumb1.Name = "ImageKitThumb1";
			this.ImageKitThumb1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("ImageKitThumb1.OcxState")));
			this.ImageKitThumb1.Size = new System.Drawing.Size(520, 303);
			this.ImageKitThumb1.TabIndex = 17;
			this.ImageKitThumb1.KeyDownEvent += new AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_KeyDownEventHandler(this.ImageKitThumb1_KeyDownEvent);
			this.ImageKitThumb1.MouseMoveOnThumb += new AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_MouseMoveOnThumbEventHandler(this.ImageKitThumb1_MouseMoveOnThumb);
			this.ImageKitThumb1.SelectFile += new AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_SelectFileEventHandler(this.ImageKitThumb1_SelectFile);
			this.ImageKitThumb1.EndLoadFile += new AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_EndLoadFileEventHandler(this.ImageKitThumb1_EndLoadFile);
			// 
			// Option3
			// 
			this.Option3.BackColor = System.Drawing.SystemColors.Control;
			this.Option3.Cursor = System.Windows.Forms.Cursors.Default;
			this.Option3.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Option3.Location = new System.Drawing.Point(100, 394);
			this.Option3.Name = "Option3";
			this.Option3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Option3.Size = new System.Drawing.Size(81, 19);
			this.Option3.TabIndex = 18;
			this.Option3.TabStop = true;
			this.Option3.Text = "Film";
			this.Option3.Click += new System.EventHandler(this.Option3_Click);
			// 
			// checkBox1
			// 
			this.checkBox1.Checked = true;
			this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox1.Location = new System.Drawing.Point(20, 420);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(104, 22);
			this.checkBox1.TabIndex = 19;
			this.checkBox1.Text = "Drag Source";
			this.checkBox1.Click += new System.EventHandler(this.checkBox1_Click);
			// 
			// checkBox2
			// 
			this.checkBox2.Checked = true;
			this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox2.Location = new System.Drawing.Point(140, 420);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(104, 22);
			this.checkBox2.TabIndex = 20;
			this.checkBox2.Text = "Drag Target";
			this.checkBox2.Click += new System.EventHandler(this.checkBox2_Click);
			// 
			// checkBox3
			// 
			this.checkBox3.Location = new System.Drawing.Point(20, 446);
			this.checkBox3.Name = "checkBox3";
			this.checkBox3.Size = new System.Drawing.Size(104, 22);
			this.checkBox3.TabIndex = 21;
			this.checkBox3.Text = "OLE Drag";
			this.checkBox3.Click += new System.EventHandler(this.checkBox3_Click);
			// 
			// checkBox4
			// 
			this.checkBox4.Checked = true;
			this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
			this.checkBox4.Location = new System.Drawing.Point(140, 446);
			this.checkBox4.Name = "checkBox4";
			this.checkBox4.Size = new System.Drawing.Size(116, 22);
			this.checkBox4.TabIndex = 22;
			this.checkBox4.Text = "Move Thumbnails";
			this.checkBox4.Click += new System.EventHandler(this.checkBox4_Click);
			// 
			// checkBox5
			// 
			this.checkBox5.Location = new System.Drawing.Point(20, 472);
			this.checkBox5.Name = "checkBox5";
			this.checkBox5.Size = new System.Drawing.Size(140, 22);
			this.checkBox5.TabIndex = 23;
			this.checkBox5.Text = "Change Mouse Cursor";
			this.checkBox5.Click += new System.EventHandler(this.checkBox5_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(553, 565);
			this.Controls.Add(this.checkBox5);
			this.Controls.Add(this.checkBox4);
			this.Controls.Add(this.checkBox3);
			this.Controls.Add(this.checkBox2);
			this.Controls.Add(this.checkBox1);
			this.Controls.Add(this.Option3);
			this.Controls.Add(this.ImageKitThumb1);
			this.Controls.Add(this.Option2);
			this.Controls.Add(this.Drive1);
			this.Controls.Add(this.Dir1);
			this.Controls.Add(this.Label1);
			this.Controls.Add(this.Button1);
			this.Controls.Add(this.Button2);
			this.Controls.Add(this.Option1);
			this.Controls.Add(this.Button3);
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Thumbnail Sample";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.Closed += new System.EventHandler(this.Form1_Closed);
			((System.ComponentModel.ISupportInitialize)(this.ImageKitThumb1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private void Form1_Load(object sender, System.EventArgs e)
		{
			CurrentDir = Directory.GetCurrentDirectory() + "\\";

			ImageKitThumb1.ThumbnailFile = "";
			ImageKitThumb1.TextBackColor = Color.FromArgb(0xC0, 0xC0, 0xFF);
			ImageKitThumb1.TextTransparent = false;
    
			ImageKitThumb1.SelectTextColor = Color.FromArgb(0xFF, 0x00, 0x00);
			ImageKitThumb1.SelectTextBackColor = Color.FromArgb(0xFF, 0x80, 0x80);
			ImageKitThumb1.SelectTextTransparent = false;
    
			ImageKitThumb1.ClearOnLoad = false;
			ImageKitThumb1.EnableOLEDrag = false;

			gImageNumber = -1;
		}

		//load thumbnails
		private void Button1_Click(object sender, System.EventArgs e)
		{
			this.Cursor = Cursors.WaitCursor;
			//update thumbnail file
			if (ImageKitThumb1.ThumbnailFile.Trim() != "")
				ImageKitThumb1.UpdateThumbnailFile();
		
			Button1.Enabled = false;
			Button2.Enabled = false;
			Button3.Visible = true;
		
			//set the directory for the images that will be displayed as thumbnails
			ImageKitThumb1.FilePath = Dir1.Path;
		
			//set the thumbnail file
			ImageKitThumb1.ThumbnailFile = Dir1.Path + "\\thumbnail.dat";
		
			ImageKitThumb1.GetFiles();
			this.Cursor = Cursors.Default;
			ImageKitThumb1.Display();
		
			Button1.Enabled = true;
			Button2.Enabled = true;
			Button3.Visible = false;
		}

		//cancel loading
		private void Button3_Click(object sender, System.EventArgs e)
		{
			ImageKitThumb1.Cancel = true;
		}

		private void Drive1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			Dir1.Path = Drive1.Drive;
		}

		//button
		private void Option1_Click(object sender, System.EventArgs e)
		{
			if (Option1.Checked == true)
			{
				ImageKitThumb1.Style = IMAGEKIT7THUMBLib.ThumbnailStyleConstants.ikButton;		
				ImageKitThumb1.Button3D = true;
				ImageKitThumb1.ForeColorUp = Color.FromArgb(0xE0, 0xE0, 0xE0);
				ImageKitThumb1.ForeColorDown = Color.FromArgb(0x80, 0x80, 0x80);
				ImageKitThumb1.BackColor = Color.FromArgb(0xFF, 0xFF, 0xFF);
			}

		}

		//film
		private void Option3_Click(object sender, System.EventArgs e)
		{
			if (Option3.Checked == true)
			{
				ImageKitThumb1.Style = IMAGEKIT7THUMBLib.ThumbnailStyleConstants.ikFilm;
				ImageKitThumb1.ForeColorUp = Color.FromArgb(0x00, 0x00, 0x00);
				ImageKitThumb1.ForeColorDown = Color.FromArgb(0x80, 0x80, 0x80);
				ImageKitThumb1.BackColor = Color.FromArgb(0xFF, 0xFF, 0xFF);
			}
		}

		//custom
		private void Option2_Click(object sender, System.EventArgs e)
		{
			if (Option2.Checked == true)
			{
				ImageKitThumb1.Style = IMAGEKIT7THUMBLib.ThumbnailStyleConstants.ikCustom;
				ImageKitThumb1.ForeColorUp = Color.FromArgb(0xE0, 0xE0, 0xE0);
				ImageKitThumb1.ForeColorDown = Color.FromArgb(0x80, 0x80, 0x80);
				ImageKitThumb1.BackColor = Color.FromArgb(0xFF, 0xFF, 0xFF);
			}
		}

		//drag source
		private void checkBox1_Click(object sender, System.EventArgs e)
		{
			ImageKitThumb1.EnableDragSource = checkBox1.Checked;
		}

		//drag target
		private void checkBox2_Click(object sender, System.EventArgs e)
		{
			ImageKitThumb1.EnableDragTarget = checkBox2.Checked;
		}

		//OLE drag
		private void checkBox3_Click(object sender, System.EventArgs e)
		{
			ImageKitThumb1.EnableOLEDrag = checkBox3.Checked;
		}

		//move thumbnails
		private void checkBox4_Click(object sender, System.EventArgs e)
		{
			ImageKitThumb1.EnableMove = checkBox4.Checked;
		}

		//change mouse cursor
		private void checkBox5_Click(object sender, System.EventArgs e)
		{
			if (checkBox5.Checked)
			{
				ImageKitThumb1.MouseCursorType = IMAGEKIT7THUMBLib.CursorTypeConstants.ikCursorCustom;
				ImageKitThumb1.MouseCursorFile = CurrentDir + "Cursor1.cur";
    
				ImageKitThumb1.SelectMouseCursorType = IMAGEKIT7THUMBLib.CursorTypeConstants.ikCursorCustom;
				ImageKitThumb1.SelectMouseCursorFile = CurrentDir + "SELECT.CUR";
			}
			else
			{
				ImageKitThumb1.MouseCursorType = IMAGEKIT7THUMBLib.CursorTypeConstants.ikCursorDefault;
				ImageKitThumb1.SelectMouseCursorType = IMAGEKIT7THUMBLib.CursorTypeConstants.ikCursorDefault;
			}
		}


		private void ImageKitThumb1_EndLoadFile(object sender, AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_EndLoadFileEvent e)
		{
			Label1.Text = "Loaded file: " + e.imageNumber.ToString() + " / " + e.maxImage.ToString();
			Application.DoEvents();
		}

		private void ImageKitThumb1_KeyDownEvent(object sender, AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_KeyDownEvent e)
		{
			if (e.keyCode == 46 && gImageNumber >= 0)
			{
				ImageKitThumb1.Delete((short)gImageNumber);
			}
		}

		private void ImageKitThumb1_MouseMoveOnThumb(object sender, AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_MouseMoveOnThumbEvent e)
		{
			Label1.Text = "MoveF" + ImageKitThumb1.FileName;
		}

		private void ImageKitThumb1_SelectFile(object sender, AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_SelectFileEvent e)
		{
			if (e.imageNumber == -1)
				return;

			Label1.Text = "SelectF" + ImageKitThumb1.FileName;
			 gImageNumber = e.imageNumber;
		}
	

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

		private void Form1_Closed(object sender, System.EventArgs e)
		{
			//update thumbnail file
			if (ImageKitThumb1.ThumbnailFile.Trim() != "")
				ImageKitThumb1.UpdateThumbnailFile();
		}


	}
}
