←Select platform

RasterOpenDialog Class

Syntax

C#
VB
C++
public class RasterOpenDialog : IDisposable 
  
Public Class RasterOpenDialog  
   Implements System.IDisposable  
public ref class RasterOpenDialog : public System.IDisposable   

Remarks

The Open dialog can be seen below:

Example

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.WinForms.CommonDialogs.File; 
 
public void openDlg_Help(object sender, RasterDialogHelpEventArgs e) 
{ 
   switch (e.Dialog) 
   { 
      case RasterDialogHelpName.Open: 
         { 
            MessageBox.Show("Open dialog Help"); 
            break; 
         } 
 
      case RasterDialogHelpName.LoadOptions: 
         { 
            MessageBox.Show("Load Options dialog Help"); 
            break; 
         } 
   } 
} 
 
public void openDlg_LoadProgress(object sender, RasterDialogLoadProgressEventArgs e) 
{ 
   string displayText; 
 
   displayText = "(" + e.FilePercent.ToString() + "%) of" + e.LoadRasterFileData.Name + "file is loaded"; 
   MessageBox.Show(displayText); 
 
   displayText = "(" + e.TotalPercent.ToString() + "%) of all file(s) loading process is completed"; 
   MessageBox.Show(displayText); 
} 
 
public void RasterOpenDialogExample() 
{ 
   RasterCodecs rasterCodecs = new RasterCodecs(); 
 
   RasterOpenDialog openDlg = new RasterOpenDialog(rasterCodecs); 
 
   openDlg.Filter = new RasterOpenDialogLoadFormat[] 
   { 
      new RasterOpenDialogLoadFormat ( "All Files", "*.*" ), 
      new RasterOpenDialogLoadFormat ( "LEAD", "*.cmp" ) 
   }; 
 
   openDlg.CheckFileExists = true; 
   openDlg.CheckPathExists = true; 
   openDlg.DefaultExt = "cmp"; 
   openDlg.DereferenceLinks = true; 
   openDlg.EnableSizing = true; 
   openDlg.FileName = "Image1.cmp"; 
   openDlg.FilterIndex = 2; 
   openDlg.GenerateThumbnail = false; 
   openDlg.InitialDirectory = LEAD_VARS.ImagesDir; 
   openDlg.InitialView = FileDialogInitialView.List; 
   openDlg.LoadCompressed = true; 
   openDlg.LoadFileImage = false; 
   openDlg.LoadOptions = false; 
   openDlg.LoadRotated = false; 
   openDlg.Multiselect = true; 
   openDlg.PreviewWindowVisible = true; 
   openDlg.ShowDeletePage = true; 
   openDlg.ShowFileInformation = true; 
   openDlg.ShowGeneralOptions = true; 
   openDlg.ShowHelp = true; 
   openDlg.ShowLoadCompressed = true; 
   openDlg.ShowLoadOptions = true; 
   openDlg.ShowLoadRotated = true; 
   openDlg.ShowMultipage = true; 
   openDlg.ShowPdfOptions = true; 
   openDlg.ShowXpsOptions = true; 
   openDlg.ShowXlsOptions = true; 
   openDlg.ShowVffOptions = true; 
   openDlg.ShowAnzOptions = true; 
   openDlg.ShowVectorOptions = true; 
   openDlg.ShowPreview = true; 
   openDlg.ShowProgressive = true; 
   openDlg.ShowRasterOptions = true; 
   openDlg.ShowTotalPages = true; 
   openDlg.Title = "Open Dialog"; 
   openDlg.UseFileStamptoPreview = true; 
   openDlg.Help += new EventHandler<RasterDialogHelpEventArgs>(openDlg_Help); 
   openDlg.LoadCorrupted = true; 
 
   // if you set "openDlg.LoadFileImage = true" this event will be fired 
   openDlg.LoadProgress += new EventHandler<RasterDialogLoadProgressEventArgs>(openDlg_LoadProgress); 
 
   if (DialogResult.OK == openDlg.ShowDialog(null)) 
   { 
      for (int i = 0; i < openDlg.OpenedFileData.Count; i++) 
      { 
         RasterDialogFileData fileDataItem = openDlg.OpenedFileData[i]; 
 
         // this is not an image file. 
         if (fileDataItem.Options == null) 
         { 
            continue; 
         } 
 
         rasterCodecs.Options.RasterizeDocument.Load.PageWidth = fileDataItem.Options.RasterizeDocumentOptions.PageWidth; 
         rasterCodecs.Options.RasterizeDocument.Load.PageHeight = fileDataItem.Options.RasterizeDocumentOptions.PageHeight; 
         rasterCodecs.Options.RasterizeDocument.Load.LeftMargin = fileDataItem.Options.RasterizeDocumentOptions.LeftMargin; 
         rasterCodecs.Options.RasterizeDocument.Load.TopMargin = fileDataItem.Options.RasterizeDocumentOptions.TopMargin; 
         rasterCodecs.Options.RasterizeDocument.Load.RightMargin = fileDataItem.Options.RasterizeDocumentOptions.RightMargin; 
         rasterCodecs.Options.RasterizeDocument.Load.BottomMargin = fileDataItem.Options.RasterizeDocumentOptions.BottomMargin; 
         rasterCodecs.Options.RasterizeDocument.Load.Unit = fileDataItem.Options.RasterizeDocumentOptions.Unit; 
         rasterCodecs.Options.RasterizeDocument.Load.XResolution = fileDataItem.Options.RasterizeDocumentOptions.XResolution; 
         rasterCodecs.Options.RasterizeDocument.Load.YResolution = fileDataItem.Options.RasterizeDocumentOptions.YResolution; 
         rasterCodecs.Options.RasterizeDocument.Load.SizeMode = fileDataItem.Options.RasterizeDocumentOptions.SizeMode; 
 
         switch (fileDataItem.Options.FileType) 
         { 
            case RasterDialogFileOptionsType.Meta: 
               { 
                  if (null != fileDataItem.Options.MetaOptions) 
                  { 
                     rasterCodecs.Options.Wmf.Load.XResolution = fileDataItem.Options.MetaOptions.XResolution; 
                     rasterCodecs.Options.Wmf.Load.YResolution = fileDataItem.Options.MetaOptions.XResolution; 
                  } 
                  break; 
               } 
 
            case RasterDialogFileOptionsType.Pdf: 
               { 
                  if ((null != fileDataItem.Options.PdfOptions) && 
                        rasterCodecs.Options.Pdf.IsEngineInstalled) 
                  { 
                     rasterCodecs.Options.Pdf.Load.DisplayDepth = fileDataItem.Options.PdfOptions.DisplayDepth; 
                     rasterCodecs.Options.Pdf.Load.GraphicsAlpha = fileDataItem.Options.PdfOptions.GraphicsAlpha; 
 
                     if (fileDataItem.Options.PdfOptions.Password != null) 
                     { 
                        rasterCodecs.Options.Pdf.Load.Password = fileDataItem.Options.PdfOptions.Password; 
                     } 
 
                     rasterCodecs.Options.Pdf.Load.TextAlpha = fileDataItem.Options.PdfOptions.TextAlpha; 
                     rasterCodecs.Options.Pdf.Load.UseLibFonts = fileDataItem.Options.PdfOptions.UseLibFonts; 
                  } 
                  break; 
               } 
 
            case RasterDialogFileOptionsType.Misc: 
               { 
                  if (null == fileDataItem.Options.MiscOptions) 
                  { 
                     continue; 
                  } 
 
                  switch (fileDataItem.FileInfo.Format) 
                  { 
                     case RasterImageFormat.Jbig: 
                        { 
                           rasterCodecs.Options.Jbig.Load.Resolution = new LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                              fileDataItem.Options.MiscOptions.YResolution); 
                           break; 
                        } 
 
                     case RasterImageFormat.Cmw: 
                        { 
                           rasterCodecs.Options.Jpeg2000.Load.CmwResolution = new LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                              fileDataItem.Options.MiscOptions.YResolution); 
                           break; 
                        } 
 
                     case RasterImageFormat.Jp2: 
                        { 
                           rasterCodecs.Options.Jpeg2000.Load.Jp2Resolution = new LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                              fileDataItem.Options.MiscOptions.YResolution); 
                           break; 
                        } 
 
                     case RasterImageFormat.J2k: 
                        { 
                           rasterCodecs.Options.Jpeg2000.Load.J2kResolution = new LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                              fileDataItem.Options.MiscOptions.YResolution); 
                           break; 
                        } 
                  } 
                  break; 
               } 
 
            case RasterDialogFileOptionsType.Xls: 
               rasterCodecs.Options.Xls.Load.MultiPageSheet = fileDataItem.Options.XlsOptions.MultiPageSheet; 
               break; 
 
            case RasterDialogFileOptionsType.Vff: 
               rasterCodecs.Options.Vff.Load.View = fileDataItem.Options.VffOptions.View; 
               break; 
 
            case RasterDialogFileOptionsType.Anz: 
               rasterCodecs.Options.Anz.Load.View = fileDataItem.Options.AnzOptions.View; 
               break; 
 
            case RasterDialogFileOptionsType.Vector: 
               rasterCodecs.Options.Vector.Load.BackgroundColor = fileDataItem.Options.VectorOptions.Options.BackgroundColor; 
               rasterCodecs.Options.Vector.Load.BitsPerPixel = fileDataItem.Options.VectorOptions.Options.BitsPerPixel; 
               rasterCodecs.Options.Vector.Load.ForceBackgroundColor = fileDataItem.Options.VectorOptions.Options.ForceBackgroundColor; 
               rasterCodecs.Options.Vector.Load.ViewHeight = fileDataItem.Options.VectorOptions.Options.ViewHeight; 
               rasterCodecs.Options.Vector.Load.ViewMode = fileDataItem.Options.VectorOptions.Options.ViewMode; 
               rasterCodecs.Options.Vector.Load.ViewWidth = fileDataItem.Options.VectorOptions.Options.ViewWidth; 
               break; 
         } 
 
         rasterCodecs.Options.Load.Passes = fileDataItem.Passes; 
         rasterCodecs.Options.Load.Rotated = fileDataItem.LoadRotated; 
         rasterCodecs.Options.Load.Compressed = fileDataItem.LoadCompressed; 
 
         RasterImage loadedImage = rasterCodecs.Load(fileDataItem.Name, 
            0, 
            CodecsLoadByteOrder.BgrOrGray, 
            fileDataItem.PageNumber, 
            fileDataItem.PageNumber); 
 
         // COPY THE 'loadedImage' IMAGE. 
 
         loadedImage.Dispose(); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.WinForms.CommonDialogs.File 
 
