c# - Create Microsoft Mouse and Keyboard style selection -


i'm making application relating key bindings - hence wish take image of mouse, , overlay outline of button on said mouse show key (i wish controllers , keyboard, should same doing mouse)

effectively, i'm going akin microsoft mouse , keyboard program:

enter image description here

the mouse cursor cannot seen in image, on right mouse button - hence selected / highlighted both whole button , binding.

i understand c# / visual studio might not best way this. i'm not wanting majorly fancy. in fact, being able overlay 1 image on other , detect mouse on fine.

what's way, or way can this, preferably without having code directly? ( i.e being able place , position in designer, coding visibility , rest )

i have tried use visual basic powerpacks graphics, seem offer basic pre-defined shapes (in case used rectangles) , looked out of place when put on top of mouse buttons

i have tried using image box 2 images (as per hans passant's suggestion) not image box take account transparency of image

use pictureboxes. can place them @ design time, , have events mouse over, click etc. on specific mouse action change image of it. in example set null, idea:

    image picimage = null;  // store original image           private void picturebox1_mouseleave(object sender, eventargs e)     {         picturebox1.image = picimage;   // rest original image     }      private void picturebox1_mouseenter(object sender, eventargs e)     {         picimage = picturebox1.image;   // remember original image         picturebox1.image = null;   // change current image     } 

update:

ok, have pixel perfect selection use 2 pictureboxes in same location, 1 showing unselected image (picturebox1), 1 showing selected image (picturebox2). make picturebox1 invisible. use code show/hide them when mouse hovers on transparent/nontransparent areas of image:

private void picturebox1_mousemove(object sender, mouseeventargs e) {     bitmap b = new bitmap(picturebox1.image);     color color = b.getpixel(e.x, e.y);      if (color.a != 0)     {         picturebox1.visible = false;         picturebox2.visible = true;     } }  private void picturebox2_mousemove(object sender, mouseeventargs e) {     bitmap b = new bitmap(picturebox1.image);     color color = b.getpixel(e.x, e.y);      if (color.a == 0)     {         picturebox2.visible = false;         picturebox1.visible = true;     } } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -