Exemple #1
0
        public ScanForm(IntPtr mainForm)
        {
            this.components = new System.ComponentModel.Container();
            InitializeComponent();
            ms_Current = this;
            this.Text  = Application.ProductName.concat("-Scanner");

            bool defaultScanner         = SettingsTable.Get <bool>(Strings.VScan_TWAINUseDefaultScanner, false);
            bool defaultScannerSettings = SettingsTable.Get <bool>(Strings.VScan_TWAINUseDefaultScannerSettings, false);

            this.ShowIcon      = true;
            this.ShowInTaskbar = true;

            m_MainFormHandler = mainForm;

            m_twain          = new Twain();
            m_twain.MainForm = mainForm;
            m_twain.ScanForm = this.Handle;
            m_twain.Form     = this;
            m_twain.Init(this.Handle);

            if (defaultScanner)
            {
                var name = SettingsTable.Get <string>(Strings.VScan_ScannerName, Strings.VScan_DefaultScannerName);
                m_twain.Select(name);
            }

            AcquireVoucher(defaultScannerSettings);
        }
Exemple #2
0
        public static void Start(IntPtr hWnd)
        {
            if (ms_Thread != null)
            {
                return;
            }

            IntPtr handle = hWnd;

            ms_Thread = new Thread((h) =>
            {
                try
                {
                    ScanForm form = new ScanForm((IntPtr)h);
                    Application.Run(form);
                }
                catch (Exception ex)
                {
                    ex.ThrowAndForget();
                }
                finally
                {
                    ms_Thread = null;
                }
            })
            {
                IsBackground = true
            };
            ms_Thread.Start(handle);
        }
Exemple #3
0
 private void Scan()
 {
     WaitForm.StartAsync(this);
     ScanForm.Start(this.Handle);
 }