0

I have an image and i am panning it after zooming, on panning horizontally, image gets moved leaving white space at the left. I want to restrict when the image left bounds has reached. Same thing for top, right, bottom panning.

Panned image Expected output

     private void Grid1_MouseMove(object sender, MouseEventArgs e)
    {
        if (!image1.IsMouseCaptured) return;

        Point p = e.MouseDevice.GetPosition(image1);

        var rect2 = new Rect(image1.RenderSize);
        Bounds = image1.TransformToAncestor(grid1).TransformBounds(rect2);

        matrix = zoomMatrixTransform.Matrix;
        Vector v = start - e.GetPosition(grid1);

        matrix.OffsetX = origin.X - v.X;
        matrix.OffsetY = origin.Y - v.Y;

        zoomMatrixTransform.Matrix = matrix;

        image1.RenderTransformOrigin = new Point(0.5, 0.5);
        image1.LayoutTransform = zoomMatrixTransform;
    }

I have attached the panned image and i want to restrict the red highlighted area. Also attached the expected output.

  • You would obviously have to calculate the transformed bounds and check if they exceed any limits. Then adjust the panning offset accordingly. As a note, it seems pointless to set RenderTransformOrigin if you don't set RenderTransform. – Clemens Oct 22 '19 at 07:25
  • @Clemens Thank you. Can you please share your idea on the below query https://stackoverflow.com/questions/58334133/how-to-get-the-zoomed-image-bounds – yogapriya shanmugam Oct 23 '19 at 10:58

0 Answers0