Esempio n. 1
0
 void _twain_ScanningComplete(object sender, ScanningCompleteEventArgs e)
 {
     OnScanDone();
 }
Esempio n. 2
0
 void ScanningComplete(object sender, ScanningCompleteEventArgs e)
 {
     this.dataReady = true;
     this.scanSemaphore.Release();
 }
Esempio n. 3
0
        private void TwainScanningComplete(object sender, ScanningCompleteEventArgs e)
        {
            if (ScannedImages == null) throw new ApplicationException("Není inicializována kolekce pro uložení naskenovaných obrázků.");

            try
            {
                if (e.Exception == null)
                {
                    if (Settings.Default.ScannerSaveToFile)
                    {
                        Logger.Log(String.Format("TwainScanningComplete-FILE"));
                        string fileName = System.IO.Path.Combine(Settings.Default.ScanFolderPath, TWAIN_SCAN_FILENAME);

                        if (File.Exists(fileName))
                        {
                            ScanBitmapSource = ImageFunctions.Load(fileName);
                            Logger.Log("TwainScanningComplete-Load");
                        }
                        else
                        {
                            string message = String.Format("Nepodařilo se načíst naskenovaný soubor {0}.", TWAIN_SCAN_FILENAME);
                            Logger.Log(String.Format("TWAIN: {0}", message));
                        }
                    }
                    else
                    {
                        Logger.Log(String.Format("TwainScanningComplete-MEMORY"));
                    }

                    if (ScanBitmapSource != null)
                    {
                        if (Settings.Default.AutoRotateEvenPage && ScannedImages.IsNextEvenPage(MainScanImage.IsCover))
                        {
                            ScanBitmapSource = ImageFunctions.Rotate180(ScanBitmapSource);
                            Logger.Log(String.Format("TwainScanningComplete-Rotate180"));
                        }

                        if (Settings.Default.AutomaticColorCorection && !MainScanImage.BlackAndWhite)
                        {
                            ScanBitmapSource = ImageFunctions.AutoColorCorrections(ScanBitmapSource);
                            Logger.Log(String.Format("TwainScanningComplete-AutoColorCorrections"));
                        }

                        MainScanImage.Dpi = TwainSettings.Resolution.Dpi;
                        MainScanImage.BlackAndWhite = (TwainSettings.Resolution.ColourSetting == ColourSetting.BlackAndWhite);
                        MainScanImage.Save(ScanBitmapSource);
                        Logger.Log(String.Format("TwainScanningComplete-Save"));

                        ScannedImages.Add(MainScanImage);
                        SelectedScanImage = MainScanImage;
                        //ScanBitmapSource = null;
                    }
                    else
                    {
                        string message = "Nepodařilo se naskenovat obrázek.";
                        MessageBox.Show(message, "TwainScanningComplete", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        Logger.Log(String.Format("TWAIN: {0}", message));
                    }
                }
                else
                {
                    MessageBox.Show(e.Exception.Message, e.Exception.Source, MessageBoxButton.OK, MessageBoxImage.Error);
                    Logger.Log(String.Format("TWAIN: {0}", e.Exception.Message));
                }
            }
            catch (TwainException tx)
            {
                string message = String.Format("{0}\nConditionCode={1}\nReturnCode={2}.", tx.Message, tx.ConditionCode, tx.ReturnCode);
                MessageBox.Show(message, tx.Source, MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Log(String.Format("TWAIN: {0}", message));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Error);
                Logger.Log(String.Format("ERROR: {0}", ex.Message));
            }
            finally
            {
                SetMenuButtonsEnabled();
                SetBookInfoPanel();
                GetAvailableMemory();
                Logger.Log("TwainScanningComplete-Finally");
            }

            Timer.Stop();
            SetTimetatusBar(Timer.Elapsed);
        }
Esempio n. 4
0
		private void Twain_ScanningComplete(object sender, ScanningCompleteEventArgs e)
		{
			_twain.ScanningComplete -= Twain_ScanningComplete;
			_twain.TransferImage -= Twain_TransferImage;
			Log("Scanning complete");
			_scanCompleteEvent.Set();
		}
Esempio n. 5
0
 /// <summary>
 /// FrontTwain_ScanningComplete is the delegate to handle what happens after the front of the image is completed.
 /// <para>If this is a 'New' or 'Initial' Scan then it will proceed with doing the back side of the card.</para>
 /// <para>This will also start the timer of the application, if not already running, to remove all items from the screen if not sent to chart within 2 minutes of the first scan.</para>
 /// </summary>
 /// <param name="sender">Object</param>
 /// <param name="e">ScanningCompleteEventArgs</param>
 void FrontTwain_ScanningComplete(Object sender, ScanningCompleteEventArgs e)
 {
     if (isScanBoth)
         backTwain.StartScanning(TwainScanSettings);
     if (!tmrToClear.Enabled)
         tmrToClear.Start();
 }
Esempio n. 6
0
 /// <summary>
 /// BackTwain_ScanningComplete is the delegate to handle what happens after the back card scanner is completed.
 /// <para>If this is a 'New' or 'Initial' Scan then it will proceed with getting the MRN #.</para>
 /// <para>This will also start the timer of the application, if not already running, to remove all items from the screen if not sent to chart within 2 minutes of the first scan.</para>
 /// </summary>
 /// <param name="sender">Object</param>
 /// <param name="e">ScanningCompleteEventArgs</param>
 void BackTwain_ScanningComplete(Object sender, ScanningCompleteEventArgs e)
 {
     if (isFirstTime)
     {
         BtnGetMrnClick(null, null);
         isFirstTime = false;
     }
     if (!tmrToClear.Enabled)
         tmrToClear.Start();
 }