Page 1 of 1

zoomselection

Posted: Mon Feb 20, 2012 12:54 pm
by MichaelHerrmanns
Hello,

I want to use to zoomselection feature.
If an user doubleclick on the image a rectangle with mousepoint as centre should be zoomed.

Code: Select all

Private Sub InteropUserControl_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AnnotationViewer1.DoubleClick
        Dim eMouse As MouseEventArgs

        If AnnotationViewer1.SelectionMode = Vintasoft.Annotation.SelectionMode.AnnotationView Then
            eMouse = DirectCast(e, MouseEventArgs)
            If _zoomSelection Is Nothing Then
                _zoomSelection = New ZoomSelection(_imageViewer)
            End If
            AnnotationViewer1.VisualTool = _zoomSelection
            _mouseX = eMouse.X.ToString
            _mouseY = eMouse.Y.ToString
            _zoomSelection.Rectangle = New Rectangle(CInt(eMouse.X - 300), CInt(eMouse.Y - 200), 600, 400)
            _zoomSelection.Zoom()
        End If

    End Sub
But never the zoom appears on the selected recangle or the rectangle not created on the place the user has clicked.

Any suggestions?

best regards

Michael

Re: zoomselection

Posted: Tue Feb 21, 2012 2:43 pm
by Alex
Hello Michael,

You need to use the following code:

Code: Select all

private void ZoomAfterDoubleClick()
{
    ...
    ImageViewer1.DoubleClick += new EventHandler(ImageViewer1_DoubleClick);

    ImageViewer1.Images.Add(Path.Combine(WorkDir, "testimage.tif"));
    ...
}

void ImageViewer1_DoubleClick(object sender, EventArgs e)
{
    MouseEventArgs eMouse;
    eMouse = e as MouseEventArgs;

    Point pointOnImage = imageViewer1.PointToImage(eMouse.Location);

    ZoomSelection selection = new ZoomSelection(ImageViewer1);
    ImageViewer1.VisualTool = selection;

    selection.Rectangle = new Rectangle(pointOnImage.X - 300, pointOnImage.Y - 200, 600, 400);
    selection.Zoom();
}
Best regards, Alexander

Re: zoomselection

Posted: Tue Feb 28, 2012 11:04 pm
by MichaelHerrmanns
Hello Alex,

thats it.
Now it works.

Thank you

best regards

Michael