Ejemplo n.º 1
0
        private void btnAcquire_Click(object sender, System.EventArgs e)
        {
            if (dlgFileSave.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            strFileName = dlgFileSave.FileName;

            m_TwainManager.OpenSource();

            try
            {
                m_TwainManager.TransferMode = Dynamsoft.TWAIN.Enums.TWICapSetupXFer.TWSX_FILE;
            }
            catch (Exception exp)
            {
                MessageBox.Show("The license for TWAIN module is invalid.Please contact [email protected] to get a trial license.");
                return;
            }


            //Since the TWSX_FILE mode is not required by TWAIN specification,
            //it is better to read the value back to see if the File transfer mode is supported by the Source
            if (m_TwainManager.TransferMode == Dynamsoft.TWAIN.Enums.TWICapSetupXFer.TWSX_FILE)
            {                                                                                                 //the source supports the TWSX_FILE transfer mode.
                m_TwainManager.SetFileXFERInfo(strFileName, Dynamsoft.TWAIN.Enums.TWICapFileFormat.TWFF_BMP); //Sets file name and file format information.
                m_TwainManager.IfShowUI = false;
                m_TwainManager.IfDisableSourceAfterAcquire = true;
                m_TwainManager.EnableSource(this as IAcquireCallback); //Acquire the image.
            }
            else                                                       //the source doesn't support the TWSX_FILE transfer mode.
            {
                MessageBox.Show("The source doesn't support the DiskFile transfer mode.");
            }
        }