This project has moved. For the latest updates, please go here.

how to disable message for is complete after _twain32.EndXfer for all scan

Apr 12, 2016 at 7:43 AM
Edited Apr 12, 2016 at 11:12 AM
hello,
how to not show qustion is complete after scan from feeder ?
i used this code :
 public string scanimage()
           
        {
            //string sourcename = "0-Color Network ScanGear V2.71";
            //float resolution = 200;
            List<string> resolutions = new List<string>();
            using (Twain32 _twain32 = new Twain32())
            {
                _twain32.ShowUI = false;
                _twain32.IsTwain2Enable = false;
                //_twain32.CloseDSM();
                _twain32.OpenDSM();


                //if (_twain32.SourcesCount != 0)
                //{
                //    for (var i = 0; i < _twain32.SourcesCount; i++)
                //    {
                //        if (sourcename == _twain32.GetSourceProductName(i)) 
                //        {
                             _twain32.CloseDataSource();
                            _twain32.SourceIndex =0;
                           // _twain32.SelectSource();//.s.GetCurrentCap(TwCap..GetIsSourceTwain2Compatible(i);
                            _twain32.OpenDataSource();
                //            break;
                //        }

                //    }

                //}
             //  var x = _twain32.GetDefaultCap(TwCap.FeederType);

                var _resolutions = _twain32.Capabilities.XResolution.Get();
                _twain32.Capabilities.Indicators.Set(false);
                //_twain32.Capabilities.UIControllable.Set(false);
                _twain32.Capabilities.FeederLoaded.Set(false);
               // _twain32.Capabilities.
                _twain32.Capabilities.XResolution.Set(200);
                _twain32.Capabilities.YResolution.Set(200);
                  _twain32.Capabilities.PixelType.Set(TwPixelType.RGB);
               // _twain32.Capabilities.AutomaticLengthDetection.Set(true);
                //_twain32.DisableAfterAcquire = false;
                // _twain32.Capabilities.XferCount.Set(1);

                  //_twain32.Capabilities.PaperDetectable.Set(true);
                //_twain32.Capabilities.FeederEnabled.Set(false);
                //_twain32.Capabilities.FeederOrder.Set(TwFO.LastPageFirst);
                // _twain32.Capabilities.FeedPage.Set(true);

                _twain32.EndXfer += (object sender, Twain32.EndXferEventArgs e) =>
                {
                    try
                    {
                        countimage++;
                        //if (e.Image != null)
                        //{
                        //    
                        //    //var _file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".jpg"));

                        //    //e.Image.Save(_file, ImageFormat.Jpeg);

                        //}
                      //  if (countimage  == _twain32.ImageCount) _twain32.Capabilities.XferCount.Set(1);

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("{0}: {1}{2}{3}{2}", ex.GetType().Name, ex.Message, Environment.NewLine, ex.StackTrace);
                    }
                };


                //   _twain32.TwainStateChanged += (sender, e) => { int p = 0; };


                _twain32.AcquireCompleted += (sender, e) => {
                   
                        try
                        {
                            for (int i = 0; i < _twain32.ImageCount; i++)
                            {
                            var _file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".jpg"));

                            _twain32.GetImage(i).Save(_file, ImageFormat.Jpeg);
                            }
                        //_twain32.Dispose();
                        }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);// Program.WriteException(ex);
                    }
                };

                
                _twain32.AcquireError += (object sender, Twain32.AcquireErrorEventArgs e) => {
                    try
                    {

                        Console.WriteLine();
                        Console.WriteLine("Acquire Error: ReturnCode = {0}; ConditionCode = {1};", e.Exception.ReturnCode, e.Exception.ConditionCode);
                        Console.WriteLine(e.Exception.Message);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                };

                _twain32.Acquire();

                return "ok";
            }

        }
Coordinator
Apr 12, 2016 at 6:33 PM
Hello, amir3321.
This question is outside the Saraff.Twain.NET project boundary. See a TWAIN Specification.
Marked as answer by SARAFF on 4/12/2016 at 11:33 AM
Apr 13, 2016 at 4:11 AM
Thanks saraff,
How can I scan is finished ? Which event ?
after complete scan fire _twain32.EndXfer for each scan and before fire _twain32.AcquireCompleted event => show message is complete and are you countinue or end ;
how to fire _twain32.AcquireCompleted manual !!!
Please help me;
Coordinator
Apr 13, 2016 at 8:23 PM
Hello, amir3321.
Manually fire a Twain32.AcquireCompleted event is impossible. The message about "countinue or end" is shown directly the driver of your scanner. Try set CAP_AUTOFEED to false.