locked
Windows 8.1 store app c# get X,Y of double tap

    Question

  • Guys

    I'm trying to get the X,Y cords of a double tapp on an image

    My image is called imageview and it is inside a scrollview so that I can pinch and zoom in

    I use the follow on the double tap event of the image

    private void imageview_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
            {
                var point = e.GetPosition(imageview);
                var p1 = point.X;
                var p2 = point.Y;
                string stringVal1;
                string stringVal2;   
                stringVal1 = System.Convert.ToString(p1);
                stringVal2 = System.Convert.ToString(p2);
                pageTitle.Text = stringVal1 + " - " + stringVal2;
                        }

    This prints the x,y cords in the pagetitle

    problem is it prints the xy cords in relation to the screen. My image is 6000 x 4000 so if I double tap in the bottom right of the screen it should print 6000 - 4000 instead it prints 900 - 600 which is the size of my scrolview

    I need this so that when i zoom in it always gives me the cords in relation to the image so i can detect when and area of the image is tapped no matter what zoom level im at

    Any ideas?

    Mark

    Thursday, January 29, 2015 6:32 PM

Answers

  • Hi,

    I think the link below can help you:

    http://www.codeproject.com/Articles/20923/Mouse-Position-over-Image-in-a-PictureBox

    when the image zoom, the image is scaled evenly across axis in such a way that the entire image is displayed in the control, centered when appropriate. To manage this method, we first need to determine what our limiting dimension is (height or width). After that, we need to determine the padding and the scaling to be applied to the point.I think this is the same in the windows store app.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.


    Tuesday, February 3, 2015 6:49 AM

All replies

  • Hi,

    GetPosition Method means:

    Gets the position of the mouse relative to a specified element.

    https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.input.tappedroutedeventargs.getposition

    If you set the tapped event to image, the xy cords in relation to the image not screen. You get 900-600 cords when you double tap in the bottom right of the screen because image in scrollview, and the image content does not fully display. If you scroll the scroll vertical and horizontal bar to the end and then tap the bottom right of the screen, the  xy cords will be  6000 - 4000.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Friday, January 30, 2015 6:54 AM
  • Hi Anne

    Sorry for my ignorance but that doesn't seem to be the case in my instance

    The image is stretched so I see the whole image in the scroll view so although the image all 6000x4000 of it is shrunk to show in the scroll view which is 900 x 600

    What I need is for the coordinates to be got are the coordinates on the image no matter what the zoom is

    I know its possible because i did have it a few years ago but lost the code since coming back to windows

    Your help is greatly appreciated

    Mark

    Friday, January 30, 2015 9:05 AM
  • Hi,

    I think the link below can help you:

    http://www.codeproject.com/Articles/20923/Mouse-Position-over-Image-in-a-PictureBox

    when the image zoom, the image is scaled evenly across axis in such a way that the entire image is displayed in the control, centered when appropriate. To manage this method, we first need to determine what our limiting dimension is (height or width). After that, we need to determine the padding and the scaling to be applied to the point.I think this is the same in the windows store app.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.


    Tuesday, February 3, 2015 6:49 AM