views:

357

answers:

2

In a WinForms application, I need to be able to interactively edit "hot" areas on top of an image, later to be used as a sort of image map.

I tried to rig together an UserControl with some floating rectangles (Microsoft.VisualBasic.PowerPacks ftw) on top of a PictureBox, but the result wasn't all that pretty, especially with flickering and refresh problems when the controls are moved.

Does anyone happen to know of an existing control that would help with defining areas on a canvas? I'm thinking that graphics applications, for example, need to deal with floating selections a lot, but I couldn't track down anything of use. Any ideas appreciated.

+1  A: 

Sticking with your current solution for the moment. Your flickering could be a result of you not enabling double-buffering!

With double-buffering enabled, most (if not all) of your flickering should disappear.

In your InitializeComponent of both the custom control and the form:

this.SetStyle(ControlStyles.AllPaintingInWmPaint |
              ControlStyles.UserPaint |
              ControlStyles.DoubleBuffer,true);

Much more information available in this article.

Ray Hayes
Lacking a better solution, I'm stuck with my solution anyway, but thank you for the double buffering tip!
Tiberiu Ana
+2  A: 

I have such a control ... with no designer support

There is one small bug (very intermittent) that I have not yet worked around, but it lies somewhere deep in the BCL. If you would like a copy, drop me a mail (via www.sadeveloper.net), and I will send you a copy on two conditions.

  1. standard immunity from any and all effects, no liability for any damages, incidental or otherwise ....
  2. if you find the bug and fix it, you let me know how

MaLio

MaLio