EDN Admin
Well-known member
<span id="x_x_result_box" lang="en <span>Hi<span>.<span>I am a
<span>new <span>member<span>.<span>I <span>have a problem
<span>with <span>drawing straight lines<span>.<span>I use
<span>this <span>code<span>:
<span lang="en <span>
<div style="color:black; background-color:white
<pre>List<Point> points = <span style="color:blue new List<Point>();
<span style="color:green //add point when Mouse down
<span style="color:blue private <span style="color:blue void pictureBox1_MouseDown(<span style="color:blue object sender,MouseEventArgs e)
{
<span style="color:blue if (e.Button == MouseButtons.Left)
{
points.Add(e.Location);
pictureBox1.Invalidate();
}
}
<span style="color:blue private <span style="color:blue void pictureBox1_Paint(<span style="color:blue object sender, PaintEventArgs e)
{
<span style="color:blue if (points.Count > 1)
e.Graphics.DrawLines(Pens.Magenta, points.ToArray());
}
[/code]
<span id="x_x_result_box" lang="en <span>I had <span>a line <span>
when <span>I click <span>mouse in the <span>PictureBox.<span id="x_x_result_box" lang="en <span>I
<span>want to <span>draw a line <span>from one point to <span>
the current <span>coordinates <span>of the mouse<span>.<br/>
<span>after I press <span>the left button<span>, <span>I move the mouse
<span>and appears <span>a <span>straight line from <span>previous point
<span>to <span>the mouse <span>coordinates<span>.<span id="x_result_box" lang="en <span>Finally a
<span>real <span>straight line <span>will appear <span>when the user presses
<span>the left mouse.<span id="x_x_result_box" lang="en <span>Its like the
<span>Pen <span>tool <span>of <span>Corel <span>draw<span id="x_x_result_box" lang="en <span>.How do I
<span>do <span>it<span>?
<br/>
View the full article
<span>new <span>member<span>.<span>I <span>have a problem
<span>with <span>drawing straight lines<span>.<span>I use
<span>this <span>code<span>:
<span lang="en <span>
<div style="color:black; background-color:white
<pre>List<Point> points = <span style="color:blue new List<Point>();
<span style="color:green //add point when Mouse down
<span style="color:blue private <span style="color:blue void pictureBox1_MouseDown(<span style="color:blue object sender,MouseEventArgs e)
{
<span style="color:blue if (e.Button == MouseButtons.Left)
{
points.Add(e.Location);
pictureBox1.Invalidate();
}
}
<span style="color:blue private <span style="color:blue void pictureBox1_Paint(<span style="color:blue object sender, PaintEventArgs e)
{
<span style="color:blue if (points.Count > 1)
e.Graphics.DrawLines(Pens.Magenta, points.ToArray());
}
[/code]
<span id="x_x_result_box" lang="en <span>I had <span>a line <span>
when <span>I click <span>mouse in the <span>PictureBox.<span id="x_x_result_box" lang="en <span>I
<span>want to <span>draw a line <span>from one point to <span>
the current <span>coordinates <span>of the mouse<span>.<br/>
<span>after I press <span>the left button<span>, <span>I move the mouse
<span>and appears <span>a <span>straight line from <span>previous point
<span>to <span>the mouse <span>coordinates<span>.<span id="x_result_box" lang="en <span>Finally a
<span>real <span>straight line <span>will appear <span>when the user presses
<span>the left mouse.<span id="x_x_result_box" lang="en <span>Its like the
<span>Pen <span>tool <span>of <span>Corel <span>draw<span id="x_x_result_box" lang="en <span>.How do I
<span>do <span>it<span>?
<br/>
View the full article