Example #1
0
//      public ArrayList AcquireImages(IntPtr windowHandle)
//      {
//
//      }

        ///<summary>
        /// Displays TWAIN device selection dialog.
        ///</summary>
        public void SelectDevice(IntPtr windowHandle)
        {
            // initialize TwainSource
            if (_twainSource == null)
            {
                _twainSource = new TwainSource(windowHandle);
            }

            DefaultDevice = _twainSource.SelectTwainSource();
        }
Example #2
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="T:System.ComponentModel.Component"/> and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.
        ///                 </param>
        protected override void Dispose(bool disposing)
        {
            SaveOptions();

            if (_twainSource != null)
            {
                _twainSource.TransferStarted  -= twainSource_TransferStarted;
                _twainSource.TransferFinished -= twainSource_TransferFinished;
                _twainSource.Dispose();
                _twainSource = null;
            }

            base.Dispose(disposing);
        }
Example #3
0
        private void DoScan(IntPtr windowHandle)
        {
            // initialize TwainSource
            if (_twainSource == null)
            {
                _twainSource = new TwainSource(windowHandle);
            }

            _twainSource.TransferStarted  -= new EventHandler(twainSource_TransferStarted);
            _twainSource.TransferFinished -= new EventHandler(twainSource_TransferFinished);
            _twainSource.TransferStarted  += new EventHandler(twainSource_TransferStarted);
            _twainSource.TransferFinished += new EventHandler(twainSource_TransferFinished);

            _twainSource.SaveTo             = this.SaveTo;
            _twainSource.OutputFolder       = this.OutputFolder;
            _twainSource.JpegQuality        = this.JpegQuality;
            _twainSource.TiffCompression    = TranslateTiffCompression(this.TiffCompression);
            _twainSource.FileNamingTemplate = _fileNamingTemplate;

            switch (this.OutputFormat)
            {
            case OutputFormat.JPEG:
                _twainSource.ImageFileFormat = ImageFormat.Jpeg;
                break;

            case OutputFormat.PNG:
                _twainSource.ImageFileFormat = ImageFormat.Png;
                break;

            case OutputFormat.TIFF:
                _twainSource.ImageFileFormat = ImageFormat.Tiff;
                break;

            case OutputFormat.BMP:
                _twainSource.ImageFileFormat = ImageFormat.Bmp;
                break;
                //              case OutputFormats.GIF:
                //                  twainSource.ImageFileFormat = ImageFormat.Gif;
                //                  break;
            }

            _twainSource.ShowTwainUi();
        }
        private void DoScan(IntPtr windowHandle)
        {
            // initialize TwainSource
            if (_twainSource == null)
            {
                _twainSource = new TwainSource(windowHandle);
            }

            _twainSource.TransferStarted -= new EventHandler(twainSource_TransferStarted);
            _twainSource.TransferFinished -= new EventHandler(twainSource_TransferFinished);
            _twainSource.TransferStarted += new EventHandler(twainSource_TransferStarted);
            _twainSource.TransferFinished += new EventHandler(twainSource_TransferFinished);

            _twainSource.SaveTo = this.SaveTo;
            _twainSource.OutputFolder = this.OutputFolder;
            _twainSource.JpegQuality = this.JpegQuality;
            _twainSource.TiffCompression = TranslateTiffCompression(this.TiffCompression);
            _twainSource.FileNamingTemplate = _fileNamingTemplate;

            switch (this.OutputFormat)
            {
                case OutputFormat.JPEG:
                _twainSource.ImageFileFormat = ImageFormat.Jpeg;
                break;
                case OutputFormat.PNG:
                _twainSource.ImageFileFormat = ImageFormat.Png;
                break;
                case OutputFormat.TIFF:
                _twainSource.ImageFileFormat = ImageFormat.Tiff;
                break;
                case OutputFormat.BMP:
                _twainSource.ImageFileFormat = ImageFormat.Bmp;
                break;
                // 				case OutputFormats.GIF:
                // 					twainSource.ImageFileFormat = ImageFormat.Gif;
                // 					break;
            }

            _twainSource.ShowTwainUi();
        }
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="T:System.ComponentModel.Component"/> and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources. 
        ///                 </param>
        protected override void Dispose(bool disposing)
        {
            SaveOptions();

            if (_twainSource != null)
            {
                _twainSource.TransferStarted -= twainSource_TransferStarted;
                _twainSource.TransferFinished -= twainSource_TransferFinished;
                _twainSource.Dispose();
                _twainSource = null;
            }

            base.Dispose(disposing);
        }
        // 		public ArrayList AcquireImages(IntPtr windowHandle)
        // 		{
        //
        // 		}
        ///<summary>
        /// Displays TWAIN device selection dialog.
        ///</summary>
        public void SelectDevice(IntPtr windowHandle)
        {
            // initialize TwainSource
            if (_twainSource == null)
            {
                _twainSource = new TwainSource(windowHandle);
            }

            DefaultDevice = _twainSource.SelectTwainSource();
        }