Leadtools.WinForms Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.8.31
ViewerBorderPadding Class
See Also  Members   Example 
Leadtools.WinForms Namespace : ViewerBorderPadding Class




Determines the border padding for Leadtools ImageViewer controls.

Syntax

Visual Basic (Declaration) 
Public Class ViewerBorderPadding 
Visual Basic (Usage)Copy Code
Dim instance As ViewerBorderPadding
C# 
public class ViewerBorderPadding 
Managed Extensions for C++ 
public __gc class ViewerBorderPadding 
C++/CLI 
public ref class ViewerBorderPadding 

Example

Visual BasicCopy Code
Public Sub ViewerBorderPaddingExample(ByVal viewer As RasterImageViewer)
   If (viewer.IsImageAvailable) Then
      AddHandler viewer.BorderPadding.Changed, AddressOf BorderPadding_Changed
      viewer.BorderPadding.All = 0
      Dim viewerWidth As Integer = viewer.Right - viewer.Left
      Dim viewerHeight As Integer = viewer.Bottom - viewer.Top
      Dim imageWidth As Integer = viewer.Image.Width
      Dim imageHeight As Integer = viewer.Image.Height

      If (imageWidth < viewerWidth) Then
         viewer.BorderPadding.Left = (viewerWidth - imageWidth) \ 2
         viewer.BorderPadding.Right = 0
      End If

      If (imageHeight < viewerHeight) Then
         viewer.BorderPadding.Top = (viewerHeight - imageHeight) \ 2
         viewer.BorderPadding.Bottom = 0
      End If
      RemoveHandler viewer.BorderPadding.Changed, AddressOf BorderPadding_Changed
   End If
End Sub

Private Sub BorderPadding_Changed(ByVal sender As Object, ByVal e As EventArgs)
   Console.WriteLine("BorderPadding Changed")
End Sub
C#Copy Code
public void ViewerBorderPaddingExample(RasterImageViewer viewer) 

   if(viewer.IsImageAvailable) 
   { 
      viewer.BorderPadding.Changed += new EventHandler(BorderPadding_Changed); 
      viewer.BorderPadding.All = 0; 
      int viewerWidth = viewer.Right - viewer.Left; 
      int viewerHeight = viewer.Bottom - viewer.Top; 
      int imageWidth = viewer.Image.Width; 
      int imageHeight = viewer.Image.Height; 
 
      if(imageWidth < viewerWidth) 
      { 
         viewer.BorderPadding.Left = (viewerWidth - imageWidth) / 2; 
         viewer.BorderPadding.Right = 0; 
      } 
 
      if(imageHeight < viewerHeight) 
      { 
         viewer.BorderPadding.Top = (viewerHeight - imageHeight) / 2; 
         viewer.BorderPadding.Bottom = 0; 
      } 
 
      viewer.BorderPadding.Changed -= new EventHandler(BorderPadding_Changed); 
   } 

 
private void BorderPadding_Changed(System.Object sender, EventArgs e) 

   Console.WriteLine("BorderPadding Changed"); 
}

Inheritance Hierarchy

System.Object
   Leadtools.WinForms.ViewerBorderPadding

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also