Click or drag to resize

AtalaImageViewerCenterInViewer Method

These methods will attempt to scroll a pixel or rectangular area to the center of the viewer.
Examples
 ' Add an event handler for the MouseUp event.
Private Me.Viewer.MouseUp += New MouseButtonEventHandler(AddressOf Viewer_MouseUp)

'... 

Sub Viewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    If Me.Viewer.Image Is Nothing Then
        Return
    End If

    Dim pt As Point = Me.Viewer.PointToImage(e.GetPosition(Me.Viewer))
    Me.Viewer.CenterInViewer(pt)
End Sub
 // Add an event handler for the MouseUp event.
this.Viewer.MouseUp += new MouseButtonEventHandler(Viewer_MouseUp);

//...

void Viewer_MouseUp(object sender, MouseButtonEventArgs e)
{
    if (this.Viewer.Image == null) return;

    Point pt = this.Viewer.PointToImage(e.GetPosition(this.Viewer));
    this.Viewer.CenterInViewer(pt);
}
Overload List
  NameDescription
Public methodCode exampleCenterInViewer(Point)
Scrolls the image to center a pixel within the viewer (if possible).
Public methodCenterInViewer(Rect, Boolean)
Centers a rectangle, optionally changing the zoom level to fit the rectangle within the viewer.
Top
Examples
 ' Add an event handler for the MouseUp event.
Private Me.Viewer.MouseUp += New MouseButtonEventHandler(AddressOf Viewer_MouseUp)

'... 

Sub Viewer_MouseUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    If Me.Viewer.Image Is Nothing Then
        Return
    End If

    Dim pt As Point = Me.Viewer.PointToImage(e.GetPosition(Me.Viewer))
    Me.Viewer.CenterInViewer(pt)
End Sub
 // Add an event handler for the MouseUp event.
this.Viewer.MouseUp += new MouseButtonEventHandler(Viewer_MouseUp);

//...

void Viewer_MouseUp(object sender, MouseButtonEventArgs e)
{
    if (this.Viewer.Image == null) return;

    Point pt = this.Viewer.PointToImage(e.GetPosition(this.Viewer));
    this.Viewer.CenterInViewer(pt);
}
See Also