RasterThumbnailBrowserLoadFlags Enumeration

Summary

Used in the RasterThumbnailBrowser.LoadThumbnails to control how the RasterThumbnailBrowser loads the thumbnails.

Syntax

C#
C++/CLI
C++
[FlagsAttribute()] 
public enum RasterThumbnailBrowserLoadFlags 
[FlagsAttribute()] 
public enum class RasterThumbnailBrowserLoadFlags : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable   
public: 
   [FlagsAttribute] 
   enum class RasterThumbnailBrowserLoadFlags sealed 

Members
ValueMemberDescription
0x00000000NoneDefault mode. The method will return immediately and the thumbnails are loaded in a background thread.
0x00000001BlockThe method will not return until all thumbnails are loaded.
0x00000002OnlyValidImageFilesOnly valid image files are loaded. Any file that contains data not recognized by the RasterThumbnailBrowser.Codecs object as a valid image file will not be loaded.
0x00000004AllDirectoriesLoad image files in current directory and all subdirectories. If this flag is not set only image files in the current directory will be loaded.
0x00000008ExpandMultiPageFileA RasterImageListItem will be created and added to the RasterThumbnailBrowser for each page found in the image file if it is a multipage file.

Example

C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
 
class MyForm : Form 
{ 
   public RasterThumbnailBrowser theBrowser; 
   public bool cancelOperation;        // Informs us if the user canceled the operation 
   public Button buttonCancel;         // Cancel browse loading 
   public Button buttonBrowse;         // Diplays the browse control 
   public ProgressBar progressBar;     // shows progress of loading browse images 
 
   void buttonBrowse_Click(object sender, EventArgs e) 
   { 
      // If we are already loading thumbails, cancel 
      // this operation 
      if (theBrowser.IsLoadingThumbnails) 
         theBrowser.CancelLoadingThumbnails(); 
 
      // Clean all the items 
      theBrowser.Items.Clear(); 
 
      // Update the application state 
      buttonCancel.Enabled = true; 
      progressBar.Value = 0; 
 
      // And load the new thumbnails 
      cancelOperation = false; 
 
      string folderPath = LEAD_VARS.ImagesDir; 
      theBrowser.LoadStamp = true; 
      theBrowser.LoadThumbnails(folderPath, "*.*", RasterThumbnailBrowserLoadFlags.Block); 
 
      theBrowser.Refresh(); 
 
      theBrowser.EnableBrowserWatcher = true; 
   } 
 
   private void thumbnailBrowser_LoadThumbnail(object sender, RasterThumbnailBrowserLoadThumbnailEventArgs e) 
   { 
      // If this is the first iteration, update the progress bar minimum and maximum values 
      if (e.Index == 0) 
      { 
         progressBar.Minimum = 0; 
         progressBar.Maximum = e.Total - 1; 
      } 
 
      // Update where we are in the loading operation 
      progressBar.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}", e.FileName, e.Add); 
   } 
 
   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 button 
      this.cancelOperation = true; 
   } 
 
   // Create  custom images to use as the "error" and "loading" thumbnails. 
   void CreateErrorThumbnail() 
   { 
      // Get the image size 
      Size imageSize = theBrowser.ItemImageSize; 
 
      // No "loading" thumbnail 
      theBrowser.LoadingThumbnail = null; 
 
      // For the "error" thumbnail, create a red X image 
      RasterColor[] 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 transparent 
      image.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 MyForm() 
   { 
      Size = new Size(300, 200); 
 
      // create the browser 
      theBrowser = 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 error 
      CreateErrorThumbnail(); 
 
      // add a panel 
      Panel panel = new Panel(); 
      panel.Dock = DockStyle.Left; 
      panel.Width = 100; 
      Controls.Add(panel); 
      panel.BringToFront(); 
 
      // add a "browse" button 
      buttonBrowse = new Button(); 
      buttonBrowse.Text = "Browse"; 
      buttonBrowse.Dock = DockStyle.Top; 
      panel.Controls.Add(buttonBrowse); 
      buttonBrowse.Click += new EventHandler(buttonBrowse_Click); 
 
      // add a "cancel" button 
      buttonCancel = new Button(); 
      buttonCancel.Text = "Cancel"; 
      buttonBrowse.Dock = DockStyle.Bottom; 
      panel.Controls.Add(buttonCancel); 
      buttonCancel.Click += new EventHandler(buttonCancel_Click); 
 
      // add a progress bar 
      progressBar = 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_RasterThumbnailBrowser() 
{ 
   MyForm form = new MyForm(); 
   form.ShowDialog(); 
   form.Cleanup(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

Reference

Leadtools.WinForms Namespace

Help Version 22.0.2023.2.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.WinForms Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.