VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.UI Namespace / ThumbnailCaption Class / CaptionFormatted Event
Syntax Example Requirements SeeAlso
In This Topic
    CaptionFormatted Event (ThumbnailCaption)
    In This Topic
    Occurs when caption text is formatted.
    Syntax
    Example

    This C#/VB.NET code shows how to customize the thumbnail caption:

    
    ''' <summary>
    ''' Sets the custom thumbnail caption.
    ''' </summary>
    ''' <param name="thumbnailViewer">The thumbnail viewer.</param>
    Public Shared Sub SetCustomThumbnailCaption(thumbnailViewer As Vintasoft.Imaging.UI.ThumbnailViewer)
        AddHandler thumbnailViewer.ThumbnailCaption.CaptionFormatted, AddressOf ThumbnailCaption_CaptionFormatted
        thumbnailViewer.ThumbnailCaption.IsVisible = True
    End Sub
    
    ''' <summary>
    ''' Handles the CaptionFormatted event of the ThumbnailCaption.
    ''' </summary>
    ''' <param name="sender">The source of the event.</param>
    ''' <param name="e">The <see cref="Vintasoft.Imaging.UI.ThumbnailCaptionFormattedEventArgs"/> instance containing the event data.</param>
    Private Shared Sub ThumbnailCaption_CaptionFormatted(sender As Object, e As Vintasoft.Imaging.UI.ThumbnailCaptionFormattedEventArgs)
        Dim image As Vintasoft.Imaging.VintasoftImage = e.Thumbnail.Source
        Dim imageIndex As Integer = e.ThumbnailViewer.Images.IndexOf(image)
        If e.ThumbnailViewer.SelectedIndices.Contains(imageIndex) Then
            e.Caption = "Selected"
        Else
            e.Caption = String.Format("{0}, page {1}", System.IO.Path.GetFileName(image.SourceInfo.Filename), image.SourceInfo.PageIndex + 1)
        End If
    End Sub
    
    
    
    /// <summary>
    /// Sets the custom thumbnail caption.
    /// </summary>
    /// <param name="thumbnailViewer">The thumbnail viewer.</param>
    public static void SetCustomThumbnailCaption(Vintasoft.Imaging.UI.ThumbnailViewer thumbnailViewer)
    {
        thumbnailViewer.ThumbnailCaption.CaptionFormatted += ThumbnailCaption_CaptionFormatted;
        thumbnailViewer.ThumbnailCaption.IsVisible = true;
    }
    
    /// <summary>
    /// Handles the CaptionFormatted event of the ThumbnailCaption.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="Vintasoft.Imaging.UI.ThumbnailCaptionFormattedEventArgs"/> instance containing the event data.</param>
    private static void ThumbnailCaption_CaptionFormatted(object sender, Vintasoft.Imaging.UI.ThumbnailCaptionFormattedEventArgs e)
    {
        Vintasoft.Imaging.VintasoftImage image = e.Thumbnail.Source;
        int imageIndex = e.ThumbnailViewer.Images.IndexOf(image);
        if (e.ThumbnailViewer.SelectedIndices.Contains(imageIndex))
        {
            e.Caption = "Selected";
        }
        else
        {
            e.Caption = string.Format("{0}, page {1}", System.IO.Path.GetFileName(image.SourceInfo.Filename), image.SourceInfo.PageIndex + 1);
        }
    }
    
    

    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