Browses the specified paths for supported images, and generates thumbnails for each image file that is found.
public void LoadThumbnails(IEnumerable<string> paths,string searchPattern,Leadtools.Winforms.RasterThumbnailBrowserLoadFlags flags)
Public Overloads Sub LoadThumbnails( _ByVal paths As IEnumerable(Of String), _ByVal searchPattern As String, _ByVal flags As Leadtools.Winforms.RasterThumbnailBrowserLoadFlags _)
public:void LoadThumbnails(IEnumerable<String^>^ paths,String^ searchPattern,Leadtools.Winforms.RasterThumbnailBrowserLoadFlags flags)
paths
The paths to browse. This can be a directories and files.
searchPattern
The search string to match against the names of files in path. The parameter cannot end in two periods ("..") or contain two periods ("..") followed by System.IO.Path.DirectorySeparatorChar or System.IO.Path.AltDirectorySeparatorChar, nor can it contain any of the characters in System.IO.Path.InvalidPathChars.
flags
An RasterThumbnailBrowserLoadFlags enumeration that can be a combination of the following:
| Value | Description |
|---|---|
| RasterThumbnailBrowserLoadFlags.None | Default mode, the method will return immediatly and the thumbnails are loaded in a background thread. |
| RasterThumbnailBrowserLoadFlags.Block | The method will not return until all thumbnails are loaded. |
| RasterThumbnailBrowserLoadFlags.OnlyValidImageFiles | Only valid image files are loaded. Any file that contains data not recognized by the Codecs object as a valid image file will not be loaded. |
Use the LoadThumbnails(String,String,RasterThumbnailBrowserLoadFlags) method to populate the RasterThumbnailBrowser control with the thumbnails of image files found in the directory specified by path. The control will load the images in the following manner:
This example will load two files and expands the multipage one.
Imports Leadtools.WinFormsImports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingPrivate Class MyForm2 : Inherits FormPublic theBrowser As RasterThumbnailBrowserPublic cancelOperation As Boolean ' Informs us if the user canceled the operationPublic buttonCancel As Button ' Cancel browse loadingPublic buttonBrowse As Button ' Diplays the browse controlPublic progressBar As ProgressBar ' shows progress of loading browse imagesPrivate Sub buttonBrowse_Click(ByVal sender As Object, ByVal e As EventArgs)' If we are already loading thumbails, cancel' this operationIf theBrowser.IsLoadingThumbnails ThentheBrowser.CancelLoadingThumbnails()End If' Clean all the itemstheBrowser.Items.Clear()' Update the application statebuttonCancel.Enabled = TrueprogressBar.Value = 0' And load the new thumbnailscancelOperation = FalseDim folderPath As String = LEAD_VARS.ImagesDirDim files As String() = New String(1) {Path.Combine(folderPath, "\image1.jpx"), folderPath}theBrowser.LoadThumbnails(files, "*.jpg", RasterThumbnailBrowserLoadFlags.Block Or RasterThumbnailBrowserLoadFlags.ExpandMultiPageFile)End SubPrivate Sub thumbnailBrowser_LoadThumbnail(ByVal sender As Object, ByVal e As RasterThumbnailBrowserLoadThumbnailEventArgs)' If this is the first iteration, update the progress bar minimum and maximum valuesIf e.Index = 0 ThenprogressBar.Minimum = 0progressBar.Maximum = e.Total - 1End If' Update where we are in the loading operationprogressBar.Value = e.Index' Check if we need to cancel (due to the user clicking the Cancel button)If cancelOperation Thene.Cancel = TrueEnd IfEnd SubPrivate Sub thumbnailBrowser_AddFile(ByVal sender As Object, ByVal e As RasterThumbnailBrowserAddFileEventArgs)Console.WriteLine("AddFile: {0} Add: {1} Total Pages: {2} Page:{3}", e.FileName, e.Add, e.TotalPages, e.Page)End SubPrivate Sub thumbnailBrowser_FinishedLoadingThumbnails(ByVal sender As Object, ByVal e As EventArgs)buttonCancel.Enabled = FalseEnd SubPrivate Sub buttonCancel_Click(ByVal sender As Object, ByVal e As EventArgs)' The user has clicked the cancel buttonMe.cancelOperation = TrueEnd Sub' Create custom images to use as the "error" and "loading" thumbnails.Private Sub CreateErrorThumbnail()' Get the image sizeDim imageSize As Size = theBrowser.ItemImageSize' No "loading" thumbnailtheBrowser.LoadingThumbnail = Nothing' For the "error" thumbnail, create a red X imageDim palette As RasterColor() = New RasterColor() {}Dim image As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, imageSize.Width, imageSize.Height, 24, RasterByteOrder.Bgr, _RasterViewPerspective.TopLeft, palette, IntPtr.Zero, 0)Dim hdc As IntPtr = RasterImagePainter.CreateLeadDC(image)Dim g As Graphics = Graphics.FromHdc(hdc)g.FillRectangle(Brushes.Magenta, 0, 0, imageSize.Width, imageSize.Height)g.DrawLine(Pens.Red, 0, 0, imageSize.Width, imageSize.Height)g.DrawLine(Pens.Red, imageSize.Width, 0, 0, imageSize.Height)g.Dispose()RasterImagePainter.DeleteLeadDC(hdc)' Make this image transparentimage.Transparent = Trueimage.TransparentColor = RasterColor.FromKnownColor(RasterKnownColor.Magenta)theBrowser.ErrorThumbnail = imageEnd SubPublic Sub Cleanup()RemoveHandler buttonBrowse.Click, AddressOf buttonBrowse_ClickRemoveHandler buttonCancel.Click, AddressOf buttonCancel_ClickRemoveHandler theBrowser.LoadThumbnail, AddressOf thumbnailBrowser_LoadThumbnailRemoveHandler theBrowser.FinishedLoadingThumbnails, AddressOf thumbnailBrowser_FinishedLoadingThumbnailsEnd SubPublic Sub New()Size = New Size(300, 200)' create the browsertheBrowser = New RasterThumbnailBrowser()theBrowser.Codecs = New RasterCodecs()theBrowser.Dock = DockStyle.FilltheBrowser.ItemSpacingSize = New Size(10, 10)theBrowser.ThumbnailSizeFlags = RasterSizeFlags.BicubicAddHandler theBrowser.LoadThumbnail, AddressOf thumbnailBrowser_LoadThumbnailAddHandler theBrowser.FinishedLoadingThumbnails, AddressOf thumbnailBrowser_FinishedLoadingThumbnailsAddHandler theBrowser.AddFile, AddressOf thumbnailBrowser_AddFile' Create a thumbnail image to be displayed on errorCreateErrorThumbnail()' add a panelDim panel As Panel = New Panel()panel.Dock = DockStyle.Leftpanel.Width = 100Controls.Add(panel)panel.BringToFront()' add a "browse" buttonbuttonBrowse = New Button()buttonBrowse.Text = "Browse"buttonBrowse.Dock = DockStyle.Toppanel.Controls.Add(buttonBrowse)AddHandler buttonBrowse.Click, AddressOf buttonBrowse_Click' add a "cancel" buttonbuttonCancel = New Button()buttonCancel.Text = "Cancel"buttonBrowse.Dock = DockStyle.Bottompanel.Controls.Add(buttonCancel)AddHandler buttonCancel.Click, AddressOf buttonCancel_Click' add a progress barprogressBar = New ProgressBar()progressBar.Dock = DockStyle.BottomControls.Add(progressBar)Controls.Add(theBrowser)theBrowser.BringToFront()End SubPrivate Sub InitializeComponent()Me.SuspendLayout()'' MyForm'Me.ClientSize = New System.Drawing.Size(315, 273)Me.Name = "MyForm"Me.ResumeLayout(False)End SubEnd ClassPublic Sub RasterThumbnailBrowser_RasterThumbnailBrowser()Dim form As MyForm = New MyForm()form.ShowDialog()form.Cleanup()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;class MyForm2 : Form{public RasterThumbnailBrowser theBrowser;public bool cancelOperation; // Informs us if the user canceled the operationpublic Button buttonCancel; // Cancel browse loadingpublic Button buttonBrowse; // Diplays the browse controlpublic ProgressBar progressBar; // shows progress of loading browse imagesvoid buttonBrowse_Click(object sender, EventArgs e){// If we are already loading thumbails, cancel// this operationif (theBrowser.IsLoadingThumbnails)theBrowser.CancelLoadingThumbnails();// Clean all the itemstheBrowser.Items.Clear();// Update the application statebuttonCancel.Enabled = true;progressBar.Value = 0;// And load the new thumbnailscancelOperation = false;string folderPath = LEAD_VARS.ImagesDir;string[] files = new string[2] { Path.Combine(folderPath , "\\image1.jpx"), folderPath };theBrowser.LoadThumbnails(files, "*.jpg", RasterThumbnailBrowserLoadFlags.Block | RasterThumbnailBrowserLoadFlags.ExpandMultiPageFile);}private void thumbnailBrowser_LoadThumbnail(object sender, RasterThumbnailBrowserLoadThumbnailEventArgs e){// If this is the first iteration, update the progress bar minimum and maximum valuesif (e.Index == 0){progressBar.Minimum = 0;progressBar.Maximum = e.Total - 1;}// Update where we are in the loading operationprogressBar.Value = e.Index;// Check if we need to cancel (due to the user clicking the Cancel button)if (cancelOperation)e.Cancel = true;}private void thumbnailBrowser_AddFile(object sender, RasterThumbnailBrowserAddFileEventArgs e){Console.WriteLine("AddFile: {0} Add: {1} Total Pages : {2} Page : {3}", e.FileName, e.Add, e.TotalPages, e.Page);}private void thumbnailBrowser_FinishedLoadingThumbnails(object sender, EventArgs e){buttonCancel.Enabled = false;}private void buttonCancel_Click(object sender, EventArgs e){// The user has clicked the cancel buttonthis.cancelOperation = true;}// Create custom images to use as the "error" and "loading" thumbnails.void CreateErrorThumbnail(){// Get the image sizeSize imageSize = theBrowser.ItemImageSize;// No "loading" thumbnailtheBrowser.LoadingThumbnail = null;// For the "error" thumbnail, create a red X imageRasterColor[] palette = new RasterColor[0];RasterImage image = new RasterImage(RasterMemoryFlags.Conventional,imageSize.Width,imageSize.Height,24,RasterByteOrder.Bgr,RasterViewPerspective.TopLeft,palette,IntPtr.Zero,0);IntPtr hdc = RasterImagePainter.CreateLeadDC(image);Graphics g = Graphics.FromHdc(hdc);g.FillRectangle(Brushes.Magenta, 0, 0, imageSize.Width, imageSize.Height);g.DrawLine(Pens.Red, 0, 0, imageSize.Width, imageSize.Height);g.DrawLine(Pens.Red, imageSize.Width, 0, 0, imageSize.Height);g.Dispose();RasterImagePainter.DeleteLeadDC(hdc);// Make this image transparentimage.Transparent = true;image.TransparentColor = RasterColor.FromKnownColor(RasterKnownColor.Magenta);theBrowser.ErrorThumbnail = image;}public void Cleanup(){buttonBrowse.Click -= new EventHandler(buttonBrowse_Click);buttonCancel.Click -= new EventHandler(buttonCancel_Click);theBrowser.LoadThumbnail -= new EventHandler<RasterThumbnailBrowserLoadThumbnailEventArgs>(thumbnailBrowser_LoadThumbnail);theBrowser.FinishedLoadingThumbnails -= new EventHandler(thumbnailBrowser_FinishedLoadingThumbnails);}public MyForm2(){Size = new Size(300, 200);// create the browsertheBrowser = new RasterThumbnailBrowser();theBrowser.Codecs = new RasterCodecs();theBrowser.Dock = DockStyle.Fill;theBrowser.ItemSpacingSize = new Size(10, 10);theBrowser.ThumbnailSizeFlags = RasterSizeFlags.Bicubic;theBrowser.LoadThumbnail += new EventHandler<RasterThumbnailBrowserLoadThumbnailEventArgs>(thumbnailBrowser_LoadThumbnail);theBrowser.FinishedLoadingThumbnails += new EventHandler(thumbnailBrowser_FinishedLoadingThumbnails);theBrowser.AddFile += new EventHandler<RasterThumbnailBrowserAddFileEventArgs>(thumbnailBrowser_AddFile);// Create a thumbnail image to be displayed on errorCreateErrorThumbnail();// add a panelPanel panel = new Panel();panel.Dock = DockStyle.Left;panel.Width = 100;Controls.Add(panel);panel.BringToFront();// add a "browse" buttonbuttonBrowse = new Button();buttonBrowse.Text = "Browse";buttonBrowse.Dock = DockStyle.Top;panel.Controls.Add(buttonBrowse);buttonBrowse.Click += new EventHandler(buttonBrowse_Click);// add a "cancel" buttonbuttonCancel = new Button();buttonCancel.Text = "Cancel";buttonBrowse.Dock = DockStyle.Bottom;panel.Controls.Add(buttonCancel);buttonCancel.Click += new EventHandler(buttonCancel_Click);// add a progress barprogressBar = new ProgressBar();progressBar.Dock = DockStyle.Bottom;Controls.Add(progressBar);Controls.Add(theBrowser);theBrowser.BringToFront();}private void InitializeComponent(){this.SuspendLayout();//// MyForm//this.ClientSize = new System.Drawing.Size(315, 273);this.Name = "MyForm";this.ResumeLayout(false);}}public void RasterThumbnailBrowser_LoadThumbnails2(){MyForm form = new MyForm();form.ShowDialog();form.Cleanup();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
|
Products |
Support |
Feedback: LoadThumbnails(IEnumerable<String>,String,RasterThumbnailBrowserLoadFlags) Method - Leadtools.WinForms |
Introduction |
Help Version 19.0.2017.3.22
|

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.