If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hotspots in .Net

Hi All

I am creating a Windows based application, my main screen is based on a picture, instead of using buttons, I would like to create hotspots on the picture for navigation, is this possible in the .net Windows application, this is not for the web.

Re: Hotspots in .Net

You can load an image directly onto a form, or onto a picturebox control. Then, you can capture mouse clicks, and compare the location to 'spots' that you activate, and fire in the 'click event' and produce the action.

Re: Hotspots in .Net

Hi dglienna

Thanks for the reply. unfortuantly I am not exactly clear on what you mean. Do you mean have a set of cordinates for each area, then take the position of a mouse click and check if it is within a set of coordinates, if it is then fire a click event? If this is the case just got a couple of questions, how do I set up a coordinate location for an area on a picture and secondly how would I do this for complex shapes such as circles, ect?

Re: Hotspots in .Net

It is going be a bit more complicated if you are using irregular shaped hotspots.

Using the mouseup event will give you coordinates clicked in the picbox. You will need a way to determine which region the clicked coordinates are in.

Rectangular and circular regions should be relatively easy. I would create a class for your regions containing the following vars: region_type (enum), parameter1, parameter2
region_type specifies whether the region is circular or rectangular. If circular, parameter1 is midpoint of circle and parameter2 is radius. If rectangular, parameter1 is upper left corner and parameter2 is lower right.

You will need a routine that accepts your coordinates, checks through your regions and calls the appropriate function (this could happen in the region class if you do it that way).

ps: have you looked at WPF ? I think this can be done on a WPF form.

Last edited by HairyMonkeyMan; December 22nd, 2008 at 05:40 AM.

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook

Re: Hotspots in .Net

IF you control the picture, there is a simple trick...Use the LSB of each color. This allows for 7 hotspots in an impage without ANY calculations.

Stegography in action!!!!

TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010In theory, there is no difference between theory and practice; in practice there is.

* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first

Re: Hotspots in .Net

Use a 24/32 bit format. Make sure the "real" picture has only EVEN color values (LSB or R,G,B are 0.)

Now modify the picture to the the LSB to 001,010,011,100,101,110,111 (R,G,B) for seven different areas.

Now when you geta click, look at a the pixel. Grab the LSB of R,G,B; combine. If 000 then not a hotspot, otherwise it is one of the 7...

TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010In theory, there is no difference between theory and practice; in practice there is.

* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first

Re: Hotspots in .Net

Here...

This blue picture is primarily made op of one color, with EVEN R,G,B values...

Some of the pixels had had 1 lsb added to one or more of the colors.

TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010In theory, there is no difference between theory and practice; in practice there is.

* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first

Re: Hotspots in .Net

TheCPUWizard, the solution is of course interesting. But how maintainable is it? Altering the background image on pixel level, at least for me, is a tedious task . Also, scalability is a factor to consider.

Since you're using .NET, I suggest using one of the windows forms skinning techniques out there, or even create a HTML page, with regions, and place a web browser control on your form.
Personally, I would go with skinning.

Re: Hotspots in .Net

Maintaining the pictures is not a problem..IF you have a decemt layer based graphic editor. The primary advantage is that all of the information is contained in the image itself.

--- If you need more hotspots, use 2 LSB, this give you 63 distinct ones on a single image.

--- Alternatively, supply TWO images, one which you display and ony (often just 8 bit resultion) where each color in the second represents a different hotspot.

I use this technique heavily becuase I am NOT a graphic designer, and outsource all my work [shameless plug: My eldest daughter graduated last year from university with a degree in graphic arts..].

Most other techniques involve a tighter coupling beteween the visual information and the coding....

TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010In theory, there is no difference between theory and practice; in practice there is.

* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first

Re: Hotspots in .Net

So, that means you change all pixels within the 'hotspot' so that you know when you're in the 'hotspot'

Exactly. Not that this will NOT work with "lossy" compressed formats like jpeg).

That would be hard to resize, I'd imagine...

The two-image idea sounds a lot better. You could resize only the visible image, and scale the mouse-clicks

Resizing (regardless of methodology) does introduce some difficulty. In most cases a little "fuzzyness" in the determination may be acceptable, but in others it can be a problem.

TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010In theory, there is no difference between theory and practice; in practice there is.

* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first