private void _miWiaAcquire_Click(object sender, System.EventArgs e) { WiaAcquireFlags flags = WiaAcquireFlags.None; bool showProgress = true; _progressDlg = new ProgressForm(DemosGlobalization.GetResxString(GetType(), "Resx_Transferring"), "", 100); _wiaAcquiring = true; if (_showUserInterface) { flags = WiaAcquireFlags.UseCommonUI | WiaAcquireFlags.ShowUserInterface; } else { // Check if the selected device is scanner and that it has multiple sources (Feeder & Flatbed) // then show the select source dialog box. if (SelectAcquireSource() != DialogResult.OK) { _wiaAcquiring = false; return; } } if (_showUserInterface) { if (_wiaVersion == WiaVersion.Version2) { showProgress = false; } } if (showProgress) { // Show the progress dialog. _progressDlg.Show(this); } try { _wiaSession.AcquireOptions = _wiaAcquireOptions; if (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) // GetProperties() method not called yet. { _transferMode = WiaTransferMode.Memory; } else { _transferMode = _wiaProperties.DataTransfer.TransferMode; } // Disable the minimize and maximize buttons. this.MinimizeBox = false; this.MaximizeBox = false; #if !LEADTOOLS_V19_OR_LATER DialogResult dialogResult = _wiaSession.Acquire(this, _sourceItem, flags); #else DialogResult dialogResult = _wiaSession.Acquire(this.Handle, _sourceItem, flags); #endif // #if !LEADTOOLS_V19_OR_LATER if (dialogResult != DialogResult.OK) { return; } // Enable back the minimize and maximize buttons. this.MinimizeBox = true; this.MaximizeBox = true; if (_progressDlg.Visible) { if (!_progressDlg.Abort) { _progressDlg.Dispose(); } } if (_sourceItem != null) { _sourceItem = null; } if (_wiaSession.FilesCount > 0) // This property indicates how many files where saved when the transfer mode is File mode. { string strMsg = DemosGlobalization.GetResxString(GetType(), "Resx_PagesSavedTo") + "\n\n"; if (_wiaSession.FilesPaths.Count > 0) { for (int i = 0; i < _wiaSession.FilesPaths.Count; i++) { string strTemp = string.Format("{0}\n", _wiaSession.FilesPaths[i]); strMsg += strTemp; } MessageBox.Show(this, strMsg, DemosGlobalization.GetResxString(GetType(), "Resx_FileTransfer"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // WIA 2.0 sometimes doesn't return the acquired files count and paths, so this message will show // the directory where the saved files were saved. if (_wiaVersion == WiaVersion.Version2) { int len = _wiaAcquireOptions.FileName.LastIndexOf('\\'); string strFilesDirectory = _wiaAcquireOptions.FileName.Substring(0, len); string strMsg = string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_PagesSavedTo") + "\n\n{0}", strFilesDirectory); MessageBox.Show(this, strMsg, DemosGlobalization.GetResxString(GetType(), "Resx_FileTransfer"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } _wiaAcquiring = false; } catch (Exception ex) { // Enable back the minimize and maximize buttons. this.MinimizeBox = true; this.MaximizeBox = true; _wiaAcquiring = false; if (_progressDlg.Visible) { if (!_progressDlg.Abort) { _progressDlg.Dispose(); } } Messager.ShowError(this, ex); } finally { // Enable back the minimize and maximize buttons. this.MinimizeBox = true; this.MaximizeBox = true; _wiaAcquiring = false; } }
private void _miWiaAcquire_Click(object sender, System.EventArgs e) { bool bTopMost = logWindow.TopMost; logWindow.TopMost = false; WiaAcquireFlags flags; bool showProgress = true; _progressDlg = new ProgressForm("Transferring...", "", 100); _wiaAcquiring = true; flags = WiaAcquireFlags.UseCommonUI; if (_showUserInterface) { flags |= WiaAcquireFlags.ShowUserInterface; } else { // Check if the selected device is scanner and that it has multiple sources (Feeder & Flatbed) // then show the select source dialog box. if (SelectAcquireSource() != DialogResult.OK) { _wiaAcquiring = false; logWindow.TopMost = bTopMost; return; } } if (_showUserInterface) { if (_wiaVersion == WiaVersion.Version1) { showProgress = true; } else { showProgress = false; } } else { showProgress = true; } if (showProgress) { // Show the progress dialog. _progressDlg.Show(this); } try { _wiaSession.AcquireOptions = _wiaAcquireOptions; if (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) // GetProperties() method not called yet. { _wiatransferMode = WiaTransferMode.Memory; } else { _wiatransferMode = _wiaProperties.DataTransfer.TransferMode; } // Disable the minimize and maximize buttons. this.MinimizeBox = false; this.MaximizeBox = false; wiaImageCollection = new ListImageBox.ImageCollection("WIA Scanned"); #if LEADTOOLS_V19_OR_LATER _wiaSession.Acquire(this.Handle, _sourceItem, flags); #else _wiaSession.Acquire(this, _sourceItem, flags); #endif // #if LEADTOOLS_V19_OR_LATER // Enable back the minimize and maximize buttons. this.MinimizeBox = true; this.MaximizeBox = true; if (_progressDlg.Visible) { if (!_progressDlg.Abort) { _progressDlg.Dispose(); } } if (_enumeratedItemsList.Count > 0) { _enumeratedItemsList.Clear(); } if (_sourceItem != null) { _sourceItem = null; } if (_wiaSession.FilesCount > 0) // This property indicates how many files where saved when the transfer mode is File mode. { string strMsg = "Acquired page(s) were saved to:\n\n"; if (_wiaSession.FilesPaths.Count > 0) { for (int i = 0; i < _wiaSession.FilesPaths.Count; i++) { string strTemp = string.Format("{0}\n", _wiaSession.FilesPaths[i]); strMsg += strTemp; } MessageBox.Show(this, strMsg, "File Transfer", MessageBoxButtons.OK, MessageBoxIcon.Information); } } _wiaAcquiring = false; } catch (Exception ex) { // Enable back the minimize and maximize buttons. this.MinimizeBox = true; this.MaximizeBox = true; _wiaAcquiring = false; if (_progressDlg.Visible) { if (!_progressDlg.Abort) { _progressDlg.Dispose(); } } Messager.ShowError(this, ex); } if (wiaImageCollection.Images.Count > 0) { _lstBoxPages.AddImageCollection(wiaImageCollection); } logWindow.TopMost = bTopMost; }