←Select platform

ImageViewer Property

Summary

Image viewer control.

Syntax
C#
C++/CLI
public ImageViewer ImageViewer { get; } 
public:  
   property ImageViewer^ ImageViewer 
   { 
      ImageViewer^ get() 
   } 

Property Value

The ImageViewer control used to view the main content of the document.

Remarks

ImageViewer is initialized during CreateDocumentViewer. A new instance of ImageViewer is created and set in this property. The control is added as a child to DocumentViewerCreateOptions.ViewContainer and initialized as follows:

Member Description

ViewHorizontalAlignment and ViewVerticalAlignment

Center

ImageHorizontalAlignment and ImageVerticalAlignment

Center

ImageBorderThickness

1

ImageBackgroundColor

White color

ItemPadding

4, 4, 4, 4

UseDpi

true

ImageViewer.Tag

Set to the owner DocumentViewer. Be careful not to modify this value in your application.

In addition to the above, the document viewer subscribes to the PostRenderItem event to render the current text selection used by DocumentViewer.Text, the annotations for the pages used by Annotations and any optional debugging rendering done by DocumentViewer.Diagnostics.

After CreateDocumentViewer returns, you can further customize or use this ImageViewer control as needed by your application.

Example
C#
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Document; 
using Leadtools.Document.Viewer; 
using Leadtools.Codecs; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
 
 
// Disable the example button, this should only run once 
exampleButton.Enabled = false; 
 
// Get the view 
var view = _documentViewer.View; 
// Get its image viewer 
var imageViewer = view.ImageViewer; 
// Hook to the PostRender 
imageViewer.PostRenderItem += (sender, e) => 
{ 
   // Get the image viewer item for the page 
   var item = e.Item; 
 
   // Get the current rectangle for the image 
   var bounds = imageViewer.GetItemViewBounds(item, ImageViewerItemPart.Image, false); 
 
   // Build the text we want. The page number is the item index + 1 
   var pageNumber = imageViewer.Items.IndexOf(item) + 1; 
   var text = "Page " + pageNumber.ToString(); 
 
   // Get the image transformation for this item 
   var transform = imageViewer.GetItemImageTransform(e.Item); 
 
   // Apply it to the context 
   var gstate = e.Context.Save(); 
   using (var matrix = new System.Drawing.Drawing2D.Matrix( 
      (float)transform.M11, 
      (float)transform.M12, 
      (float)transform.M21, 
      (float)transform.M22, 
      (float)transform.OffsetX, 
      (float)transform.OffsetY)) 
   { 
      e.Context.MultiplyTransform(matrix); 
   } 
 
   // Render the text at the bottom of the bounds 
   var flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom; 
   var rc = new Rectangle((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height); 
   TextRenderer.DrawText(e.Context, text, imageViewer.Font, rc, Color.White, Color.Black, flags); 
 
   e.Context.Restore(gstate); 
}; 
 
// Invalidate so our changes take effect the first time 
view.Invalidate(); 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Viewer.WinForms Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.