jeudi 30 juillet 2015

Draw/delete (show/hide) specific lines on checkbox C# winForms Graphics

I created an app in C#, windows forms where I draw all my objects on panel. I created grid, lots of lines, rectangle, filled elipses etc...

I want to create checkbox where I can control which lines should be shown and when. For instance if checkbox is checked, show lines and if it is not checked, hide them or remove them from panel.

How to do this? I can only delete all objects from panel, not specific ones... How to iterate through program since there are no ID's?

Example how the objects are added.

e.Graphics.DrawLine(pen, x1, y1, x2, y2);

e.Graphics.FillEllipse(Brushes.Red, x1, y1, 10, 10);

Is there a way to group them somehow? I could rewrite whole code just with/without lines I want but since there is alot of code that's not a great idea.




Aucun commentaire:

Enregistrer un commentaire