Click here to Skip to main content
15,891,473 members
Home / Discussions / C#
   

C#

 
AnswerRe: Graphics Pin
Christian Graus20-Dec-05 18:37
protectorChristian Graus20-Dec-05 18:37 
GeneralRe: Graphics Pin
Mahi.Ragava20-Dec-05 19:23
Mahi.Ragava20-Dec-05 19:23 
GeneralRe: Graphics Pin
Mahi.Ragava20-Dec-05 19:40
Mahi.Ragava20-Dec-05 19:40 
GeneralRe: Graphics Pin
microsoc20-Dec-05 21:47
microsoc20-Dec-05 21:47 
GeneralRe: Graphics Pin
Mahi.Ragava21-Dec-05 18:01
Mahi.Ragava21-Dec-05 18:01 
GeneralRe: Graphics Pin
microsoc21-Dec-05 18:13
microsoc21-Dec-05 18:13 
GeneralRe: Graphics Pin
Mahi.Ragava21-Dec-05 18:56
Mahi.Ragava21-Dec-05 18:56 
GeneralRe: Graphics Pin
microsoc21-Dec-05 19:50
microsoc21-Dec-05 19:50 
i try to run what you've got and figured out what the cause of your problem...
It's because you didn't store the previous lines coordinates to a collection or array.
and because you call the Invalidate method,this will repaint the whole control that means it will clear all what you've drawn before.

so my solution was to put the coordinates in an arraylist and loop it on the OnPaint method. i used this on a simple form and it works fine. Smile | :)

here's the code
<br />
                //declaration<br />
		private ArrayList m_arlPoint1 = new ArrayList();<br />
		private ArrayList m_arlPoint2 = new ArrayList();<br />
<br />
		protected override void OnPaint(PaintEventArgs e)<br />
		{<br />
			base.OnPaint(e);<br />
                        //you don't need to creategraphics and attach a handler of Paint event if you'll override this method. (just a tip) :)<br />
<br />
			Pen pen=new Pen(Color.Magenta);<br />
			Point pt1, pt2;<br />
			for (int i = 0; i < m_arlPoint1.Count; i++)<br />
			{<br />
				pt1 = (Point)m_arlPoint1[i];<br />
				pt2 = (Point)m_arlPoint2[i];<br />
				e.Graphics.DrawLine(pen, pt1, pt2);<br />
			}<br />
                        <br />
                        //i think you don't need this one<br />
                        //this.ResetMouseEventArgs(); <br />
		}<br />
<br />
		<br />
		protected override void OnMouseUp(MouseEventArgs e)<br />
		{<br />
			m_arlPoint2.Add(new Point(e.X, e.Y));<br />
			Invalidate();<br />
		}<br />
		protected override void OnMouseDown(MouseEventArgs e)<br />
		{<br />
			m_arlPoint1.Add(new Point(e.X, e.Y));<br />
		}<br />
<br />


hope this will solve your problem! Smile | :)
GeneralRe: Graphics Pin
Mahi.Ragava21-Dec-05 20:05
Mahi.Ragava21-Dec-05 20:05 
GeneralRe: Graphics Pin
Mahi.Ragava21-Dec-05 20:13
Mahi.Ragava21-Dec-05 20:13 
GeneralRe: Graphics Pin
microsoc21-Dec-05 20:41
microsoc21-Dec-05 20:41 
GeneralRe: Graphics Pin
microsoc21-Dec-05 20:20
microsoc21-Dec-05 20:20 
GeneralRe: Graphics Pin
Mahi.Ragava21-Dec-05 22:32
Mahi.Ragava21-Dec-05 22:32 
QuestionIs this the right PInvoke? Pin
eggie520-Dec-05 15:31
eggie520-Dec-05 15:31 
AnswerRe: Is this the right PInvoke? Pin
leppie21-Dec-05 4:18
leppie21-Dec-05 4:18 
GeneralRe: Is this the right PInvoke? Pin
eggie521-Dec-05 13:45
eggie521-Dec-05 13:45 
QuestionHandling Nullable Types in .NET 1.1? Pin
RobertF5720-Dec-05 15:17
RobertF5720-Dec-05 15:17 
AnswerRe: Handling Nullable Types in .NET 1.1? Pin
Michael Ceranski20-Dec-05 15:34
Michael Ceranski20-Dec-05 15:34 
GeneralRe: Handling Nullable Types in .NET 1.1? Pin
RobertF5721-Dec-05 6:59
RobertF5721-Dec-05 6:59 
GeneralRe: Handling Nullable Types in .NET 1.1? Pin
RobertF5721-Dec-05 11:55
RobertF5721-Dec-05 11:55 
GeneralRe: Handling Nullable Types in .NET 1.1? Pin
Michael Ceranski21-Dec-05 14:37
Michael Ceranski21-Dec-05 14:37 
GeneralRe: Handling Nullable Types in .NET 1.1? Pin
RobertF5728-Dec-05 8:36
RobertF5728-Dec-05 8:36 
QuestionImplementing Delete Pin
monrobot1320-Dec-05 14:35
monrobot1320-Dec-05 14:35 
AnswerRe: Implementing Delete Pin
Curtis Schlak.20-Dec-05 15:54
Curtis Schlak.20-Dec-05 15:54 
GeneralRe: Implementing Delete Pin
monrobot1320-Dec-05 19:19
monrobot1320-Dec-05 19:19 

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.