c# - Graphics.Fillrectangle won't update -
i have event-function launches on click , in have graphics instruction
    private void picturebox1_click(object sender, eventargs e)     {         switch (modclick)         {             case 2:                      session.g.fillrectangle(brushes.tomato, mouseposition.x, mouseposition.y, 50, 100);                 break;         }         modclick = 1;     }   when launch program click nothing, if press key (some keys only), changes apply (i can see rectangle). why not updating ? ps : don't worry case instruction.
storing graphics instances in global variables bad idea. make instead:
using (var g = graphics.fromimage(picturebox1.image)) {    g.fillrectangle(brushes.tomato, mouseposition.x, mouseposition.y, 50, 100);    picturebox1.invalidate(); }   the invalidate() call 1 looking for. picturebox can tell changed image property, can't tell changed image content.
Comments
Post a Comment