Display a translucent selection highlight around an image - c#

I have a rectangle with no background and I want to give it a translucent background when the user hovers their mouse over it, and then remove it when the mouse leaves the rectangle.
Is there any sample C# code that shows me how to do this?
I am basically doing an Windows Explorer style image viewer and looking for an identical method of highlighting the image that the mouse is currently hovering over.
Thanks.

Related

Button's background color turns grey when mouse hovering on it C# Winforms

I made a simple design for my WinForms app in Photoshop and I want to make some borderless buttons. In FlatAppearance properties, I changed border size to 0 and the FlatSyle is Flat but when the mouse is hovering on the button, its background color turns to grey, although I changed it to transparent. I'll attach some pics to get the problem better.
Can somebody help me, please?
How I want to look:
how it looks
In the same place that you changed the border size to zero, change the MouseOverBackColor to Transparent:

C# WindowsForms: Reproduce Microsoft control

I would like to reproduce a Control in my WindowsFormsApplication that is equal to the refresh Button of the Windows Network connection form.
Does anybody know which Control it is or how to build a equal one in C#? It seems to be a PictureBox but if you hover it with the Cursor it gets a semi transparent blue colored overlay.
you can use XanderUI for this, add the button, change the button image and change both hover and click background colors to whatever color you like

Bigger mouse cursor in Silverlight

I have a silverlight application in which I have to click on some pictures, if I hover over them for 3 seconds approx.
The problem is that if the pictures are a bit small in size, and the mouse moves a little, it moves out of the respective picture clicking area and selects another picture.
I have tried using a custom image in place of the default mouse cursor, but can this mouse be enlarged in some way so that it has a larger clicking area under it and not only the tip of the mouse pointer?
I think you're thinking about this the wrong way around. The mouse pointer simply defines a coordinate on the screen, rather than an area. If you want mouseover/click etc to be more generous, and give a wider area of interaction, you should make the target area larger.
So in the case of some small image, you can surround it with a larger area to handle the mouseover or click events, for example by surrounding it by a transparent border (note that elements with a transparent background will receive mouse events, unlike elements with no background).

During drag drop, how to show a popup with text(or a cursor with text) that follows the mouse cursor in WPF

I need to show a popup to the user when he is dragging files or items onto my control. The popup basically informs him why dragging is disabled by giving him a message. I would like the popup to follow the mouse cursor whilst he is still in dragging mode.
OR is there a way to change the mouse cursor while dragging and displaying a text alongside the cursor?
If there are any other designs that you guys can suggest.. that would be nice too.
Thanks for your suggestions!
You might finde some suggestions on how to change the cursor here: Custom cursor in WPF?
One suggestion is to draw your popup on a canvas and move it as the cursor moves.

How to make a resizeable rectangle selection tool?

I'm trying to write a very simple photo editor using C# 2008 or QT4.
How to make a resizeable rectangle selection tool like the photoshop did?
If you are talking about the "classic" "rubber band" type of selection rectangle, check out How to draw a rubber band rectangle or a focus rectangle in Visual C#.
WPF Code Example: http://www.codeproject.com/KB/WPF/wpfmarchingants.aspx?display=Print
This one is a bit more complicated because it involves image cropping, but if you scroll down to the selection rectangle, you can see the basic formulas for calculating the rectangle: http://69.10.233.10/KB/WPF/ImageCropper.aspx
Lastly, another one using GDI: http://codelog.blogial.com/2008/10/31/rubber-band-selection-rectangle-in-c/
If you provide more specifics, I'm sure we can help you out more.
Qt has a class for that:
http://doc.trolltech.com/4.5-snapshot/qrubberband.html
I don't know the specific calls, but the idea is this:
You want to draw a transparent rectangle with an opaque or dotted border. The rectangle appears when the mouse button is clicked. While the button is held, the dimension of the rectangle will change as the mouse moves, with the top-left point at the position where the button was clicked and the bottom-right following the mouse as it moves. Releasing the button causes the rectangle to fix its position over the selection area.
You should be able to figure out the particulars from a resource on the C# Drawing namespace.

Categories