Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
GeneralRe: Wht is Static? Pin
Simon P Stevens13-Jun-08 4:39
Simon P Stevens13-Jun-08 4:39 
QuestionClicking on a drawn line Pin
Gareth H13-Jun-08 4:09
Gareth H13-Jun-08 4:09 
AnswerRe: Clicking on a drawn line Pin
User 665813-Jun-08 4:31
User 665813-Jun-08 4:31 
AnswerRe: Clicking on a drawn line [modified] Pin
Anthony Mushrow13-Jun-08 4:33
professionalAnthony Mushrow13-Jun-08 4:33 
GeneralRe: Clicking on a drawn line Pin
Gareth H13-Jun-08 7:16
Gareth H13-Jun-08 7:16 
GeneralRe: Clicking on a drawn line Pin
Anthony Mushrow13-Jun-08 7:19
professionalAnthony Mushrow13-Jun-08 7:19 
GeneralRe: Clicking on a drawn line Pin
Gareth H13-Jun-08 7:31
Gareth H13-Jun-08 7:31 
GeneralRe: Clicking on a drawn line Pin
Anthony Mushrow13-Jun-08 8:09
professionalAnthony Mushrow13-Jun-08 8:09 
This little test worked out:

PointF start = new Point(0, 0);
PointF end = new Point(150, 150);
float m;
float c;

protected override void OnPaint(PaintEventArgs e)
{
	base.OnPaint(e);
	e.Graphics.DrawLine(Pens.Black, start, end);
}

void Form1MouseClick(object sender, MouseEventArgs e)
{
	m = (end.Y - start.Y)/(end.X - start.X);
	c = start.Y - m*start.X;
	
	Y = m*e.X + c;
	Y -= e.Y;
	Y *= Y;
	if(Y <= 5)
		MessageBox.Show("Shwam");			
}


Clicking within one pixel was hard(ish) 5 seems pretty good though.

Damn, I just remebered, the gradient for a verticle line would be infinite. That means that this wouldn't work for completely verticle lines.
EDIT: Although
m = (end.Y - start.Y)/(end.X - start.X);
c = start.Y - m*start.X;
	
Y = m*e.X + c;
Y -= e.Y;
if(-3 < Y && Y lt; 2)
	MessageBox.Show("Shwam");

if(float.IsInfinity(m)) {
	float X = start.X - e.X;
	if(-3 < X && X < 3)
		MessageBox.Show("Shwam");
}


My current favourite word is: I'm starting to run out of fav. words!
-SK Genius

Game Programming articles start -here[^]-

QuestionCannot Save Personal settings Pin
humayunlalzad13-Jun-08 3:50
humayunlalzad13-Jun-08 3:50 
AnswerRe: Cannot Save Personal settings Pin
leppie13-Jun-08 3:51
leppie13-Jun-08 3:51 
GeneralRe: Cannot Save Personal settings Pin
humayunlalzad13-Jun-08 4:07
humayunlalzad13-Jun-08 4:07 
AnswerRe: Cannot Save Personal settings Pin
Ashfield13-Jun-08 4:13
Ashfield13-Jun-08 4:13 
GeneralRe: Cannot Save Personal settings Pin
humayunlalzad13-Jun-08 4:28
humayunlalzad13-Jun-08 4:28 
GeneralRe: Cannot Save Personal settings Pin
Ashfield13-Jun-08 5:11
Ashfield13-Jun-08 5:11 
GeneralRe: Cannot Save Personal settings Pin
leppie13-Jun-08 5:18
leppie13-Jun-08 5:18 
GeneralRe: Cannot Save Personal settings Pin
humayunlalzad13-Jun-08 5:34
humayunlalzad13-Jun-08 5:34 
GeneralRe: Cannot Save Personal settings Pin
leppie13-Jun-08 6:10
leppie13-Jun-08 6:10 
QuestionHow to merge the 2 tables of a dataset using c#, given the 2 tables contain same primary key with different content Pin
dotNetKeen13-Jun-08 3:41
dotNetKeen13-Jun-08 3:41 
AnswerRe: How to merge the 2 tables of a dataset using c#, given the 2 tables contain same primary key with different content Pin
leppie13-Jun-08 5:20
leppie13-Jun-08 5:20 
QuestionHow can I read a specific node in XML file ? Pin
Mohammad Dayyan13-Jun-08 3:39
Mohammad Dayyan13-Jun-08 3:39 
AnswerRe: How can I read a specific node in XML file ? Pin
leppie13-Jun-08 3:46
leppie13-Jun-08 3:46 
GeneralRe: How can I read a specific node in XML file ? Pin
Mohammad Dayyan13-Jun-08 3:49
Mohammad Dayyan13-Jun-08 3:49 
GeneralRe: How can I read a specific node in XML file ? Pin
leppie13-Jun-08 3:52
leppie13-Jun-08 3:52 
QuestionChange Page Doctype Pin
tadhg8813-Jun-08 3:05
tadhg8813-Jun-08 3:05 
AnswerRe: Change Page Doctype Pin
leppie13-Jun-08 12:17
leppie13-Jun-08 12:17 

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.