The collection of items in this ImageViewer
public ImageViewerItems Items { get; }
Public ReadOnly Property Items() As ImageViewerItems
Get
public:
property ImageViewerItems^ Items
{
ImageViewerItems^ get()
}
The collection of items in this ImageViewer.
Items is of type ImageViewerItems which supports standard collection operations such as adding, removing and enumerating the items.
The viewer listens to the events of ImageViewerItems (Using LeadCollection.CollectionChanged) and automatically re-calculates the view layout and update the transformations used when an item is added, removed or changed by the view and items by calling UpdateTransform.
Use BeginUpdate and EndUpdate to optimize this behavior when adding or removing multiple items at once.
The viewer will automatically keep the ActiveItem property set to an item inside this collection. Usually, the first item added if the user did not change the value. When an item is removed, the viewer will set ActiveItem to the new item that takes index in the collection. Finally when no items are left in the collection, ActiveItem will be set to null.
For more information, refer to Image Viewer Items.
This example will show how to add, remove and enumerate items in the viewer.
Start with the ImageViewer example, remove all the code inside the example function (search for the "// TODO: add example code here" comment) and insert the following code:
using Leadtools;
using Leadtools.Controls;
using Leadtools.Codecs;
using Leadtools.Drawing;
using LeadtoolsExamples.Common;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
// Clear all the images already the viewer
_imageViewer.Items.Clear();
// Use vertical view layout
_imageViewer.ViewLayout = new ImageViewerVerticalViewLayout();
_imageViewer.ImageBorderThickness = 1;
// Add 4 items to the viewer
using (var codecs = new RasterCodecs())
{
for (var page = 1; page <= 4; page++)
{
var item = new ImageViewerItem();
var fileName = Path.Combine(ImagesPath.Path, string.Format("ocr{0}.tif", page));
item.Image = codecs.Load(fileName, 100, 100, 24, RasterSizeFlags.Resample, CodecsLoadByteOrder.BgrOrGray, page, page);
// Set the tag of each item to be the page number
item.Tag = page;
_imageViewer.Items.Add(item);
}
}
// Show the count
MessageBox.Show("This must say 4: " + _imageViewer.Items.Count);
// Remove the item at index 1 (page 2)
_imageViewer.Items.RemoveAt(1);
MessageBox.Show("This must now say 3: " + _imageViewer.Items.Count);
// Loop through each item and show the tag, since we remove page 2, it must say 1, 3, 4
foreach (var item in _imageViewer.Items)
{
var pageNumber = (int)item.Tag;
MessageBox.Show(pageNumber.ToString());
}
Imports Leadtools
Imports Leadtools.Controls
Imports Leadtools.Codecs
Imports Leadtools.Drawing
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports LeadtoolsControlsExamples.LeadtoolsExamples.Common
' Clear all the images already the viewer
_imageViewer.Items.Clear()
' Use vertical view layout
_imageViewer.ViewLayout = New ImageViewerVerticalViewLayout()
_imageViewer.ImageBorderThickness = 1
' Add 4 items to the viewer
Using codecs As New RasterCodecs()
For page As Integer = 1 To 4
Dim item As New ImageViewerItem()
Dim fileName As String = Path.Combine(ImagesPath.Path, String.Format("ocr{0}.tif", page))
item.Image = codecs.Load(fileName, 100, 100, 24, RasterSizeFlags.Resample, CodecsLoadByteOrder.BgrOrGray, page, page)
' Set the tag of each item to be the page number
item.Tag = page
_imageViewer.Items.Add(item)
Next page
End Using
' Show the count
MessageBox.Show("This must say 4: " & _imageViewer.Items.Count)
' Remove the item at index 1 (page 2)
_imageViewer.Items.RemoveAt(1)
MessageBox.Show("This must now say 3: " & _imageViewer.Items.Count)
' Loop through each item and show the tag, since we remove page 2, it must say 1, 3, 4
For Each item As ImageViewerItem In _imageViewer.Items
Dim pageNumber As Integer = CInt(item.Tag)
MessageBox.Show(pageNumber.ToString())
Next item
Products |
Support |
Feedback: Items Property (ImageViewer) - Leadtools.Controls |
Introduction |
Help Version 19.0.2017.6.20
|
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.