Centers the image display at the specified point.
public virtual void CenterAtPoint(Point pt)
Public Overridable Sub CenterAtPoint( _ByVal pt As Point _)
public:virtual void CenterAtPoint(Point pt)
pt
The point at which to center the image display, in client coordinates.
The control will position the scrollbars according to user cursor moves, therefore, this method is only functional if the control has visible scrollbars (SizeMode is SizeMode.Normal or SizeMode.FitWidth and the view port is less than the image size).
The control will call this method during InteractiveMode.Pan.
This example shows a method to change the viewer scale factor (zoom) while keeping the viewer centered.
using Leadtools.Help;using Leadtools.Windows.Controls;void ZoomAndCenter(ImageViewer viewer, double scaleFactor){// Minimum and maximum scale factors allowed (change if you have to)const double minimumScaleFactor = 0.05;const double maximumScaleFactor = 11;// Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor));// Check if we need to change the scale factor for the viewerif (viewer.ScaleFactor != scaleFactor){// Get the current center in logical units// We will use this point later to re-center the viewer// Get what you see in physical coordinatesRect rc = Rect.Intersect(new Rect(0, 0, viewer.ActualWidth, viewer.ActualHeight), new Rect(viewer.PhysicalSize));// Get the center of what you see in physical coordinatesPoint center = new Point(rc.Left + rc.Width / 2 * scaleFactor, rc.Top + rc.Height / 2 * scaleFactor);// Set the new scale factorviewer.ScaleFactor = scaleFactor;// Bring the old center into the center of the viewviewer.CenterAtPoint(center);}}
Imports Leadtools.Windows.ControlsPrivate Sub ZoomAndCenter(ByVal viewer As ImageViewer, ByVal scaleFactor As Double)' Minimum and maximum scale factors allowed (change if you have to)Const minimumScaleFactor As Double = 0.05Const maximumScaleFactor As Double = 11' Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor))' Check if we need to change the scale factor for the viewerIf viewer.ScaleFactor <> scaleFactor Then' Get the current center in logical units' We will use this point later to re-center the viewer' Get what you see in physical coordinatesDim rc As Rect = Rect.Intersect(New Rect(0, 0, viewer.ActualWidth, viewer.ActualHeight), New Rect(viewer.PhysicalSize))' Get the center of what you see in physical coordinatesDim center As Point = New Point(rc.Left + rc.Width / 2 * scaleFactor, rc.Top + rc.Height / 2 * scaleFactor)' Set the new scale factorviewer.ScaleFactor = scaleFactor' Bring the old center into the center of the viewviewer.CenterAtPoint(center)End IfEnd Sub
using Leadtools.Help;using Leadtools.Windows.Controls;void ZoomAndCenter(ImageViewer viewer, double scaleFactor){// Minimum and maximum scale factors allowed (change if you have to)const double minimumScaleFactor = 0.05;const double maximumScaleFactor = 11;// Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor));// Check if we need to change the scale factor for the viewerif (viewer.ScaleFactor != scaleFactor){// Get the current center in logical units// We will use this point later to re-center the viewer// Get what you see in physical coordinatesLeadRect rc = LeadRect.Intersect(new LeadRect(0, 0, (int)viewer.ActualWidth, (int)viewer.ActualHeight), new LeadRect(0, 0, (int)viewer.PhysicalSize.Width, (int)viewer.PhysicalSize.Height));// Get the center of what you see in physical coordinatesPoint center = new Point(rc.Left + rc.Width / 2 * scaleFactor, rc.Top + rc.Height / 2 * scaleFactor);// Set the new scale factorviewer.ScaleFactor = scaleFactor;// Bring the old center into the center of the viewviewer.CenterAtPoint(center);}}
Imports LeadtoolsImports Leadtools.Windows.ControlsPrivate Sub ZoomAndCenter(ByVal viewer As ImageViewer, ByVal scaleFactor As Double)' Minimum and maximum scale factors allowed (change if you have to)Const minimumScaleFactor As Double = 0.05Const maximumScaleFactor As Double = 11' Normalize the scale factor based on min and maxscaleFactor = Math.Max(minimumScaleFactor, Math.Min(maximumScaleFactor, scaleFactor))' Check if we need to change the scale factor for the viewerIf viewer.ScaleFactor <> scaleFactor Then' Get the current center in logical units' We will use this point later to re-center the viewer' Get what you see in physical coordinatesDim rc As LeadRect = LeadRect.Intersect(New LeadRect(0, 0, CInt(viewer.ActualWidth), CInt(viewer.ActualHeight)), New LeadRect(0, 0, CInt(viewer.PhysicalSize.Width), CInt(viewer.PhysicalSize.Height)))' Get the center of what you see in physical coordinatesDim center As Point = New Point(rc.Left + rc.Width / 2 * scaleFactor, rc.Top + rc.Height / 2 * scaleFactor)' Set the new scale factorviewer.ScaleFactor = scaleFactor' Bring the old center into the center of the viewviewer.CenterAtPoint(center)End IfEnd Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
