VintaSoft Imaging .NET SDK and Plug-ins Discussions
Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.
Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions
private void ShowThumbnails(string currentFolder)
{
wpfThumbnailViewer1.Images.Clear();
foreach (var file in Directory.GetFiles(currentFolder).Where(f => f.EndsWith(".png") || f.EndsWith(".jpg") || f.EndsWith(".jpeg")))
{
wpfThumbnailViewer1.Images.Add(file);
}
}
I work with Visual Studio 10 Express, WPF and C#void MainWindow()
{
...
thumbnailViewer1.ThumbnailAdded += new EventHandler<ThumbnailImageItemEventArgs>(thumbnailViewer_ThumbnailAdded);
...
}
void thumbnailViewer_ThumbnailAdded(object sender, ThumbnailImageItemEventArgs e)
{
// add decoder name on thumbnail
TextBlock text = new TextBlock();
text.TextAlignment = TextAlignment.Center;
text.Text = e.Thumbnail.Source.SourceInfo.DecoderName;
e.Thumbnail.Content = text;
}
Best regards, Alexander
Can you tell me how I could show the text under each thumbnail and let the text create a newline when it is bigger the the image width?Here is the code snippet:
void MainWindow()
{
...
// increase the thumbnail height, this is necessary for reserving space for text under thumbnail
thumbnailViewer.ThumbnailSize = new Size(thumbnailViewer.ThumbnailSize.Width, thumbnailViewer.ThumbnailSize.Height + 50);
// subscribe to the ThumbnailAdded event
thumbnailViewer1.ThumbnailAdded += new EventHandler<ThumbnailImageItemEventArgs>(thumbnailViewer_ThumbnailAdded);
...
}
void thumbnailViewer_ThumbnailAdded(object sender, ThumbnailImageItemEventArgs e)
{
// reserve space for text
Thickness thumbnailImagePadding = e.Thumbnail.ThumbnailImagePadding;
thumbnailImagePadding.Bottom = 50;
e.Thumbnail.ThumbnailImagePadding = thumbnailImagePadding;
// create the text block with filename
TextBlock text = new TextBlock();
text.Text = e.Thumbnail.Source.SourceInfo.Filename;
text.TextAlignment = TextAlignment.Center;
text.TextWrapping = TextWrapping.Wrap;
text.Margin = new Thickness(0, e.Thumbnail.Height - 50, 0, 0);
// add text block as content of thumbnail
e.Thumbnail.Content = text;
}
Best regards, Alexander