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).
Related
So I tried building my game, but I saw that the objects that were set on a panel didnt keep their position. If I click on max window size then the objects move away from their original position. How can I solve this? (see images for extra info)
You should set ui elements' anchor position
For example my Restart button is in top-left place. When screen size change, it doesn't change position. To do this, click your ui object, click anhcor-presets section, press alt key and select a position which you want.
Also, Canvas scale may help you for resizing ui objects,when you change screen size
Basically I have a MouseDown event where I move the window. I want to be able to snap my WPF app to the nearest screen corner by a certain threshold (i.e. 20 pixels), not just a screen edge but the nearest corner.
Which events should I use to accomplish this? I saw some articles but they seem overkill that are subclassing the Window class, etc.
I know I will loop through every corner of the screen and every corner of my app window but I am not sure which events I need to use and which property of the WPF Window gives me the exact coordinates of the window extents.
We can get the location of the screen by SystemParameters.WorkArea.Width(x1) and SystemParameters.WorkArea.Height(y1),and you window's size are this.width(x2) and this.Height(y2).So,we get the four location of corners:(0,0),(x1-x2,0),(0,y1-y2),(x1-x2,y1-y2).
Then,we can use the MouseLeftButtonUp and down event of the window,i tried that but only I clicked in the window it worded.Moving the window when clicking the title bar of it can't trigger event.I thick maybe we can Customize the title bar and write the event in it's MouseLeftButtonUp and down.
I want to be able to drag around a 100% zoomed picture in a picturebox: http://spunit.tk/x/dragpic1.png.
I want it to work exactly like the Windows Photo Viewer: http://spunit.tk/x/dragpic2.png.
How is this possible?
I believe you need to maintain the coordinates of that picturebox, also set its view style to full-image, without any stretching.
Then, you will need three mouse events: mouse down, mouse up and mouse move, where you can get the mouse coordinates and capture or release mouse to translate the picture box according to mouse delta translation.
I want measuring tool in project that will be same as measure it in Firefox (add-on). How to do this?
To get such a think to work you'll need an application that runs as a tray icon or something like that. Then you open your application and tell him, that you'd like to measure.
Now, you'll go and put a transparent window onto the whole screen(s) and wait for a mouse move event. Within the mouse move event, you'll check the mouse button state. If it is going to be hit you know the starting position and you can draw some kind of user-control at this position and if the user releases the mouse button, you're going to stop the resizing of your user-control.
The user-control itself should be semi-transparent and checking for the resizing and/or paint events, to draw the ruler lines around the border.
Last but not least you can show some kind of tooltip or labelcontrol in relation to the position and size of your user-control and screen bounds to give some status informations.
To get a good starting point about how to get the transparent overlay part done, you can take a look into ObjectListView Overlay.
--EDIT--
One solution could be:
Create a separate transparent windows form
Upon certain key press, for instance Ctrl+Shift+R, show your app with lower transparency level; so that user can see the background.
Draw ruler upon form load
You may allow user to move the ruler window with mouse click.
I am developing a small application with images and trash box icon on right hand bottom.
I have multiple images floating in the main window, and using mouse I can move image from one corner to other corner of window, left, right, top and bottom.
I can't figure out how do I catch an event when a image touches and panel (with trash box image), in the right hand corner.
Does anybody knows which event or handler to listen? This is not a drag and drop case since my images are floating so no point using drag and drop.
Thank you
Per this thread (MSDN), you could listen to an event fired when your image moves, and get Rects representing the trash box and the image, then use the IntersectsWith() method to detect if they are "touching".
Other than that, there are the UIElement events DragEnter, DragOver, and Drop (as well as their Preview___ counterparts) which might fit the bill. However, those are part of drag-and-drop. I'm not convinced that drag-and-drop is not appropriate in this situation. It sounds like drag and drop to me.