示例#1
0
        void _wiaSession_AcquireEvent(object sender, WiaAcquireEventArgs e)
        {
            string strInfoMsg;

            // Update the progress bar with the received percent value;
            if (_progressDlg.Visible)
            {
                // Show the user some information about the file we are acquiring
                // to (if the user chooses file transfer).

                if ((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage)
                {
                    if (_wiatransferMode == WiaTransferMode.File)
                    {
                        strInfoMsg = string.Format("Transferring to file:\n\n{0}", e.FileName);
                        _progressDlg.InformationString = strInfoMsg;
                    }
                }

                if (((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage) &&
                    ((e.Flags & WiaAcquiredPageFlags.EndOfPage) != WiaAcquiredPageFlags.EndOfPage))
                {
                    _progressDlg.Percent = 0;
                }
                else
                {
                    _progressDlg.Percent = (Int32)e.Percent;
                }

                Application.DoEvents();

                if (_progressDlg.Abort)
                {
                    e.Cancel = true;
                }
            }

            if (_wiatransferMode != WiaTransferMode.File)
            {
                if (e.Image != null)
                {
                    Page page = new Page();
                    page.DeleteOnDispose = false;
                    string strTemp = Path.GetTempFileName();
                    _codec.Save(e.Image, strTemp, Leadtools.RasterImageFormat.Tif, 0);
                    page.FilePath = strTemp;
                    wiaImageCollection.Images.Add(new ListImageBox.ImageItem(_codec.Load(strTemp), wiaImageCollection, page));
                    e.Image.Dispose();
                    Application.DoEvents();
                }
            }
        }
示例#2
0
        void _wiaSession_AcquireEvent(object sender, WiaAcquireEventArgs e)
        {
            string strInfoMsg;

            // Update the progress bar with the received percent value;
            if (_progressDlg.Visible)
            {
                // Show the user some information about the file we are acquiring
                // to (if the user chooses file transfer).

                if ((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage)
                {
                    if (_transferMode == WiaTransferMode.File)
                    {
                        strInfoMsg = string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_TransferringToFile:") + "\n\n{0}", e.FileName);
                        _progressDlg.InformationString = strInfoMsg;
                    }
                }

                if (((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage) &&
                    ((e.Flags & WiaAcquiredPageFlags.EndOfPage) != WiaAcquiredPageFlags.EndOfPage))
                {
                    _progressDlg.Percent = 0;
                }
                else
                {
                    _progressDlg.Percent = (Int32)e.Percent;
                }

                Application.DoEvents();

                if (_progressDlg.Abort)
                {
                    e.Cancel = true;
                }
            }

            if (_transferMode != WiaTransferMode.File)
            {
                if (e.Image != null)
                {
                    _scanCount++;
                    string childCaption = string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_WIAScannedPage") + " {0}", _scanCount.ToString());
                    CreateChildForm(e.Image, childCaption);

                    Application.DoEvents();
                }
            }
        }