Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / C#

Nice Line - A simple shaded line

Rate me:
Please Sign up or sign in to vote.
4.30/5 (16 votes)
21 Aug 20032 min read 84.9K   2.6K   50  
A simple line control with multiple purposes
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace NiceLineDemo
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private NiceLineDemo.NiceLine niceLine1;
		private System.Windows.Forms.Panel panel1;
		private NiceLineDemo.NiceLine niceLine2;
		private NiceLineDemo.NiceLine niceLine4;
		private NiceLineDemo.NiceLine niceLine5;
		private System.Windows.Forms.Button button1;
		private NiceLineDemo.NiceLine niceLine3;
		private NiceLineDemo.NiceLine niceLine6;
		private System.Windows.Forms.Label label7;
		/// <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()
		{
			this.niceLine1 = new NiceLineDemo.NiceLine();
			this.panel1 = new System.Windows.Forms.Panel();
			this.label7 = new System.Windows.Forms.Label();
			this.niceLine2 = new NiceLineDemo.NiceLine();
			this.niceLine4 = new NiceLineDemo.NiceLine();
			this.niceLine5 = new NiceLineDemo.NiceLine();
			this.button1 = new System.Windows.Forms.Button();
			this.niceLine3 = new NiceLineDemo.NiceLine();
			this.niceLine6 = new NiceLineDemo.NiceLine();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// niceLine1
			// 
			this.niceLine1.BackColor = System.Drawing.SystemColors.Control;
			this.niceLine1.Caption = "Nice Line 1";
			this.niceLine1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.niceLine1.ForeColor = System.Drawing.SystemColors.WindowText;
			this.niceLine1.Location = new System.Drawing.Point(24, 72);
			this.niceLine1.Name = "niceLine1";
			this.niceLine1.Size = new System.Drawing.Size(232, 15);
			this.niceLine1.TabIndex = 0;
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.label7});
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(288, 40);
			this.panel1.TabIndex = 1;
			// 
			// label7
			// 
			this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label7.ForeColor = System.Drawing.SystemColors.Desktop;
			this.label7.Location = new System.Drawing.Point(8, 0);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(224, 24);
			this.label7.TabIndex = 14;
			this.label7.Text = "Nice Line Demo";
			// 
			// niceLine2
			// 
			this.niceLine2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.niceLine2.LineVerticalAlign = NiceLineDemo.LineVerticalAlign.Top;
			this.niceLine2.Location = new System.Drawing.Point(0, 32);
			this.niceLine2.Name = "niceLine2";
			this.niceLine2.Size = new System.Drawing.Size(280, 15);
			this.niceLine2.TabIndex = 2;
			// 
			// niceLine4
			// 
			this.niceLine4.Caption = "Nice Line 2";
			this.niceLine4.CaptionMarginSpace = 8;
			this.niceLine4.CaptionOrizontalAlign = NiceLineDemo.CaptionOrizontalAlign.Right;
			this.niceLine4.CaptionPadding = 4;
			this.niceLine4.Location = new System.Drawing.Point(24, 96);
			this.niceLine4.Name = "niceLine4";
			this.niceLine4.Size = new System.Drawing.Size(232, 15);
			this.niceLine4.TabIndex = 4;
			// 
			// niceLine5
			// 
			this.niceLine5.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.niceLine5.LineVerticalAlign = NiceLineDemo.LineVerticalAlign.Bottom;
			this.niceLine5.Location = new System.Drawing.Point(0, 144);
			this.niceLine5.Name = "niceLine5";
			this.niceLine5.Size = new System.Drawing.Size(280, 15);
			this.niceLine5.TabIndex = 5;
			// 
			// button1
			// 
			this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button1.Location = new System.Drawing.Point(8, 168);
			this.button1.Name = "button1";
			this.button1.TabIndex = 6;
			this.button1.Text = "Exit";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// niceLine3
			// 
			this.niceLine3.Location = new System.Drawing.Point(24, 48);
			this.niceLine3.Name = "niceLine3";
			this.niceLine3.Size = new System.Drawing.Size(232, 15);
			this.niceLine3.TabIndex = 7;
			// 
			// niceLine6
			// 
			this.niceLine6.Caption = "Nice Line 3";
			this.niceLine6.CaptionOrizontalAlign = NiceLineDemo.CaptionOrizontalAlign.Center;
			this.niceLine6.CaptionPadding = 24;
			this.niceLine6.Location = new System.Drawing.Point(24, 120);
			this.niceLine6.Name = "niceLine6";
			this.niceLine6.Size = new System.Drawing.Size(232, 15);
			this.niceLine6.TabIndex = 8;
			// 
			// Form1
			// 
			this.AcceptButton = this.button1;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.button1;
			this.ClientSize = new System.Drawing.Size(280, 197);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.niceLine6,
																		  this.niceLine3,
																		  this.button1,
																		  this.niceLine5,
																		  this.niceLine4,
																		  this.niceLine2,
																		  this.niceLine1,
																		  this.panel1});
			this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.MaximizeBox = false;
			this.Name = "Form1";
			this.Text = "Nice Line Demo";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.panel1.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 Form1_Load(object sender, System.EventArgs e)
		{
		
		}

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

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

Comments and Discussions