Click here to Skip to main content
15,886,518 members
Articles / Multimedia / GDI+

Click to Drag, Zoom, and Copy - PictureBox

Rate me:
Please Sign up or sign in to vote.
4.11/5 (17 votes)
23 Jan 20074 min read 148.4K   8.8K   108  
A picture box with built-in click to drag, zoom, and copy.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestApp
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private Tpsc.Controls.PictureBoxEx pictureBoxEx1;
		/// <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.pictureBoxEx1 = new Tpsc.Controls.PictureBoxEx();
			this.SuspendLayout();
			// 
			// pictureBoxEx1
			// 
			this.pictureBoxEx1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.pictureBoxEx1.AutoScroll = true;
			this.pictureBoxEx1.AutoScrollMinSize = new System.Drawing.Size(800, 600);
			this.pictureBoxEx1.DiagnosticMode = true;
			this.pictureBoxEx1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBoxEx1.Image")));
			this.pictureBoxEx1.Location = new System.Drawing.Point(8, 8);
			this.pictureBoxEx1.MaximumZoom = 1F;
			this.pictureBoxEx1.Name = "pictureBoxEx1";
			this.pictureBoxEx1.Size = new System.Drawing.Size(656, 472);
			this.pictureBoxEx1.TabIndex = 2;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(672, 486);
			this.Controls.Add(this.pictureBoxEx1);
			this.Name = "Form1";
			this.Text = "PictureBoxEx Test Application";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}

		#endregion

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

			Application.EnableVisualStyles();
		}


		private void Form1_Load(object sender, System.EventArgs e)
		{
			Tpsc.Controls.Annotation annote1 = new Tpsc.Controls.Annotation("Annotation 1",
				new Font("Arial Black", 9.25F, FontStyle.Regular), Color.Red);

			annote1.Location = new Point(100, 100);

			pictureBoxEx1.Annotations.Add(annote1, true);

			Tpsc.Controls.Annotation annote2 = new Tpsc.Controls.Annotation("Annotation 2",
				new Font("Arial Black", 22F, FontStyle.Regular), Color.Red);

			annote2.Location = new Point(150, 150);

			pictureBoxEx1.Annotations.Add(annote2, true);
		}
	}
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions