Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#

Thumbnail Generator - An easy way to process thumbnails from a large amount of images

Rate me:
Please Sign up or sign in to vote.
4.85/5 (15 votes)
9 Mar 20031 min read 321.8K   5.3K   88  
Thumbnail Generator application supporting a bunch of image file types (for both: source images and target thumbnails), fixed target image size as well as ratio calculation, and full internationalization.
/*
 * Program			: Thumbnail Generator
 * Author			: Christian Ballerstaller
 * eMail			: Chris.Balla@web.de
 * Last modified	: 9 March 2003
 * License			: Released under GPL General Public License
 * 
 * .NET Framework	: Version 1.0
 * 
 * Description		: - User can select multiple files to generate thumbnails from
 *					  - Selected files infos and a small image are displayed in a source listbox
 *					  - User can generate thumbnails (with various file formats) from those source images
 *					  - Generated thumbnails and infos are displayed in a target listbox
 */

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.Windows.Forms;
using System.IO;

using System.Xml;
using System.Xml.XPath;

using Controls.Development;

namespace ThumbGenerator
{
	public class ThumbGenerator : System.Windows.Forms.Form
	{
		// Designer variables
		private System.Windows.Forms.MenuItem miChooseDir;
		private System.Windows.Forms.MenuItem miExit;
		private System.Windows.Forms.MenuItem miGenThumbs;
		private System.Windows.Forms.Button btnGenerateThumb;
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Panel pnlAction;
		private System.Windows.Forms.GroupBox gbxSource;
		private System.Windows.Forms.GroupBox gbxTarget;
		private System.Windows.Forms.Panel pnlContent;
		private System.Windows.Forms.MenuItem miFile;
		private System.Windows.Forms.MenuItem miHelp;
		private System.Windows.Forms.MenuItem miInfo;

		private System.Windows.Forms.Panel pnlImages;
		private System.Windows.Forms.MenuItem miFileClear;
		private System.Windows.Forms.GroupBox gbxSettings;
		private System.Windows.Forms.Label lblFormat;
		private System.Windows.Forms.Label lblExtension;
		private System.Windows.Forms.TextBox tbxExtension;
		private System.Windows.Forms.ComboBox cbxFormat;
		private System.Windows.Forms.TextBox tbxHeight;
		private System.Windows.Forms.TextBox tbxWidth;
		private System.Windows.Forms.CheckBox cbxRatio;
		private System.Windows.Forms.Panel pnlRatio;
		private System.Windows.Forms.RadioButton rdbHeight;
		private System.Windows.Forms.RadioButton rdbWidth;
		private System.Windows.Forms.Panel pnlSizeRatio;
		private System.Windows.Forms.ProgressBar prgBar;
		private System.Windows.Forms.Label lblHeight;
		private System.Windows.Forms.Label lblWidth;
		private System.Windows.Forms.Label lblPixel;
		private System.Windows.Forms.MenuItem miPreferences;
		private System.Windows.Forms.MainMenu mainMenu;
		private System.Windows.Forms.OpenFileDialog openFileDialog;
		private System.Windows.Forms.MenuItem miBlank1;
		private System.Windows.Forms.MenuItem miBlank2;
		private System.Windows.Forms.MenuItem miBlank3;

		private Controls.Development.ImageListBox lbxSource;
		private Controls.Development.ImageListBox lbxTarget;

		// Application variables
		private string configFileName = "Config.xml";

		private ImageFormat currentImageFormat=null;

		private string		txtStdHeight	= "100";	// Standard height
		private string		txtStdWidth		= "100";	// Standard width

		private string		errImage;
		private string		errFile;
		private string		errChoose;

		private string		txtWidth;
		private string		txtHeight;
		private string		txtRatio;
		private string		txtRatioShort;

		private string		strLang			="en";		// Standard language
		private string		txtVersion;
		
		string[] filesFromDialog=null;

		[STAThread]
		static void Main() 
		{
			Application.Run(new ThumbGenerator());
		}

		public ThumbGenerator()
		{
			InitializeComponent();

			// Get standard language (can be changed in preferences dialog)
			CurrentLang = XmlManager.GetAttributeFromTagName(configFileName, "StdLanguage", "Type");

			// Init standard Thumbnail settings
			currentImageFormat		= ImageFormat.Jpeg;

			tbxExtension.Text		= ".Thumb";		// Extension of generated thumbnails
			cbxFormat.SelectedItem	= "*.Jpeg";		// Image format of generated thumbnails
			tbxWidth.Text			= txtStdWidth;	// Width of thumbnail
			tbxHeight.Text			= txtStdHeight;	// Height of thumbnail

			// Init standard GUI settings
			cbxRatio.Checked		= true;
			rdbWidth.Checked		= true;
			prgBar.Visible			= false;
		}

