get pointer position - c#

I want to make a small box that will be visible after PointerEntered event on bing map. I need to get the position of pointer when the pointer is over the pushpin. Everything works but I can't get the position. I need it so I can dynamicly show the box in correct place near the pushpin.
How can I get cursor/pointer position ?

I don't think it's a good idea trying to rely too much on pointer position in Windows Store apps. Don't forget about your touch based users - how are you going to determine the pointer position in their case?
I haven't used Bing maps and pushpins in a Windows Store app yet, but maybe you could try using tooltips instead. They already have built-in support for both touch based and mouse based control and they even position themselves automatically in such a way that the user doesn't obsure them with his finger.

Related

Remove Bing OnTouch event

I will attempt to describe my problem.
I am creating a simple map application that plots the location of my home.
I would like to be able to press a button that LOCKS the screen so the map cannot scroll.
I currently have everything working, the only problem is I cannot figure out how to remove the OnTouch event that currently Pans/Zooms the map. I am using BING API with C#/XAML.
Does anyone know how to prevent the touch events from panning or moving about the map?
You can store the map center and zoom values when the lock button is pressed and then use the view change event to set the maps center and zoom to these values. This will cause the map to lock.

Restrict cursor to a UI Element in Silverlight

I am working on a silverlight application that has to capture electronic signature from user as a part of it's functionality. I was able to build a PoC based on Silverlight Ink Presenter control, when the page renders I have designated a rectangular region into which user has to input his signature.
This absolutely works like a charm, but, I wsa not able to restrict pointing device to rectangular region so it can currently go out of the region irritating the user. User has to get it back to the rectangular region to input his signature. I would like to know if there is a way to restrict cursor to a rectangular region of the web page.
Something similar to "Cursor.Clip" of Windows.Forms
Any help is highly appreciated.
Try designing your own cursor as the pointer enters the region and hide the pointer. Set the bounds of the custom cursor to stay with int rectangle
here's a link for custom cursor
custom cursor
Only problem is as you move it along with the mouse pointer then mouse pointer can move out but this cursor wont. Rest of the code you need to modify so that user sticks to the particular edges

Custom mouse cursor size in WPF

We are developing an application that must be used by people that may have some visual problem involving the use of kinect to move the cursor, so we need to make it bigger than usual. However, this application does not interfaces directly with kinect, so we can't use its APIs.
We are programming in C# (.NET 4.5) using WPF. The problem is that the default cursor size cannot be bigger than 32x32 pixel or 64x64 pixel in high res devices.
We first tried to make the actual mouse cursor invisible and then use a Graphics object, taken using Graphics.FromHwnd(applicationWindowHandler). It succeeds to draw the image but it leaves the trail of the past cursor positions.
Is there a way to do using the regular windows mouse cursor, or at least a way to remove the trail (like an "invalidate" method that force the current window to refresh)?
We already tried these solutions but with no luck:
www.hsys.com/CustomCursorArticlePart1.htm
www.hsys.com/CustomCursorArticlePart2.htm
csharparticles.blogspot.it/2005/03/custom-drawing-cursors.html
Couldn't you just use a Canvas control that covers the entire window, set the cursor to none and then put an Image control with a suitably large cursor image in the Canvas, with its Left and Top properties bound to the cursor's X and Y coordinates relative to the Canvas??

Default system mouse pointer

Is there a way I can change the default system mouse pointer from within my application and change it back to the original scheme when I want to?
You can use the Cursor class to create a custom cursor, and you can set the mouse pointer to use that cursor while it's over your application.

Building a MVVM 3D Editor Application -> Getting Mouse Position?

In my 3d editor application, I want to be able to click on and move a scene's entities (meshes, lights, cameras, etc). To do that, I imagine that I need to get the current mouse position relative to my Direct3d view and somehow give it to my ViewModel. How would I go about doing that, considering that my app is built with the MVVM pattern?
Additional Info: The Direct3d renderer is from a C++ DLL and we're using an HwndHost to place it inside our WPF app. It has a WndProc which I imagine I could use to handle mouse messages there but I'd rather avoid it if at all possible.
Thanks!
The best solution I found is to use an attached behavior. In the control that serves as the placeholder to the HwndHost I set an attached property, like
b:MouseBehavior.LeftClick="{Binding DoSomeActionCommand}"
where MouseBehavior receives the control and sets mouse events on it.
It works well for me.
InputManager.Current.PrimaryMouseDevice is probably your best bet.
you can get the mouse position with
Mouse.Position( RelativeToObject ); // get the mouse pos relative to an object
Mouse.Position( null ); // get the mouse pos relative to the whole screen
if thats not good enough, you can use Win32 calls.

Categories

Resources