Beispiel #1
0
        void _engine_CaptureInformation(object sender, ScreenCaptureInformationEventArgs e)
        {
            ListImageBox.ImageCollection imagecollection = new ListImageBox.ImageCollection("Captured Image");
            Page   page    = new Page();
            string strTemp = null;

            page    = new Page();
            strTemp = Path.GetTempFileName();
            _codec.Save(e.Image, strTemp, RasterImageFormat.Tif, 0);
            page.FilePath        = strTemp;
            page.DeleteOnDispose = true;
            imagecollection.Images.Add(new ListImageBox.ImageItem(_codec.Load(strTemp), imagecollection, page));
            e.Image.Dispose();

            _lstBoxPages.AddImageCollection(imagecollection);
            _captureType = CaptureType.None;
            _engine.StopCapture();
            UpdateScreenCaptureItems();
            this.Invalidate();
        }
Beispiel #2
0
        private void _miTwainAcquire_Click(object sender, System.EventArgs e)
        {
            bool bTopMost = logWindow.TopMost;

            logWindow.TopMost = false;
            try
            {
                SetTransferMode();
                // Acquire one or more images from a TWAIN source.
                twainImageCollection = new ListImageBox.ImageCollection("Twain Aquire");
                _twainSession.Acquire(TwainUserInterfaceFlags.Show | TwainUserInterfaceFlags.Modal);
            }
            catch (Exception ex)
            {
                AddErrorToErrorList(ex.Message);
                MessageBox.Show(this, ex.Message);
            }
            if (twainImageCollection.Images.Count > 0)
            {
                _lstBoxPages.AddImageCollection(twainImageCollection);
            }

            logWindow.TopMost = bTopMost;
        }
Beispiel #3
0
        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;
        }