Example #1
0
 public TwainLocalOnTwainParameters
 (
     string a_szWriteFolder,
     string a_szImagesFolder,
     string a_szIpc,
     int a_iPid,
     TWAIN.RunInUiThreadDelegate a_runinuithreaddelegate,
     FormTwain a_formtwain,
     IntPtr a_intptrHwnd
 )
 {
     m_szWriteFolder         = a_szWriteFolder;
     m_szImagesFolder        = a_szImagesFolder;
     m_szIpc                 = a_szIpc;
     m_iPid                  = a_iPid;
     m_runinuithreaddelegate = a_runinuithreaddelegate;
     m_formtwain             = a_formtwain;
     m_intptrHwnd            = a_intptrHwnd;
 }
Example #2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public Methods...
        ///////////////////////////////////////////////////////////////////////////////
        #region Public Methods...

        /// <summary>
        /// Our constructor...
        /// </summary>
        public FormScan()
        {
            // Build our form...
            InitializeComponent();

            // Open the log in our working folder, and say hi...
            TWAINWorkingGroup.Log.Open("TWAINCSScan", ".", 1);
            TWAINWorkingGroup.Log.Info("TWAINCSScan v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());

            // Init other stuff...
            m_blIndicators    = true;
            m_blExit          = false;
            m_iUseBitmap      = 0;
            this.FormClosing += new FormClosingEventHandler(FormScan_FormClosing);

            // Create our image capture object...
            try
            {
                // Init stuff...
                TWAIN.DeviceEventCallback   deviceeventcallback   = DeviceEventCallback;
                TWAIN.ScanCallback          scancallback          = ScanCallbackTrigger;
                TWAIN.RunInUiThreadDelegate runinuithreaddelegate = RunInUiThread;

                // Instantiate TWAIN, and register ourselves...
                m_twain = new TWAIN
                          (
                    "TWAIN Working Group",
                    "TWAIN Open Source",
                    "TWAIN CS Scan App",
                    (ushort)TWAIN.TWON_PROTOCOL.MAJOR,
                    (ushort)TWAIN.TWON_PROTOCOL.MINOR,
                    ((uint)TWAIN.DG.APP2 | (uint)TWAIN.DG.CONTROL | (uint)TWAIN.DG.IMAGE),
                    TWAIN.TWCY.USA,
                    "TWAIN CS Scan App",
                    TWAIN.TWLG.ENGLISH_USA,
                    2,
                    4,
                    false,
                    false,
                    deviceeventcallback,
                    scancallback,
                    runinuithreaddelegate,
                    this.Handle
                          );
            }
            catch (Exception exception)
            {
                TWAINWorkingGroup.Log.Error("exception - " + exception.Message);
                m_twain  = null;
                m_blExit = true;
                MessageBox.Show
                (
                    "Unable to start, the most likely reason is that the TWAIN\n" +
                    "Data Source Manager is not installed on your system.\n\n" +
                    "An internet search for 'TWAIN DSM' will locate it and once\n" +
                    "installed, you should be able to proceed.\n\n" +
                    "You can also try the following link:\n" +
                    "http://sourceforge.net/projects/twain-dsm/",
                    "Error Starting TWAIN CS Scan"
                );
                return;
            }

            // Init our picture box...
            InitImage();

            // Prep for TWAIN events...
            SetMessageFilter(true);

            // Init our buttons...
            SetButtons(EBUTTONSTATE.CLOSED);
        }