Prevents the control from drawing until the EndUpdate method is called.
public virtual void BeginUpdate()
Public Overridable Sub BeginUpdate()
public:
virtual void BeginUpdate();
When you want to disable repainting of the viewer, call BeginUpdate. When you are ready to resume painting call EndUpdate.
This sample zooms out on the image, keeping it centered. The resulting transform is displayed in the console.
Imports Leadtools.WinForms
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing
'''
' center the loaded image in the middle of rasterImageViewer if the image smaller than the viewer size
Private Sub centerImage(ByVal viewer As RasterImageViewer)
' do center only when RasterViewerSizeMode == Normal
If viewer.SizeMode = RasterPaintSizeMode.Normal Then
If viewer.IsImageAvailable = True Then
If Not viewer.Image Is Nothing Then
Dim viewerWidth As Integer = viewer.Right - viewer.Left
Dim viewerHeight As Integer = viewer.Bottom - viewer.Top
Dim imageWidth As Integer = CInt(viewer.LogicalViewRectangle.Width * viewer.ScaleFactor)
Dim imageHeight As Integer = CInt(viewer.LogicalViewRectangle.Height * viewer.ScaleFactor)
If imageWidth < viewerWidth Then
viewer.BorderPadding.Left = (viewerWidth - imageWidth) \ 2
Else
viewer.BorderPadding.Left = 0
End If
If imageHeight < viewerHeight Then
viewer.BorderPadding.Top = (viewerHeight - imageHeight) \ 2
Else
viewer.BorderPadding.Top = 0
End If
End If
End If
End If
End Sub
Private Sub viewer_TransformedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim viewer As RasterImageViewer = CType(IIf(TypeOf sender Is RasterImageViewer, sender, Nothing), RasterImageViewer)
Dim s As String = String.Format("Transform: {0} {1} {2} {3} {4} {5}", viewer.Transform.Elements(0), viewer.Transform.Elements(1), _
viewer.Transform.Elements(2), viewer.Transform.Elements(3), viewer.Transform.Elements(4), _
viewer.Transform.Elements(5))
Console.WriteLine(s)
End Sub
Public Sub RasterImageViewer_BeginUpdate(ByVal viewer As RasterImageViewer)
AddHandler viewer.TransformChanged, AddressOf viewer_TransformedChanged
viewer.BeginUpdate() ' suspend painting of the image
viewer.ScaleFactor = viewer.ScaleFactor * 0.9F
centerImage(viewer)
viewer.EndUpdate() ' start painting of the image
RemoveHandler viewer.TransformChanged, AddressOf viewer_TransformedChanged
End Sub
using Leadtools.WinForms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Color;
using Leadtools.Drawing;
///
// center the loaded image in the middle of rasterImageViewer if the image smaller than the viewer size
private void centerImage(RasterImageViewer viewer)
{
// do center only when RasterViewerSizeMode == Normal
if (viewer.SizeMode == RasterPaintSizeMode.Normal)
{
if (viewer.IsImageAvailable == true)
{
if (viewer.Image != null)
{
int viewerWidth = viewer.Right - viewer.Left;
int viewerHeight = viewer.Bottom - viewer.Top;
int imageWidth = (int)(viewer.LogicalViewRectangle.Width * viewer.ScaleFactor);
int imageHeight = (int)(viewer.LogicalViewRectangle.Height * viewer.ScaleFactor);
if (imageWidth < viewerWidth)
viewer.BorderPadding.Left = (viewerWidth - imageWidth) / 2;
else
viewer.BorderPadding.Left = 0;
if (imageHeight < viewerHeight)
viewer.BorderPadding.Top = (viewerHeight - imageHeight) / 2;
else
viewer.BorderPadding.Top = 0;
}
}
}
}
private void viewer_TransformedChanged(object sender, EventArgs e)
{
RasterImageViewer viewer = sender as RasterImageViewer;
string s = string.Format("Transform: {0} {1} {2} {3} {4} {5}",
viewer.Transform.Elements[0],
viewer.Transform.Elements[1],
viewer.Transform.Elements[2],
viewer.Transform.Elements[3],
viewer.Transform.Elements[4],
viewer.Transform.Elements[5]);
Console.WriteLine(s);
}
public void RasterImageViewer_BeginUpdate(RasterImageViewer viewer)
{
viewer.TransformChanged += new EventHandler(viewer_TransformedChanged);
viewer.BeginUpdate(); // suspend painting of the image
viewer.ScaleFactor = viewer.ScaleFactor * 0.9F;
centerImage(viewer);
viewer.EndUpdate(); // start painting of the image
viewer.TransformChanged -= new EventHandler(viewer_TransformedChanged);
}
Products |
Support |
Feedback: BeginUpdate Method (RasterImageViewer) - Leadtools.WinForms |
Introduction |
Help Version 19.0.2017.3.22
|
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.