Public Sub openDlg_Help(ByVal sender As Object, ByVal e As RasterDialogHelpEventArgs) Handles openDlg.Help 
   Select Case e.Dialog 
      Case RasterDialogHelpName.Open 
         MessageBox.Show("Open dialog Help") 
         Exit Select 
 
      Case RasterDialogHelpName.LoadOptions 
         MessageBox.Show("Load Options dialog Help") 
         Exit Select 
   End Select 
End Sub 
 
Public Sub openDlg_LoadProgress(ByVal sender As Object, ByVal e As RasterDialogLoadProgressEventArgs) Handles openDlg.LoadProgress 
   Dim displayText As String 
 
   displayText = "(" & e.FilePercent.ToString() & "%) of" & e.LoadRasterFileData.Name & "file is loaded" 
   MessageBox.Show(displayText) 
 
   displayText = "(" & e.TotalPercent.ToString() & "%) of all file(s) loading process is completed" 
   MessageBox.Show(displayText) 
End Sub 
 
WithEvents openDlg As RasterOpenDialog 
 
Public Sub RasterOpenDialogExample() 
   Dim rasterCodecs As RasterCodecs = New RasterCodecs() 
 
   openDlg = New RasterOpenDialog(rasterCodecs) 
 
   openDlg.Filter = New RasterOpenDialogLoadFormat() {New RasterOpenDialogLoadFormat("All Files", "*.*"), New RasterOpenDialogLoadFormat("LEAD", "*.cmp")} 
 
   openDlg.CheckFileExists = True 
   openDlg.CheckPathExists = True 
   openDlg.DefaultExt = "cmp" 
   openDlg.DereferenceLinks = True 
   openDlg.EnableSizing = True 
   openDlg.FileName = "Image.cmp" 
   openDlg.FilterIndex = 2 
   openDlg.GenerateThumbnail = False 
   openDlg.InitialDirectory = LEAD_VARS.ImagesDir 
   openDlg.InitialView = FileDialogInitialView.List 
   openDlg.LoadCompressed = True 
   openDlg.LoadFileImage = False 
   openDlg.LoadOptions = False 
   openDlg.LoadRotated = False 
   openDlg.Multiselect = True 
   openDlg.PreviewWindowVisible = True 
   openDlg.ShowDeletePage = True 
   openDlg.ShowFileInformation = True 
   openDlg.ShowGeneralOptions = True 
   openDlg.ShowHelp = True 
   openDlg.ShowLoadCompressed = True 
   openDlg.ShowLoadOptions = True 
   openDlg.ShowLoadRotated = True 
   openDlg.ShowMultipage = True 
   openDlg.ShowPdfOptions = True 
   openDlg.ShowXpsOptions = True 
   openDlg.ShowXlsOptions = True 
   openDlg.ShowVffOptions = True 
   openDlg.ShowAnzOptions = True 
   openDlg.ShowVectorOptions = True 
   openDlg.ShowPreview = True 
   openDlg.ShowProgressive = True 
   openDlg.ShowRasterOptions = True 
   openDlg.ShowTotalPages = True 
   openDlg.Title = "Open Dialog" 
   openDlg.UseFileStamptoPreview = True 
   openDlg.LoadCorrupted = True 
 
   If DialogResult.OK = openDlg.ShowDialog(Nothing) Then 
      For i As Integer = 0 To openDlg.OpenedFileData.Count 
         Dim fileDataItem As RasterDialogFileData = CType(openDlg.OpenedFileData(i), RasterDialogFileData) 
 
         ' this is not an image file. 
         If fileDataItem.Options Is Nothing Then 
            Continue For 
         End If 
 
         rasterCodecs.Options.RasterizeDocument.Load.PageWidth = fileDataItem.Options.RasterizeDocumentOptions.PageWidth 
         rasterCodecs.Options.RasterizeDocument.Load.PageHeight = fileDataItem.Options.RasterizeDocumentOptions.PageHeight 
         rasterCodecs.Options.RasterizeDocument.Load.LeftMargin = fileDataItem.Options.RasterizeDocumentOptions.LeftMargin 
         rasterCodecs.Options.RasterizeDocument.Load.TopMargin = fileDataItem.Options.RasterizeDocumentOptions.TopMargin 
         rasterCodecs.Options.RasterizeDocument.Load.RightMargin = fileDataItem.Options.RasterizeDocumentOptions.RightMargin 
         rasterCodecs.Options.RasterizeDocument.Load.BottomMargin = fileDataItem.Options.RasterizeDocumentOptions.BottomMargin 
         rasterCodecs.Options.RasterizeDocument.Load.Unit = fileDataItem.Options.RasterizeDocumentOptions.Unit 
         rasterCodecs.Options.RasterizeDocument.Load.XResolution = fileDataItem.Options.RasterizeDocumentOptions.XResolution 
         rasterCodecs.Options.RasterizeDocument.Load.YResolution = fileDataItem.Options.RasterizeDocumentOptions.YResolution 
         rasterCodecs.Options.RasterizeDocument.Load.SizeMode = fileDataItem.Options.RasterizeDocumentOptions.SizeMode 
 
         Select Case fileDataItem.Options.FileType 
            Case RasterDialogFileOptionsType.Meta 
               If Not Nothing Is fileDataItem.Options.MetaOptions Then 
                  rasterCodecs.Options.Wmf.Load.XResolution = fileDataItem.Options.MetaOptions.XResolution 
                  rasterCodecs.Options.Wmf.Load.YResolution = fileDataItem.Options.MetaOptions.XResolution 
               End If 
               Exit Select 
 
            Case RasterDialogFileOptionsType.Pdf 
               If (Not Nothing Is fileDataItem.Options.PdfOptions) AndAlso rasterCodecs.Options.Pdf.IsEngineInstalled Then 
                  rasterCodecs.Options.Pdf.Load.DisplayDepth = fileDataItem.Options.PdfOptions.DisplayDepth 
                  rasterCodecs.Options.Pdf.Load.GraphicsAlpha = fileDataItem.Options.PdfOptions.GraphicsAlpha 
 
                  If Not fileDataItem.Options.PdfOptions.Password Is Nothing Then 
                     rasterCodecs.Options.Pdf.Load.Password = fileDataItem.Options.PdfOptions.Password 
                  End If 
 
                  rasterCodecs.Options.Pdf.Load.TextAlpha = fileDataItem.Options.PdfOptions.TextAlpha 
                  rasterCodecs.Options.Pdf.Load.UseLibFonts = fileDataItem.Options.PdfOptions.UseLibFonts 
               End If 
               Exit Select 
 
            Case RasterDialogFileOptionsType.Misc 
               If Nothing Is fileDataItem.Options.MiscOptions Then 
                  Continue For 
               End If 
 
               Select Case fileDataItem.FileInfo.Format 
                  Case RasterImageFormat.Jbig 
                     rasterCodecs.Options.Jbig.Load.Resolution = New LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                                                                              fileDataItem.Options.MiscOptions.YResolution) 
                     Exit Select 
 
                  Case RasterImageFormat.Cmw 
                     rasterCodecs.Options.Jpeg2000.Load.CmwResolution = New LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                                                                                     fileDataItem.Options.MiscOptions.YResolution) 
                     Exit Select 
 
                  Case RasterImageFormat.Jp2 
                     rasterCodecs.Options.Jpeg2000.Load.Jp2Resolution = New LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                                                                                     fileDataItem.Options.MiscOptions.YResolution) 
                     Exit Select 
 
                  Case RasterImageFormat.J2k 
                     rasterCodecs.Options.Jpeg2000.Load.J2kResolution = New LeadSize(fileDataItem.Options.MiscOptions.XResolution, 
                                                                                     fileDataItem.Options.MiscOptions.YResolution) 
                     Exit Select 
               End Select 
               Exit Select 
            Case RasterDialogFileOptionsType.Xls 
               rasterCodecs.Options.Xls.Load.MultiPageSheet = fileDataItem.Options.XlsOptions.MultiPageSheet 
               Exit Select 
            Case RasterDialogFileOptionsType.Vff 
               rasterCodecs.Options.Vff.Load.View = fileDataItem.Options.VffOptions.View 
               Exit Select 
            Case RasterDialogFileOptionsType.Anz 
               rasterCodecs.Options.Anz.Load.View = fileDataItem.Options.AnzOptions.View 
               Exit Select 
            Case RasterDialogFileOptionsType.Vector 
               rasterCodecs.Options.Vector.Load.BackgroundColor = fileDataItem.Options.VectorOptions.Options.BackgroundColor 
               rasterCodecs.Options.Vector.Load.BitsPerPixel = fileDataItem.Options.VectorOptions.Options.BitsPerPixel 
               rasterCodecs.Options.Vector.Load.ForceBackgroundColor = fileDataItem.Options.VectorOptions.Options.ForceBackgroundColor 
               rasterCodecs.Options.Vector.Load.ViewHeight = fileDataItem.Options.VectorOptions.Options.ViewHeight 
               rasterCodecs.Options.Vector.Load.ViewMode = fileDataItem.Options.VectorOptions.Options.ViewMode 
               rasterCodecs.Options.Vector.Load.ViewWidth = fileDataItem.Options.VectorOptions.Options.ViewWidth 
               Exit Select 
         End Select 
 
         rasterCodecs.Options.Load.Passes = fileDataItem.Passes 
         rasterCodecs.Options.Load.Rotated = fileDataItem.LoadRotated 
         rasterCodecs.Options.Load.Compressed = fileDataItem.LoadCompressed 
 
         Dim loadedImage As RasterImage = rasterCodecs.Load(fileDataItem.Name, 0, CodecsLoadByteOrder.BgrOrGray, fileDataItem.PageNumber, fileDataItem.PageNumber) 
 
         ' COPY THE 'loadedImage' IMAGE. 
 
         loadedImage.Dispose() 
      Next 
   End If 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.WinForms.CommonDialogs.File Assembly