Executing function based on pointer location - c#

I am working with ArcGIS SDK for dot net. I am programming using vc#. I want to execute a piece of code as soon as the mouse pointer enters a particular longitude/latitude on map or if mouse is clicked on that location. there are many event handlers but I don't know how to retrieve the location the mouse pointer is at. e.g I want to display some picture as soon as mouse pointer is at longitude 25 and lat 33.

Add a MouseMove listener to your MapView.
Your listener method will have a parameter of type MouseEventArgs. Call GetPosition(null) on that parameter to get the screen point.
Use MapView.ScreenToLocation(Point) to get the MapPoint in map coordinates.
If your map isn't in longitude/latitude, use GeometryEngine.Project(Geometry, SpatialReference.Create(4326)) to convert to longitude/latitude.
Check the longitude and latitude to see if they're in the range you want.
I tried posting my source code here but Stack Overflow gave me an error, so here it is as a screenshot:

Related

Getting a "move target out of bounds" exception when trying to click at a specific x and y coordinate

So some weird stuff, could just be im unfamiliar with a specific rule related to the MoveByOffset() method.
So I have the x and y coordinates that I need to move the mouse too, I know they're the right coordinates because I can actually see it happen when my test reaches this line of code:
actions.MoveByOffset(842, 663).Click().Perform();
The problem arises when I interact with a separate element, I click a button to open a drawer to validate some information, Once my script validates what it needs to it closes the drawer and attempts to execute
actions.MoveByOffset(842, 663).Click().Perform(); once again.
I dont scroll or really change anything on the screen other than open a drawer and close it.
But Its at this point where ill get the exception
OpenQA.Selenium.WebDriverException : move target out of bounds
I have it currently in a try catch block and even when I catch the exception it still throws the same exception at me.
Any help or advice or info would be appreciated
MoveByOffset(x, y) means Move By Offset from your current position.
Performing MoveByOffset(xOff, yOff) you move pointer into (currentX+xOff; currentY+yOff).
So first time it is 0+842 and 0+663, second time it is 842+842 and 663+663.
If you need to go to element use moveToElement().
To be sure you don't reach bounds of viewport you can use something like driver.manage().window().getSize().
it is Java code, but I believe c# has such operators.

HOW to get LOW touch point argument for each touch point in UWP by C#

I need to filtrate touch point in an UWP app. I need to filtrate touch point according to timestamp of a touch point, and get coordinate or id of the touch point.
In a WPF application , I can get necessary data of touch point by using TouchFrameEventArgs class, and using the method GetTouchPoints().
But, In UWP app, what should I use? I want to get the first occurred touch point after a specific event occurs.
First, generally speaking, touhc, mouse and pen input in UWP is abstracted to a single event set dealing with pointers.
When you handle a pointer event like PointerDown, you get an instance of PointerRoutedEventArgs class. This class will help you identify a specific pointer using the Pointer.PointerId property. This a unique identification you can use to check for the pointer that raised this event. You can store the pointer IDs you have encountered in time which should provide you with the behavior you are requesting.

Is it possible to use Interop to select text in a Powerpoint TextFrame by location (top and left offset)?

I'm attempting to automate the basic process of editing text in a TextFrame in Powerpoint via Interop, and I've hit a snag. I need to be able to begin the text editing process at a particular location on screen, and after crawling MSDN I still don't know of a way to do it. The use case boils down to this:
My service receives an X and Y coordinate
I tell Powerpoint to select the shape at that location
I tell Powerpoint to place the blinking cursor at the location it would be if the user had clicked there himself to start editing text.
It's the third step that's tripping me up. Word has RangeFromPoint, which returns a text range. In Powerpoint, though, that method returns a shape. I can use TextRange.Characters() to place the cursor manually within the shape's text range, but that accepts character index values rather than screen coordinates.
Anyone know how to go about this (other than brute forcing in mouse messages via Win32 calls)?
Every bit of text, down to the character level, can be treated as a Range; every text range has .BoundLeft, .BoundTop, .BoundHeight and .BoundWidth properties that return the coordinates of a rectangle that bounds the text range.
For example, this snippet will give you the left coordinate of the third text character in the currently selected shape:
With ActiveWindow.Selection.ShapeRange(1)
Debug.Print .TextFrame.TextRange.Characters(3, 1).BoundLeft
End With
Coordinates are returned in Points. It sounds like you already have a handle on converting screen coordinates to PPT coordinates.

Mouse.GetPostion(null) Equivalent in WinRT

What would be the equivalent for Mouse.GetPostion(null) which is in WPF.
I can get the position of pointer from the pointer event args. but how do i get the position without any event. like "Mouse.GetPostion(null)" in WPF. where mouse is a static class.
Any idea?
There is a PointerPoint.Position property - PointerPoint is a general input abstraction that also inludes touch and stylus input so you have to get a focus on mouse input first - this can be done with a static
PointerPoint PointerPoint.GetCurrentPoint(uint pointerId)
method where pointerId is a system generated number identifying the input device. I don't know if there is any other way but you can get the mouse PointerId through
PointerRoutedEventArgs.Pointer.PointerId
if you handle some mouse Pointer event like PointerPressed or PointerReleased first.

Is there an updated version of OpenTK documentation?

I'm developing a multiplataform application using C# and mono. For OpenGL bindings I'm using OpenTK. I was looking at their "getting started" tutorial on Input: http://www.opentk.com/doc/input, and found this:
Use Mouse.GetState() to retrieve the aggregate state of all connected mice.
Use Mouse.GetState(int) to retrieve the state of the specified mouse.
To check whether a button is pressed:
using OpenTK.Input;
var mouse = Mouse.GetState();
if (mouse[MouseButton.Left])
{
// Left mouse button is pressed
}
I used that code snippet and got a compile time error, saying that Mouse doesn't contain a method definition for GetState(). And I downloaded the most recent version of OpenTK
So, are there any updated resources to get started with OpenTK?
Mouse.GetState doesn't have an overload with 0 parameters, you have to pass in an int (0 should get you the first mouse connected to the computer). This is true only for the last stable release, if you download the latest SVN nightly build, it contains both methods.
And just as a tip, the aggregated state of all mice will say that the left mouse button is clicked if any of the connected mice have the left mouse button clicked, and the mouse coordinates will be different from screen coordinates if you have more than one mouse connected.

Categories

Resources