VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.UI Namespace / ImageViewerImagesManager Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    ImageViewerImagesManager Class
    In This Topic
    Asynchronously manages images of image viewer.
    Object Model
    ImageCollection ImageViewerImagesManager
    Syntax
    'Declaration
    
    Public Class ImageViewerImagesManager
       Inherits Vintasoft.Imaging.ImageCollectionManager
    
    
    public class ImageViewerImagesManager : Vintasoft.Imaging.ImageCollectionManager
    
    
    public __gc class ImageViewerImagesManager : public Vintasoft.Imaging.ImageCollectionManager*
    
    
    public ref class ImageViewerImagesManager : public Vintasoft.Imaging.ImageCollectionManager^
    
    
    Example

    This C#/VB.NET code shows how to use images manager that asynchronously adds images to an image viewer (manager retrieves information about images from file during 1 second, adds images to an image viewer, does previous steps until information about all images will not be retrieved).

    
    ''' <summary>
    ''' The images manager for an image viewer.
    ''' </summary>
    Private _imagesManager As Vintasoft.Imaging.UI.ImageViewerImagesManager
    
    
    
    ''' <summary>
    ''' Initializes a new instance of the <see cref="MainForm1"/> class.
    ''' </summary>
    Public Sub New()
        InitializeComponent()
    
        ' create images manager
        _imagesManager = New Vintasoft.Imaging.UI.ImageViewerImagesManager(imageViewer1)
        ' specify that manager should retrieve information about image from file during 1 second, add images to an image viewer,
        ' do previous steps until information about all images will not be retrieved
        _imagesManager.IntermediateAddInterval = 1000
        ' specify that manager should work asynchronously
        _imagesManager.IsAsync = True
        AddHandler _imagesManager.ImageSourceAddException, AddressOf ImagesManager_ImageSourceAddException
    End Sub
    
    
    
    ''' <summary>
    ''' Opens an image file.
    ''' </summary>
    ''' <param name="filename">The filename.</param>
    Friend Sub OpenImageFile(filename As String)
        ' cancel previous file opening process
        CancelOpening()
        ' clear image collection of manager
        _imagesManager.Images.ClearAndDisposeItems()
        ' add image file to the manager
        _imagesManager.Add(filename)
    End Sub
    
    ''' <summary>
    ''' Cancels the opening of a file.
    ''' </summary>
    Private Sub CancelOpening()
        _imagesManager.Cancel()
    End Sub
    
    Private Sub ImagesManager_ImageSourceAddException(sender As Object, e As Vintasoft.Imaging.ImageSourceExceptionEventArgs)
        Dim message As String = String.Format("Cannot open {0} : {1}", System.IO.Path.GetFileName(e.SourceFilename), e.Exception.Message)
        System.Windows.Forms.MessageBox.Show(message, "Error")
    End Sub
    
    
    
    /// <summary>
    /// The images manager for an image viewer.
    /// </summary>
    Vintasoft.Imaging.UI.ImageViewerImagesManager _imagesManager;
    
    
    
    /// <summary>
    /// Initializes a new instance of the <see cref="MainForm1"/> class.
    /// </summary>
    public MainForm1()
    {
        InitializeComponent();
    
        // create images manager
        _imagesManager = new Vintasoft.Imaging.UI.ImageViewerImagesManager(imageViewer1);
        // specify that manager should retrieve information about image from file during 1 second, add images to an image viewer,
        // do previous steps until information about all images will not be retrieved
        _imagesManager.IntermediateAddInterval = 1000;
        // specify that manager should work asynchronously
        _imagesManager.IsAsync = true;
        _imagesManager.ImageSourceAddException += ImagesManager_ImageSourceAddException;
    }
    
    
    
    /// <summary>
    /// Opens an image file.
    /// </summary>
    /// <param name="filename">The filename.</param>
    internal void OpenImageFile(string filename)
    {
        // cancel previous file opening process
        CancelOpening();
        // clear image collection of manager
        _imagesManager.Images.ClearAndDisposeItems();
        // add image file to the manager
        _imagesManager.Add(filename);
    }
    
    /// <summary>
    /// Cancels the opening of a file.
    /// </summary>
    private void CancelOpening()
    {
        _imagesManager.Cancel();
    }
    
    private void ImagesManager_ImageSourceAddException(object sender, Vintasoft.Imaging.ImageSourceExceptionEventArgs e)
    {
        string message = string.Format("Cannot open {0} : {1}", System.IO.Path.GetFileName(e.SourceFilename), e.Exception.Message);
        System.Windows.Forms.MessageBox.Show(message, "Error");
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageCollectionManager
          Vintasoft.Imaging.UI.ImageViewerImagesManager

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also