		/// <summary>
		/// Initializes Language for current form
		/// </summary>
		private void InitializeLang()
		{
			XPathDocument XPathDoc		= new XPathDocument(configFileName);
			XPathNavigator nav			= XPathDoc.CreateNavigator();

			this.Text					= XmlManager.GetValueFromXPath(nav, "/Application/Information/Name")+" "+XmlManager.GetValueFromXPath(nav, "/Application/Information/Version");
			miFile.Text					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miFile']");
			miChooseDir.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miChooseDir']");
			miGenThumbs.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miGenThumbs']");
			miFileClear.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miFileClear']");
			miPreferences.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miPreferences']");
			miExit.Text					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miExit']");

			miHelp.Text					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miHelp']");
			miInfo.Text					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='miInfo']");

			btnGenerateThumb.Text		= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='btnGenerateThumb']");
			gbxSource.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='gbxSource']");
			gbxTarget.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='gbxTarget']");
			gbxSettings.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='gbxSettings']");
			lblExtension.Text			= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='lblExtension']");
			lblFormat.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='lblFormat']");
			cbxRatio.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='cbxRatio']");
			rdbWidth.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='rdbWidth']");
			rdbHeight.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='rdbHeight']");
			lblWidth.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='lblWidth']");
			lblHeight.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='lblHeight']");
			lblPixel.Text				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='lblPixel']");

			txtWidth					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='txtWidth']");
			txtHeight					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='txtHeight']");
			txtRatio					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='txtRatio']");
			txtRatioShort				= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='txtRatioShort']");

			errImage					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='errImage']");
			errFile						= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='errFile']");
			errChoose					= XmlManager.GetValueFromXPath(nav, "/Application/Language[@Type='"+CurrentLang+"']/Text[@GUIRelation='errChoose']");
			
			txtVersion					= XmlManager.GetValueFromXPath(nav, "/Application/Information/Version");
		}

		/// <summary>
		/// Gets or Sets Current Language
		/// </summary>
		public string CurrentLang
		{
			get
			{
				return strLang;
			}
			set
			{
				strLang = value;
				InitializeLang();
			}
		}

		/// <summary>
		/// Source files are chosen in this dialog. After accepting the files they are added to the source listbox.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void miChooseDir_Click(object sender, System.EventArgs e)
		{
			openFileDialog.InitialDirectory=System.Environment.CurrentDirectory;

			// Supported filetypes
			openFileDialog.Filter =  "JPG Files (*.jpg)|*.jpg|"+
									  "JPEG Files (*.jpeg)|*.jpeg|"+
									  "PNG Files (*.png)|*.png|"+
									  "GIF Files (*.gif)|*.gif|"+
									  "BMP Files (*.bmp)|*.bmp|"+
									  "All Files (*.*)|*.*";

			// Add selected images to source listbox
			if(openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				filesFromDialog = openFileDialog.FileNames; // retrieve filelist
				ClearEverything();							// clears source and target listbox

				ImageList imgList = new ImageList();
				imgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
				imgList.ImageSize = new System.Drawing.Size(24, 24);
				imgList.TransparentColor = System.Drawing.Color.Magenta;
				lbxSource.ImageList=imgList;

				// Add selected images plus image information to source listbox
				for(int i=0; i<filesFromDialog.Length; i++)
				{
					try
					{
						// Retrieve image to get it's infos
						Image LbxSourceImage = Image.FromFile(filesFromDialog[i]);
						imgList.Images.Add(LbxSourceImage);

						// Calculates image ratio
						float Ratio=((float)LbxSourceImage.Width)/((float)LbxSourceImage.Height); 

						// Generates Listboxitem
						ImageListBoxItem lbxItem = new ImageListBoxItem(
							filesFromDialog[i].ToString()+						// Filename
							"\r\n"+txtWidth+LbxSourceImage.Width.ToString()+	// Width
							", "+txtHeight+LbxSourceImage.Height.ToString()+	// Height
							", "+txtRatio+Ratio.ToString(),i);					// Ratio

						lbxSource.Items.Add(lbxItem);
					}
					catch(Exception)
					{
						// Thumbnail couldn't be generated
						MessageBox.Show(errImage+filesFromDialog[i], this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}

				imgList.Dispose();

				// Select all images in source listbox
				for(int i=0; i<lbxSource.Items.Count; i++)
				{
					lbxSource.SetSelected(i, true);
				}
			}
		}

		/// <summary>
		/// Generates thumbnails from images in source Listbox. Only selected images will be processed.
		/// </summary>
		private void GenerateThumb()
		{
			// If there are source images and if an image to process is selected
			if(lbxSource.Items.Count>0 && lbxSource.SelectedItems.Count>0)
			{
				// How many steps will progress bar have?
				int PrgBarStepWidth = 100/lbxSource.SelectedItems.Count;
				prgBar.Value=0;
				prgBar.Visible=true;

				// Imagelist settings
				ImageList imgListTarget = new ImageList();
				imgListTarget.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
				imgListTarget.ImageSize = new System.Drawing.Size(24, 24);
				imgListTarget.TransparentColor = System.Drawing.Color.Magenta;

				// Prepares target listbox
				lbxTarget.Items.Clear();
				lbxTarget.ImageList=imgListTarget;

				// Sets target filetype
				if(cbxFormat.SelectedItem.ToString()=="*.Bmp")
					currentImageFormat=ImageFormat.Bmp;
				else if(cbxFormat.SelectedItem.ToString()=="*.Gif")
					currentImageFormat=ImageFormat.Gif;
				else if(cbxFormat.SelectedItem.ToString()=="*.Jpeg")
					currentImageFormat=ImageFormat.Jpeg;
				else if(cbxFormat.SelectedItem.ToString()=="*.Png")
					currentImageFormat=ImageFormat.Png;
				else if(cbxFormat.SelectedItem.ToString()=="*.Tiff")
					currentImageFormat=ImageFormat.Tiff;

				int ImageListIndex=-1;
				int i = 0;

				try
				{
					for(i=0; i<lbxSource.Items.Count; i++)
					{
						// Process all selected source images
						if(lbxSource.GetSelected(i)==true)
						{
							ImageListIndex++;
							Image image		=	Image.FromFile(filesFromDialog[i].ToString());
							Image thumbNail	=	null;

							prgBar.Value+=PrgBarStepWidth; // Another step on the progress bar

							// Target file size
							int ResizeXInt=0;
							int ResizeYInt=0;

							// Target Size: no ratio adjustment, get size from input boxes
							if(cbxRatio.Checked==false)
							{
								ResizeXInt=Int32.Parse(tbxWidth.Text);
								ResizeYInt=Int32.Parse(tbxHeight.Text);
							}

							// Target Size: Ratio from x
							if(cbxRatio.Checked==true && rdbWidth.Checked==true)
							{
								float Ratio=((float)image.Width)/((float)image.Height);
								float ResizeX=Int32.Parse(tbxWidth.Text);
								float ResizeY=ResizeX/Ratio;

								ResizeXInt=Convert.ToInt32(ResizeX);
								ResizeYInt=Convert.ToInt32(ResizeY);
							}

							// Target Size: Ratio from y
							if(cbxRatio.Checked==true && rdbHeight.Checked==true)
							{
								float Ratio=((float)image.Width)/((float)image.Height);
								float ResizeY=Int32.Parse(tbxHeight.Text);
								float ResizeX=ResizeY/Ratio;

								ResizeXInt=Convert.ToInt32(ResizeX);
								ResizeYInt=Convert.ToInt32(ResizeY);
							}

							thumbNail = image.GetThumbnailImage(ResizeXInt, ResizeYInt, null, new IntPtr());

							// Build target filename
							string FileNameToSave = filesFromDialog[i].Remove(
								filesFromDialog[i].LastIndexOf("."),
								filesFromDialog[i].Length-filesFromDialog[i].LastIndexOf("."));

							// Save generated thumbnail
							thumbNail.Save(FileNameToSave+tbxExtension.Text, currentImageFormat);

							// Add target thumbnail to target listbox
							imgListTarget.Images.Add(thumbNail);
							float RatioLbx	= ((float)thumbNail.Width)/((float)thumbNail.Height);
							int picIndex	= imgListTarget.Images.Count-1;

							ImageListBoxItem lbxItem = new ImageListBoxItem(
								FileNameToSave+tbxExtension.Text+"\r\n"+
								txtWidth+thumbNail.Width.ToString()+
								", "+txtHeight+thumbNail.Height.ToString()+
								", "+txtRatio+RatioLbx.ToString(),picIndex);

							lbxTarget.Items.Add(lbxItem);
						}
					}
				}
				catch(Exception)
				{
					// Couldn't generate thumbnail from this file
					MessageBox.Show(errFile+lbxSource.GetSelected(i));
				}
				prgBar.Visible=false;
			}
			else
			{
				// No files are selected
				MessageBox.Show(errChoose,this.Text,MessageBoxButtons.OK, MessageBoxIcon.Information);
			}
		}

		private void btnGenerateThumb_Click(object sender, System.EventArgs e)
		{
			GenerateThumb();
		}

		private void miGenThumbs_Click(object sender, System.EventArgs e)
		{
			GenerateThumb();
		}

		private void ThumbGenerator_Load(object sender, System.EventArgs e)
		{
			// Adjust frame at startup
			ResizePnlContent();
		}

		private void ThumbGenerator_Resize(object sender, System.EventArgs e)
		{
			// Adjust frame if resized by user
			ResizePnlContent();
		}

		/// <summary>
		/// Resizes the Panel dynamically if the Window is resized by user
		/// </summary>
		private void ResizePnlContent()
		{
			gbxSource.Width = (pnlContent.Width/2)-35;
			gbxTarget.Width = (pnlContent.Width/2)-35;
			this.Refresh();
		}

		/// <summary>
		/// Info Dialog
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void miInfo_Click(object sender, System.EventArgs e)
		{
			About ab = new About(txtVersion);
			ab.ShowDialog();
		}

		private void miFileClear_Click(object sender, System.EventArgs e)
		{
			ClearEverything();
		}

		/// <summary>
		/// Opens Preferences Dialog
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void miPreferences_Click(object sender, System.EventArgs e)
		{
			Preferences pre = new Preferences(CurrentLang);
			pre.InitPref();
			if(pre.ShowDialog() == DialogResult.OK)
			{
				CurrentLang = pre.NewLanguage;
			}
		}

		/// <summary>
		/// Clears source and target listboxes
		/// </summary>
		private void ClearEverything()
		{
			lbxSource.Items.Clear();
			lbxTarget.Items.Clear();

			lbxSource.Refresh();
			lbxTarget.Refresh();
		}

		/// <summary>
		/// Ratio calculation was changed by user
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void cbxRatio_CheckedChanged(object sender, System.EventArgs e)
		{
			if(cbxRatio.Checked==true) // Set to standard WITH ratio calculation
			{
				pnlRatio.Enabled=true;
				tbxWidth.Enabled=false;
				tbxHeight.Enabled=false;

				tbxWidth.Text=txtStdWidth;
				tbxHeight.Text=txtStdHeight;
				if(rdbWidth.Checked==true)
					tbxHeight.Text=txtRatio;
				if(rdbHeight.Checked==true)
					tbxWidth.Text=txtRatio;
			}
			else // Set to standard WITHOUT ratio calculation
			{
				tbxWidth.Text=txtStdWidth;
				tbxHeight.Text=txtStdHeight;

				pnlRatio.Enabled=false;
				tbxWidth.Enabled=true;
				tbxHeight.Enabled=true;
			}
		}

		/// <summary>
		/// Width is static, Height is dynamic
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void rdbWidth_CheckedChanged(object sender, System.EventArgs e)
		{
			if(rdbWidth.Checked==true)
			{
				tbxWidth.Text=txtStdWidth;
				tbxHeight.Text=txtRatioShort;
				tbxWidth.Enabled=true;
				tbxHeight.Enabled=false;
			}
		}

		/// <summary>
		/// Height is static, Width is dynamic
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void rdbHeight_CheckedChanged(object sender, System.EventArgs e)
		{
			if(rdbHeight.Checked==true)
			{
				tbxWidth.Text=txtRatioShort;
				tbxHeight.Text=txtStdHeight;
				tbxWidth.Enabled=false;
				tbxHeight.Enabled=true;
			}
		}

		private void miExit_Click(object sender, System.EventArgs e)
		{
			this.Dispose(true);
		}

		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(ThumbGenerator));
			this.mainMenu = new System.Windows.Forms.MainMenu();
			this.miFile = new System.Windows.Forms.MenuItem();
			this.miChooseDir = new System.Windows.Forms.MenuItem();
			this.miGenThumbs = new System.Windows.Forms.MenuItem();
			this.miBlank1 = new System.Windows.Forms.MenuItem();
			this.miFileClear = new System.Windows.Forms.MenuItem();
			this.miBlank2 = new System.Windows.Forms.MenuItem();
			this.miPreferences = new System.Windows.Forms.MenuItem();
			this.miBlank3 = new System.Windows.Forms.MenuItem();
			this.miExit = new System.Windows.Forms.MenuItem();
			this.miHelp = new System.Windows.Forms.MenuItem();
			this.miInfo = new System.Windows.Forms.MenuItem();
			this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
			this.btnGenerateThumb = new System.Windows.Forms.Button();
			this.gbxSource = new System.Windows.Forms.GroupBox();
			this.lbxSource = new Controls.Development.ImageListBox();
			this.gbxTarget = new System.Windows.Forms.GroupBox();
			this.lbxTarget = new Controls.Development.ImageListBox();
			this.pnlAction = new System.Windows.Forms.Panel();
			this.gbxSettings = new System.Windows.Forms.GroupBox();
			this.cbxFormat = new System.Windows.Forms.ComboBox();
			this.tbxExtension = new System.Windows.Forms.TextBox();
			this.lblFormat = new System.Windows.Forms.Label();
			this.lblExtension = new System.Windows.Forms.Label();
			this.pnlSizeRatio = new System.Windows.Forms.Panel();
			this.cbxRatio = new System.Windows.Forms.CheckBox();
			this.lblHeight = new System.Windows.Forms.Label();
			this.lblWidth = new System.Windows.Forms.Label();
			this.tbxWidth = new System.Windows.Forms.TextBox();
			this.tbxHeight = new System.Windows.Forms.TextBox();
			this.pnlRatio = new System.Windows.Forms.Panel();
			this.rdbHeight = new System.Windows.Forms.RadioButton();
			this.rdbWidth = new System.Windows.Forms.RadioButton();
			this.lblPixel = new System.Windows.Forms.Label();
			this.pnlContent = new System.Windows.Forms.Panel();
			this.pnlImages = new System.Windows.Forms.Panel();
			this.prgBar = new System.Windows.Forms.ProgressBar();
			this.gbxSource.SuspendLayout();
			this.gbxTarget.SuspendLayout();
			this.pnlAction.SuspendLayout();
			this.gbxSettings.SuspendLayout();
			this.pnlSizeRatio.SuspendLayout();
			this.pnlRatio.SuspendLayout();
			this.pnlContent.SuspendLayout();
			this.pnlImages.SuspendLayout();
			this.SuspendLayout();
			// 
			// mainMenu
			// 
			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miFile,
																					 this.miHelp});
			// 
			// miFile
			// 
			this.miFile.Index = 0;
			this.miFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.miChooseDir,
																				   this.miGenThumbs,
																				   this.miBlank1,
																				   this.miFileClear,
																				   this.miBlank2,
																				   this.miPreferences,
																				   this.miBlank3,
																				   this.miExit});
			this.miFile.Text = "miFile";
			// 
			// miChooseDir
			// 
			this.miChooseDir.Index = 0;
			this.miChooseDir.Text = "miChooseDir";
			this.miChooseDir.Click += new System.EventHandler(this.miChooseDir_Click);
			// 
			// miGenThumbs
			// 
			this.miGenThumbs.Index = 1;
			this.miGenThumbs.Text = "miGenThumbs";
			this.miGenThumbs.Click += new System.EventHandler(this.miGenThumbs_Click);
			// 
			// miBlank1
			// 
			this.miBlank1.Index = 2;
			this.miBlank1.Text = "-";
			// 
			// miFileClear
			// 
			this.miFileClear.Index = 3;
			this.miFileClear.Text = "miFileClear";
			this.miFileClear.Click += new System.EventHandler(this.miFileClear_Click);
			// 
			// miBlank2
			// 
			this.miBlank2.Index = 4;
			this.miBlank2.Text = "-";
			// 
			// miPreferences
			// 
			this.miPreferences.Index = 5;
			this.miPreferences.Text = "miPreferences";
			this.miPreferences.Click += new System.EventHandler(this.miPreferences_Click);
			// 
			// miBlank3
			// 
			this.miBlank3.Index = 6;
			this.miBlank3.Text = "-";
			// 
			// miExit
			// 
			this.miExit.Index = 7;
			this.miExit.Text = "miExit";
			this.miExit.Click += new System.EventHandler(this.miExit_Click);
			// 
			// miHelp
			// 
			this.miHelp.Index = 1;
			this.miHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.miInfo});
			this.miHelp.Text = "miHelp";
			// 
			// miInfo
			// 
			this.miInfo.Index = 0;
			this.miInfo.Text = "miInfo";
			this.miInfo.Click += new System.EventHandler(this.miInfo_Click);
			// 
			// openFileDialog
			// 
			this.openFileDialog.Multiselect = true;
			// 
			// btnGenerateThumb
			// 
			this.btnGenerateThumb.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.btnGenerateThumb.BackColor = System.Drawing.Color.LightSteelBlue;
			this.btnGenerateThumb.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnGenerateThumb.Location = new System.Drawing.Point(296, 20);
			this.btnGenerateThumb.Name = "btnGenerateThumb";
			this.btnGenerateThumb.Size = new System.Drawing.Size(224, 28);
			this.btnGenerateThumb.TabIndex = 2;
			this.btnGenerateThumb.Text = "btnGenerateThumb";
			this.btnGenerateThumb.Click += new System.EventHandler(this.btnGenerateThumb_Click);
			// 
			// gbxSource
			// 
			this.gbxSource.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left);
			this.gbxSource.BackColor = System.Drawing.Color.Gainsboro;
			this.gbxSource.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.lbxSource});
			this.gbxSource.Location = new System.Drawing.Point(16, 8);
			this.gbxSource.Name = "gbxSource";
			this.gbxSource.Size = new System.Drawing.Size(256, 340);
			this.gbxSource.TabIndex = 5;
			this.gbxSource.TabStop = false;
			this.gbxSource.Text = "gbxSource";
			// 
			// lbxSource
			// 
			this.lbxSource.Dock = System.Windows.Forms.DockStyle.Fill;
			this.lbxSource.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
			this.lbxSource.HorizontalScrollbar = true;
			this.lbxSource.ItemHeight = 28;
			this.lbxSource.Location = new System.Drawing.Point(3, 16);
			this.lbxSource.Name = "lbxSource";
			this.lbxSource.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
			this.lbxSource.Size = new System.Drawing.Size(250, 312);
			this.lbxSource.TabIndex = 7;
			// 
			// gbxTarget
			// 
			this.gbxTarget.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom);
			this.gbxTarget.BackColor = System.Drawing.Color.Gainsboro;
			this.gbxTarget.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.lbxTarget});
			this.gbxTarget.Location = new System.Drawing.Point(448, 8);
			this.gbxTarget.Name = "gbxTarget";
			this.gbxTarget.Size = new System.Drawing.Size(256, 340);
			this.gbxTarget.TabIndex = 6;
			this.gbxTarget.TabStop = false;
			this.gbxTarget.Text = "gbxTarget";
			// 
			// lbxTarget
			// 
			this.lbxTarget.Dock = System.Windows.Forms.DockStyle.Fill;
			this.lbxTarget.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
			this.lbxTarget.HorizontalScrollbar = true;
			this.lbxTarget.ItemHeight = 28;
			this.lbxTarget.Location = new System.Drawing.Point(3, 16);
			this.lbxTarget.Name = "lbxTarget";
			this.lbxTarget.SelectionMode = System.Windows.Forms.SelectionMode.None;
			this.lbxTarget.Size = new System.Drawing.Size(250, 312);
			this.lbxTarget.TabIndex = 0;
			// 
			// pnlAction
			// 
			this.pnlAction.BackColor = System.Drawing.Color.Gainsboro;
			this.pnlAction.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.gbxSettings});
			this.pnlAction.Dock = System.Windows.Forms.DockStyle.Top;
			this.pnlAction.Name = "pnlAction";
			this.pnlAction.Size = new System.Drawing.Size(856, 96);
			this.pnlAction.TabIndex = 7;
			// 
			// gbxSettings
			// 
			this.gbxSettings.Anchor = (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			this.gbxSettings.BackColor = System.Drawing.Color.Gainsboro;
			this.gbxSettings.Controls.AddRange(new System.Windows.Forms.Control[] {
																					  this.cbxFormat,
																					  this.tbxExtension,
																					  this.lblFormat,
																					  this.lblExtension,
																					  this.btnGenerateThumb,
																					  this.pnlSizeRatio});
			this.gbxSettings.Location = new System.Drawing.Point(16, 4);
			this.gbxSettings.Name = "gbxSettings";
			this.gbxSettings.Size = new System.Drawing.Size(832, 88);
			this.gbxSettings.TabIndex = 3;
			this.gbxSettings.TabStop = false;
			this.gbxSettings.Text = "gbxSettings";
			// 
			// cbxFormat
			// 
			this.cbxFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbxFormat.Items.AddRange(new object[] {
														   "*.Bmp",
														   "*.Gif",
														   "*.Jpeg",
														   "*.Png",
														   "*.Tiff"});
			this.cbxFormat.Location = new System.Drawing.Point(120, 52);
			this.cbxFormat.Name = "cbxFormat";
			this.cbxFormat.Size = new System.Drawing.Size(152, 21);
			this.cbxFormat.Sorted = true;
			this.cbxFormat.TabIndex = 6;
			// 
			// tbxExtension
			// 
			this.tbxExtension.Location = new System.Drawing.Point(120, 20);
			this.tbxExtension.Name = "tbxExtension";
			this.tbxExtension.Size = new System.Drawing.Size(152, 20);
			this.tbxExtension.TabIndex = 5;
			this.tbxExtension.Text = "";
			// 
			// lblFormat
			// 
			this.lblFormat.Location = new System.Drawing.Point(8, 52);
			this.lblFormat.Name = "lblFormat";
			this.lblFormat.Size = new System.Drawing.Size(104, 23);
			this.lblFormat.TabIndex = 4;
			this.lblFormat.Text = "lblFormat";
			this.lblFormat.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblExtension
			// 
			this.lblExtension.Location = new System.Drawing.Point(8, 16);
			this.lblExtension.Name = "lblExtension";
			this.lblExtension.Size = new System.Drawing.Size(104, 23);
			this.lblExtension.TabIndex = 3;
			this.lblExtension.Text = "lblExtension";
			this.lblExtension.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// pnlSizeRatio
			// 
			this.pnlSizeRatio.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			this.pnlSizeRatio.Controls.AddRange(new System.Windows.Forms.Control[] {
																					   this.cbxRatio,
																					   this.lblHeight,
																					   this.lblWidth,
																					   this.tbxWidth,
																					   this.tbxHeight,
																					   this.pnlRatio,
																					   this.lblPixel});
			this.pnlSizeRatio.Location = new System.Drawing.Point(536, 20);
			this.pnlSizeRatio.Name = "pnlSizeRatio";
			this.pnlSizeRatio.Size = new System.Drawing.Size(288, 56);
			this.pnlSizeRatio.TabIndex = 7;
			// 
			// cbxRatio
			// 
			this.cbxRatio.Location = new System.Drawing.Point(8, 3);
			this.cbxRatio.Name = "cbxRatio";
			this.cbxRatio.Size = new System.Drawing.Size(160, 24);
			this.cbxRatio.TabIndex = 12;
			this.cbxRatio.Tag = "";
			this.cbxRatio.Text = "cbxRatio";
			this.cbxRatio.CheckedChanged += new System.EventHandler(this.cbxRatio_CheckedChanged);
			// 
			// lblHeight
			// 
			this.lblHeight.Location = new System.Drawing.Point(168, 33);
			this.lblHeight.Name = "lblHeight";
			this.lblHeight.Size = new System.Drawing.Size(40, 23);
			this.lblHeight.TabIndex = 9;
			this.lblHeight.Text = "lblHeight";
			this.lblHeight.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblWidth
			// 
			this.lblWidth.Location = new System.Drawing.Point(168, 0);
			this.lblWidth.Name = "lblWidth";
			this.lblWidth.Size = new System.Drawing.Size(40, 23);
			this.lblWidth.TabIndex = 7;
			this.lblWidth.Text = "lblWidth";
			this.lblWidth.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// tbxWidth
			// 
			this.tbxWidth.Location = new System.Drawing.Point(208, 3);
			this.tbxWidth.MaxLength = 4;
			this.tbxWidth.Name = "tbxWidth";
			this.tbxWidth.Size = new System.Drawing.Size(40, 20);
			this.tbxWidth.TabIndex = 8;
			this.tbxWidth.Text = "";
			// 
			// tbxHeight
			// 
			this.tbxHeight.Location = new System.Drawing.Point(208, 35);
			this.tbxHeight.MaxLength = 4;
			this.tbxHeight.Name = "tbxHeight";
			this.tbxHeight.Size = new System.Drawing.Size(40, 20);
			this.tbxHeight.TabIndex = 10;
			this.tbxHeight.Text = "";
			// 
			// pnlRatio
			// 
			this.pnlRatio.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.rdbHeight,
																				   this.rdbWidth});
			this.pnlRatio.Location = new System.Drawing.Point(0, 27);
			this.pnlRatio.Name = "pnlRatio";
			this.pnlRatio.Size = new System.Drawing.Size(120, 24);
			this.pnlRatio.TabIndex = 13;
			// 
			// rdbHeight
			// 
			this.rdbHeight.Location = new System.Drawing.Point(64, 4);
			this.rdbHeight.Name = "rdbHeight";
			this.rdbHeight.Size = new System.Drawing.Size(56, 24);
			this.rdbHeight.TabIndex = 1;
			this.rdbHeight.Text = "rdbHeight";
			this.rdbHeight.CheckedChanged += new System.EventHandler(this.rdbHeight_CheckedChanged);
			// 
			// rdbWidth
			// 
			this.rdbWidth.Location = new System.Drawing.Point(8, 4);
			this.rdbWidth.Name = "rdbWidth";
			this.rdbWidth.Size = new System.Drawing.Size(56, 24);
			this.rdbWidth.TabIndex = 0;
			this.rdbWidth.Text = "rdbWidth";
			this.rdbWidth.CheckedChanged += new System.EventHandler(this.rdbWidth_CheckedChanged);
			// 
			// lblPixel
			// 
			this.lblPixel.Location = new System.Drawing.Point(255, 19);
			this.lblPixel.Name = "lblPixel";
			this.lblPixel.Size = new System.Drawing.Size(32, 23);
			this.lblPixel.TabIndex = 11;
			this.lblPixel.Text = "lblPixel";
			this.lblPixel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// pnlContent
			// 
			this.pnlContent.BackColor = System.Drawing.Color.Gainsboro;
			this.pnlContent.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.gbxTarget,
																					 this.gbxSource});
			this.pnlContent.Dock = System.Windows.Forms.DockStyle.Fill;
			this.pnlContent.Location = new System.Drawing.Point(0, 96);
			this.pnlContent.Name = "pnlContent";
			this.pnlContent.Size = new System.Drawing.Size(856, 417);
			this.pnlContent.TabIndex = 8;
			// 
			// pnlImages
			// 
			this.pnlImages.AutoScroll = true;
			this.pnlImages.BackColor = System.Drawing.Color.Gainsboro;
			this.pnlImages.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.prgBar});
			this.pnlImages.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.pnlImages.Location = new System.Drawing.Point(0, 457);
			this.pnlImages.Name = "pnlImages";
			this.pnlImages.Size = new System.Drawing.Size(856, 56);
			this.pnlImages.TabIndex = 9;
			// 
			// prgBar
			// 
			this.prgBar.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.prgBar.Location = new System.Drawing.Point(288, 24);
			this.prgBar.Name = "prgBar";
			this.prgBar.Size = new System.Drawing.Size(296, 16);
			this.prgBar.TabIndex = 0;
			// 
			// ThumbGenerator
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(856, 513);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.pnlImages,
																		  this.pnlContent,
																		  this.pnlAction});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mainMenu;
			this.MinimumSize = new System.Drawing.Size(792, 500);
			this.Name = "ThumbGenerator";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Thumbnail Generator";
			this.Resize += new System.EventHandler(this.ThumbGenerator_Resize);
			this.Load += new System.EventHandler(this.ThumbGenerator_Load);
			this.gbxSource.ResumeLayout(false);
			this.gbxTarget.ResumeLayout(false);
			this.pnlAction.ResumeLayout(false);
			this.gbxSettings.ResumeLayout(false);
			this.pnlSizeRatio.ResumeLayout(false);
			this.pnlRatio.ResumeLayout(false);
			this.pnlContent.ResumeLayout(false);
			this.pnlImages.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
Experience:
- Java
- C#
- XML, XSL, PHP, ASP, ASP.NET
- Server administration

- ASM, Visual Basic (poor)
- Linux (poor)

If you have any offers, questions, or project ideas please feel free to contact me.

If you experience any bugs in my software, please report them.

Thank you.

Comments and Discussions