Click here to Skip to main content
15,888,340 members
Home / Discussions / C#
   

C#

 
GeneralRe: UML for C# Pin
Tomas Petricek28-May-03 13:15
Tomas Petricek28-May-03 13:15 
GeneralRe: UML for C# Pin
KingTermite29-May-03 7:42
KingTermite29-May-03 7:42 
GeneralRe: UML for C# Pin
Anonymous18-Jun-03 9:44
Anonymous18-Jun-03 9:44 
GeneralMystery of the missing line control Pin
RB@Emphasys28-May-03 8:48
RB@Emphasys28-May-03 8:48 
GeneralRe: Mystery of the missing line control Pin
Ray Cassick28-May-03 9:23
Ray Cassick28-May-03 9:23 
GeneralRe: Mystery of the missing line control Pin
Nick Parker28-May-03 17:30
protectorNick Parker28-May-03 17:30 
GeneralRe: Mystery of the missing line control Pin
Anonymous28-May-03 14:15
Anonymous28-May-03 14:15 
GeneralRe: Mystery of the missing line control Pin
Nick Parker28-May-03 17:29
protectorNick Parker28-May-03 17:29 
Ryan@SalamanderTechnologies wrote:
Does anyone know where it went?

Nope, but I wrote up a quick control for you, I haven't implemented everything, however it does do the job (even works with diagonal lines Smile | :) ) I am writing an article on this, but here is some code that you can compile into a quick control if you would like, hope this helps:

using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace DeveloperNotes.LineControl
{
	public class LineControl : System.Windows.Forms.UserControl, ISupportInitialize
	{
		private Point start, end;
		private Color color;

		#region ISupportInitialize

		void ISupportInitialize.BeginInit() {}

		void ISupportInitialize.EndInit() {}

                  #endregion
		
		#region Properties
		[Category("Position"),Description("Starting position of line")]
		public Point Start
		{
			get{return start;}
			set{start = value;}
		}
		[Category("Position"),Description("Ending position of line")]
		public Point End
		{
			get{return end;}
			set{end = value;}
		}
		[Category("Line Color"),Description("Color of line")]
		public Color LineColor
		{
			get{return color;}
			set{color = value;}
		}
		#endregion

		#region Constructors
		public LineControl()
		{
			this.SetStyle(ControlStyles.DoubleBuffer, true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			this.SetStyle(ControlStyles.ResizeRedraw, true);
		}
		public LineControl(int x1, int y1, int x2, int y2)
		{
			start.X = x1;
			start.Y = y1;
			end.X = x2;
			end.Y = y2;
		}
		public LineControl(Point pt1, Point pt2)
		{
			start = pt1;
			end = pt2;
		}
		#endregion

		#region Event Handlers

		protected override void OnPaint(PaintEventArgs pe) 
		{
			Graphics   g = pe.Graphics;
			SolidBrush brush = new SolidBrush(this.color);
			Pen pen = new Pen(brush, 1);
			Size       clientSize = this.ClientRectangle.Size;
			g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
			g.DrawLine(pen, this.start, this.end);
			base.OnPaint(pe);
		}
		#endregion

	}
}


-Nick Parker
GeneralRe: Mystery of the missing line control Pin
RB@Emphasys29-May-03 2:54
RB@Emphasys29-May-03 2:54 
GeneralSingleton/static member question... Pin
Ryan Cromwell28-May-03 7:25
Ryan Cromwell28-May-03 7:25 
GeneralRe: Singleton/static member question... Pin
leppie28-May-03 11:10
leppie28-May-03 11:10 
GeneralCopy protection via internet Pin
Bog28-May-03 7:09
Bog28-May-03 7:09 
GeneralRe: Copy protection via internet Pin
Ray Cassick28-May-03 7:16
Ray Cassick28-May-03 7:16 
GeneralRe: Copy protection via internet Pin
Bog28-May-03 9:11
Bog28-May-03 9:11 
GeneralRe: Copy protection via internet Pin
Ray Cassick28-May-03 9:20
Ray Cassick28-May-03 9:20 
GeneralRe: Copy protection via internet Pin
KingTermite28-May-03 7:53
KingTermite28-May-03 7:53 
GeneralRe: Copy protection via internet Pin
Bog28-May-03 8:58
Bog28-May-03 8:58 
GeneralRe: Copy protection via internet Pin
Christian Merritt28-May-03 9:37
Christian Merritt28-May-03 9:37 
GeneralRe: Copy protection via internet Pin
Bog28-May-03 9:55
Bog28-May-03 9:55 
GeneralRe: Copy protection via internet Pin
The Limey28-May-03 10:34
The Limey28-May-03 10:34 
GeneralRe: Copy protection via internet Pin
Ranjan Banerji28-May-03 9:47
Ranjan Banerji28-May-03 9:47 
GeneralRe: Copy protection via internet Pin
Bog28-May-03 9:52
Bog28-May-03 9:52 
GeneralRe: Copy protection via internet Pin
Kant28-May-03 13:20
Kant28-May-03 13:20 
GeneralRe: Copy protection via internet Pin
Rocky Moore28-May-03 22:27
Rocky Moore28-May-03 22:27 
GeneralRe: Copy protection via internet Pin
Daniel Turini29-May-03 11:35
Daniel Turini29-May-03 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.