Click here to Skip to main content
15,892,298 members
Articles / Programming Languages / C#

Code Template Add-In for Visual Studio .NET

Rate me:
Please Sign up or sign in to vote.
4.90/5 (71 votes)
6 May 200413 min read 466.9K   1.2K   150  
A Visual Studio .NET addin that provides a mechanism for inserting commonly used code snippets.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;

namespace CodeTemplate
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	internal class AboutBox : System.Windows.Forms.Form
	{
        private System.Windows.Forms.Button m_btnOK;
        private System.Windows.Forms.LinkLabel m_linkEmail;
        private System.Windows.Forms.Label m_lblVersion;
        private System.Windows.Forms.PictureBox m_picIcon;
        private System.Windows.Forms.Label m_lblCopyright;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public AboutBox()
		{
			InitializeComponent();

            FileVersionInfo vi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            m_lblVersion.Text += vi.FileVersion;

            string email = "codetemplate@e-velasquez.com";
            int start = m_linkEmail.Text.IndexOf(email);
            m_linkEmail.Links.Add(start, email.Length, "mailto:" + email);
		}

		/// <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(AboutBox));
			this.m_btnOK = new System.Windows.Forms.Button();
			this.m_linkEmail = new System.Windows.Forms.LinkLabel();
			this.m_lblVersion = new System.Windows.Forms.Label();
			this.m_picIcon = new System.Windows.Forms.PictureBox();
			this.m_lblCopyright = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// m_btnOK
			// 
			this.m_btnOK.Location = new System.Drawing.Point(116, 152);
			this.m_btnOK.Name = "m_btnOK";
			this.m_btnOK.TabIndex = 0;
			this.m_btnOK.Text = "OK";
			this.m_btnOK.Click += new System.EventHandler(this.m_btnOK_Click);
			// 
			// m_linkEmail
			// 
			this.m_linkEmail.Location = new System.Drawing.Point(56, 96);
			this.m_linkEmail.Name = "m_linkEmail";
			this.m_linkEmail.Size = new System.Drawing.Size(240, 48);
			this.m_linkEmail.TabIndex = 1;
			this.m_linkEmail.TabStop = true;
			this.m_linkEmail.Text = "For suggestions or bug reports, codetemplate@e-velasquez.com";
			this.m_linkEmail.UseMnemonic = false;
			this.m_linkEmail.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.m_linkEmail_LinkClicked);
			// 
			// m_lblVersion
			// 
			this.m_lblVersion.Location = new System.Drawing.Point(64, 24);
			this.m_lblVersion.Name = "m_lblVersion";
			this.m_lblVersion.Size = new System.Drawing.Size(232, 24);
			this.m_lblVersion.TabIndex = 2;
			this.m_lblVersion.Text = "Code<Template>.NET version ";
			// 
			// m_picIcon
			// 
			this.m_picIcon.Image = ((System.Drawing.Image)(resources.GetObject("m_picIcon.Image")));
			this.m_picIcon.Location = new System.Drawing.Point(16, 24);
			this.m_picIcon.Name = "m_picIcon";
			this.m_picIcon.Size = new System.Drawing.Size(32, 32);
			this.m_picIcon.TabIndex = 3;
			this.m_picIcon.TabStop = false;
			this.m_picIcon.DoubleClick += new System.EventHandler(this.m_picIcon_DoubleClick);
			// 
			// m_lblCopyright
			// 
			this.m_lblCopyright.Location = new System.Drawing.Point(64, 48);
			this.m_lblCopyright.Name = "m_lblCopyright";
			this.m_lblCopyright.Size = new System.Drawing.Size(232, 48);
			this.m_lblCopyright.TabIndex = 4;
			this.m_lblCopyright.Text = "Copyright (c) 2002, 2004 by Eddie Velasquez";
			// 
			// AboutBox
			// 
			this.AcceptButton = this.m_btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(306, 184);
			this.Controls.Add(this.m_lblCopyright);
			this.Controls.Add(this.m_picIcon);
			this.Controls.Add(this.m_lblVersion);
			this.Controls.Add(this.m_linkEmail);
			this.Controls.Add(this.m_btnOK);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "AboutBox";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "About Code<Template>.NET";
			this.ResumeLayout(false);

		}
		#endregion

        private void m_linkEmail_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            // Determine which link was clicked within the LinkLabel.
            m_linkEmail.Links[m_linkEmail.Links.IndexOf(e.Link)].Visited = true;

            // Display the appropriate link based on the value of the LinkData property of the Link object.
            System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
        
        }

        private void m_btnOK_Click(object sender, System.EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

		private void m_picIcon_DoubleClick(object sender, System.EventArgs e)
		{
			if(s_currEgg > s_easterEgg.Length - 1)
				s_currEgg = 0;

			MessageBox.Show(s_easterEgg[s_currEgg++]);
		}

		private static int s_currEgg = 0;
		private static string[] s_easterEgg = 
		{
			"Who lives in a pineapple under the sea?",
			"Absorbent and yellow and pourous is he!",
			"If nautical nonsense be something you wish,",
			"Then drop on the deck and flop like a fish!"
		};
	}
}

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
Software Developer (Senior)
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