←Select platform

PageNumber Property

Summary

Page number to use if Image has more than one page (frame).

Syntax
C#
VB
C++
public int PageNumber { get; set; } 
Public Property PageNumber() As Integer 
   Get 
   Set 
public:  
   property int PageNumber 
   { 
      int get() 
      void set(int value) 
   } 

Property Value

The 1-based page number to use by this item of Image has more than one page. Default value is 0.

Remarks

This value is used as the 1-based page number when a valid object is set in the Image property. RasterImage supports multipage images (frames) and the same value can be set in multiple items. Use PageNumber to control which page is used by the item.

Note that even through the default value of 0 is not a legal page number, the item will check and internally revert to using 1 (first page).

ImageViewerPagerInteractiveMode uses the value of this property to cycle through the pages of a multipage image in an item.

For more information, refer to Image Viewer Items.

Example
C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using LeadtoolsExamples.Common; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
public void ImageViewerPageNumber_Example() 
{ 
   if (_imageViewer.Items.Count > 0) 
   { 
      var item = _imageViewer.ActiveItem; 
      var image = item != null ? item.Image : null; 
      var pageCount = (image != null) ? image.PageCount : 1; 
 
      if (pageCount > 1) 
      { 
         var oldPageNumber = item.PageNumber; 
         var newPageNumber = oldPageNumber; 
 
         if (_previousItem) 
            newPageNumber--; 
         else 
            newPageNumber++; 
 
         newPageNumber = Math.Max(1, Math.Min(pageCount, newPageNumber)); 
         if (newPageNumber != oldPageNumber) 
         { 
            item.PageNumber = newPageNumber; 
         } 
      } 
      else 
      { 
         var index = _imageViewer.Items.IndexOf(_imageViewer.ActiveItem); 
         if (_previousItem) 
            index--; 
         else 
            index++; 
 
         if (index >= 0 && index < _imageViewer.Items.Count) 
            _imageViewer.ActiveItem = _imageViewer.Items[index]; 
      } 
   } 
} 
Imports Leadtools 
Imports Leadtools.Controls 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports LeadtoolsControlsExamples.LeadtoolsExamples.Common 
 
Public Sub ImageViewerPageNumber_Example() 
 
   If _imageViewer.Items.Count > 0 Then 
      Dim item As ImageViewerItem = _imageViewer.ActiveItem 
      Dim image As RasterImage 
      If Not item Is Nothing Then 
         image = item.Image 
      Else 
         image = Nothing 
      End If 
      Dim pageCount As Integer 
      If (Not image Is Nothing) Then 
         pageCount = image.PageCount 
      Else 
         pageCount = 1 
      End If 
 
      If pageCount > 1 Then 
         Dim oldPageNumber As Integer = item.PageNumber 
         Dim newPageNumber As Integer = oldPageNumber 
 
         If _previousItem Then 
            newPageNumber -= 1 
         Else 
            newPageNumber += 1 
         End If 
 
         newPageNumber = Math.Max(1, Math.Min(pageCount, newPageNumber)) 
         If newPageNumber <> oldPageNumber Then 
            item.PageNumber = newPageNumber 
         End If 
      Else 
         Dim index As Integer = _imageViewer.Items.IndexOf(_imageViewer.ActiveItem) 
         If _previousItem Then 
            index -= 1 
         Else 
            index += 1 
         End If 
 
         If index >= 0 AndAlso index < _imageViewer.Items.Count Then 
            _imageViewer.ActiveItem = _imageViewer.Items(index) 
         End If 
      End If 
   End If 
End Sub 

Requirements

Target Platforms

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

Leadtools.Controls Assembly