Sunday, 15 April 2012

winforms - Converting a list of Points to an Array in C# -



winforms - Converting a list of Points to an Array in C# -

i'm trying create simple paint programme in c# using windows forms application. when converting list of points array using toarray function, i'm getting generic "argumentexception unhandled: parameter invalid" error. know i've done before , it's worked fine, there special drawlines function i'm not aware of? below code, line in question beingness lastly line in panel1_paint event. in advance help can provide.

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace getsig { public partial class form1 : form { bool paint = false; list<point> mypointlist = new list<point>(); private void panel1_mousedown(object sender, mouseeventargs e) { paint = true; } private void panel1_mousemove(object sender, mouseeventargs e) { if (paint) { mypointlist.add(e.location); panel1.invalidate(); } } private void panel1_mouseup(object sender, mouseeventargs e) { paint = false; } private void panel1_paint(object sender, painteventargs e) { e.graphics.drawlines(pens.black, mypointlist.toarray()); } } }

well, can't draw lines without @ to the lowest degree 2 points :)

if (mypointlist.count >= 2) { e.graphics.drawlines(pens.black, mypointlist.toarray()); }

c# winforms list paint

No comments:

Post a Comment