开发者

draw multiple curves in WinForms picturebox

I am working on a program which I want to draw diode curves in a WinForms application. I have a list of diode names and I have theire points as you can see at the right side of the picture. That is Voltage as X and Current as Y ( A curve contains like 50 points).

What I want to do is by selecting one or more diodes from the list theire curve show up on my plot. What you see is just a picture box at the moment filled with a bmp. I know that this is not a reliable solution, so I am asking you what can be the best approach to do such thing? I dont know any good compo开发者_如何学JAVAnent which can make me do this. So I just need to know what can be the best approuch for this task?

draw multiple curves in WinForms picturebox

A diode curve is something like:

draw multiple curves in WinForms picturebox

I might have up to 100 of diode curves in my program which all of them (single or multiple) should be drawn by clicking on them in the list.

So what you think?

UPDATE

ALSO important thing is by deselecting a pin in the curve, its curve should be removed from the plot!

I am drawing that axis you see using the code below:

    Bitmap xyCords = new Bitmap(500, 500);
Graphics g = Graphics.FromImage(xyCords);
g.DrawLine(penAxis, 250, 0, 250, 500);
g.DrawLine(penAxis, 0, 250, 500, 250);
curveBox.Image = xyCords;

how is it possible later if I made a new Graphics I append it like:

curveBox.Image += newGraphic;

** Please let me know if there is any component or something which already can do what I want. or else show me a good approach! Thanks!


Try using Graphics.DrawCurve. You just put all of the points you want in an array, and pass that and a pen to the method.

Edit: Add this after your code to prove to yourself that both graphs coexist. To erase one or the other, just plot the same points, but in the background color of the bitmap (test for it, I don't remember what it is).

Point[] ptarray = new Point[3];
ptarray[0] = new Point(250, 250);
ptarray[1] = new Point(300, 300);
ptarray[2] = new Point(350, 400);

Pen pengraph = new Pen(Color.Green, 0.75F);
g.DrawCurve(pengraph, ptarray);

Point[] ptarray2 = new Point[3];
ptarray2[0] = new Point(100, 100);
ptarray2[1] = new Point(200, 150);
ptarray2[2] = new Point(250, 250);

Pen pengraph2 = new Pen(Color.Yellow, 1.25F);
g.DrawCurve(pengraph2, ptarray2);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