Image Click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a image(.jpg file) which contains the skin of a remote control.
The idea is to develop an remote control application in my Pocket PC.
Now I want the buttons in the image has to handle the click events. The remote control image contains the ellipse and circle shaped buttons.

Kindly help me by giving the idea to implement this.

Thanks in advance.

-kamal
 
The idea for you is to develop a "hit test" method that'd identify that the
user tapped in the certain area of your image.
There're different algorithms exist to handle that. In your case you'd
probably need to combine a region hit-testing with the color test.

--
Alex Yakhnin .NET CF MVP
www.intelliprog.com | www.opennetcf.org

kamal said:
I am using a image(.jpg file) which contains the skin of a remote control.
The idea is to develop an remote control application in my Pocket PC.
Now I want the buttons in the image has to handle the click events. The
remote control image contains the ellipse and circle shaped buttons.
 
Kamal:

In addition to Alex's post, you can wire in a click event for a Picture box,
so if you broke out the pictures of the buttons into seperate images, you
could put them on top of the background image and just handle the click
event directly. There are many controls that you can wire in a click event
for for instance and they'll compile, they just won't do anything. Witha
picturebox fortunately you can. You can also add the files as embedded
resources, set their build action to Embedded Resource, then reference them
directly in your project without having to worry about adding them to your
setup project. This may or may not be helpful depending on how you
implement it.

Anyway, to wire in an event, just go ahead and add it,
(assuming your picture was named picPlay:
this.picPlay.Click += new System.EventHandler(this.picPlay_Click);

write your handler:
private void picPlay_Click(object sender, System.EventArgs e)
{
//Do something
}

And if you choose to referece embedded resources:

private Bitmap GetImage(ImageName i)
{
try
{
switch(i)
{
case ImageName.RecordDisabled:
return new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResource
Stream("MySolution.ResourceName.jpg"));
////the rest is just the closing parts of the top
HTH,

Bill

kamal said:
I am using a image(.jpg file) which contains the skin of a remote control.
The idea is to develop an remote control application in my Pocket PC.
Now I want the buttons in the image has to handle the click events. The
remote control image contains the ellipse and circle shaped buttons.
 
Dear Ale
I think other than datagrid control no control has the Hit Test method. I may be wrong. If u have have any sample code on this please give me which will be more useful for me

Dear William
I have already tried the method you have told but the problem is if I have a ellipse image in the picture box, the click event also occurs outside the ellipse i.e in the rectangular form
 
Back
Top