Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Erasing lines

Erasing lines

Scheduled Pinned Locked Moved C#
graphicshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CoolASL
    wrote on last edited by
    #1

    Hi all, I am making an application, where i need to keep drawing and erasing lines over an image. Drawing lines is ok, but i am not able to find any suitable means to remove those lines. One method could be to draw on the same line using some other color, but that method is unsuitable since i am drawing it over an image.:( Another method could be to send the Paint event so as to refresh the frame. But since i am drawing and removing the lines quite frequently, i dont think it will be a good idea to call the paint method so many times. Can anyone please suggest a more efficient method?:confused: Any help will be highly appreciated. Thanks in advance.:cool: *** Who said nothing is impossible? I have been doing it for a long time ***

    R 1 Reply Last reply
    0
    • C CoolASL

      Hi all, I am making an application, where i need to keep drawing and erasing lines over an image. Drawing lines is ok, but i am not able to find any suitable means to remove those lines. One method could be to draw on the same line using some other color, but that method is unsuitable since i am drawing it over an image.:( Another method could be to send the Paint event so as to refresh the frame. But since i am drawing and removing the lines quite frequently, i dont think it will be a good idea to call the paint method so many times. Can anyone please suggest a more efficient method?:confused: Any help will be highly appreciated. Thanks in advance.:cool: *** Who said nothing is impossible? I have been doing it for a long time ***

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Repainting is generally a good idea. Just implement your OnPaint method the way that a flag indicates whether the lines should be drawn or not. Everytime you switch between on and off just switch the flag and call Invalidate on your control. This will lead to a repaint (and also avoid too many repaints). If your are switching frequently you should enable double buffering to avoid flickering: (in constructor) base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true);

      C 1 Reply Last reply
      0
      • R Robert Rohde

        Repainting is generally a good idea. Just implement your OnPaint method the way that a flag indicates whether the lines should be drawn or not. Everytime you switch between on and off just switch the flag and call Invalidate on your control. This will lead to a repaint (and also avoid too many repaints). If your are switching frequently you should enable double buffering to avoid flickering: (in constructor) base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true);

        C Offline
        C Offline
        CoolASL
        wrote on last edited by
        #3

        Hey thanks Robert! I havent tried that yet, but will surely do when i get out of my office. Thanks a lot. I'll get back to you if i bump into any more problems. Thanks again. *** Who said nothing is impossible? I have been doing it for a long time ***

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups