Displays the Open dialog box, and gets the options for
Load.
Object Model
Syntax
Visual Basic (Declaration) | |
---|
Public Class RasterOpenDialog |
C# | |
---|
public class RasterOpenDialog |
Managed Extensions for C++ | |
---|
public __gc class RasterOpenDialog |
C++/CLI | |
---|
public ref class RasterOpenDialog |
Example
Visual Basic | Copy Code |
---|
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()
Leadtools.Codecs.RasterCodecs.Startup()
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 = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"
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.ShowPreview = True
openDlg.ShowProgressive = True
openDlg.ShowRasterOptions = True
openDlg.ShowTotalPages = True
openDlg.Title = "Open Dialog"
openDlg.UseFileStamptoPreview = True
If DialogResult.OK = openDlg.ShowDialog(Nothing) Then
Dim i As Integer = 0
Do While i < openDlg.OpenedFileData.Count
Dim fileDataItem As RasterDialogFileData = CType(openDlg.OpenedFileData(i), RasterDialogFileData)
If fileDataItem.Options Is Nothing Then
GoTo Continue1
End If
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
rasterCodecs.Options.Pdf.Load.XResolution = fileDataItem.Options.PdfOptions.XResolution
rasterCodecs.Options.Pdf.Load.YResolution = fileDataItem.Options.PdfOptions.YResolution
End If
Exit Select
Case RasterDialogFileOptionsType.Misc
If Nothing Is fileDataItem.Options.MiscOptions Then
GoTo Continue1
End If
Select Case fileDataItem.FileInfo.Format
Case RasterImageFormat.Jbig
rasterCodecs.Options.Jbig.Load.Resolution = New Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution)
Exit Select
Case RasterImageFormat.Cmw
rasterCodecs.Options.Jpeg2000.Load.CmwResolution = New Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution)
Exit Select
Case RasterImageFormat.Jp2
rasterCodecs.Options.Jpeg2000.Load.Jp2Resolution = New Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution)
Exit Select
Case RasterImageFormat.J2k
rasterCodecs.Options.Jpeg2000.Load.J2kResolution = New Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution)
Exit Select
End Select
Exit Select
Case RasterDialogFileOptionsType.Xps
rasterCodecs.Options.Xps.Load.Resolution = New Size(fileDataItem.Options.XpsOptions.XResolution, fileDataItem.Options.XpsOptions.YResolution)
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)
loadedImage.Dispose()
Continue1:
i += 1
Loop
End If
Leadtools.Codecs.RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
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.Startup(); 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 = "Image.cmp"; openDlg.FilterIndex = 2; openDlg.GenerateThumbnail = false; openDlg.InitialDirectory = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"; 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.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); // 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; } 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; rasterCodecs.Options.Pdf.Load.XResolution = fileDataItem.Options.PdfOptions.XResolution; rasterCodecs.Options.Pdf.Load.YResolution = fileDataItem.Options.PdfOptions.YResolution; } break; } case RasterDialogFileOptionsType.Misc: { if(null == fileDataItem.Options.MiscOptions) { continue; } switch(fileDataItem.FileInfo.Format) { case RasterImageFormat.Jbig: { rasterCodecs.Options.Jbig.Load.Resolution = new Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution); break; } case RasterImageFormat.Cmw: { rasterCodecs.Options.Jpeg2000.Load.CmwResolution = new Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution); break; } case RasterImageFormat.Jp2: { rasterCodecs.Options.Jpeg2000.Load.Jp2Resolution = new Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution); break; } case RasterImageFormat.J2k: { rasterCodecs.Options.Jpeg2000.Load.J2kResolution = new Size(fileDataItem.Options.MiscOptions.XResolution, fileDataItem.Options.MiscOptions.YResolution); break; } } break; } case RasterDialogFileOptionsType.Xps: { rasterCodecs.Options.Xps.Load.Resolution = new Size(fileDataItem.Options.XpsOptions.XResolution, fileDataItem.Options.XpsOptions.YResolution); 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(); } } RasterCodecs.Shutdown(); } |
Remarks
Inheritance Hierarchy
System.Object
Leadtools.WinForms.CommonDialogs.File.RasterOpenDialog
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also