private void btnCalibrate_Click(object sender, RoutedEventArgs e) { bool isPaperOn = false; Twain twain = null; try { twain = new Twain(new WpfWindowMessageHook(this)); twain.SelectSource("A8 ColorScanner PP"); isPaperOn = twain.CalibrateA8(); twain.Dispose(); } catch (TwainException ex) { Console.WriteLine(ex); isPaperOn = false; twain?.Dispose(); } catch (Exception ex) { Console.WriteLine(ex); isPaperOn = false; twain?.Dispose(); } }
private void btnPaperOn_Click(object sender, RoutedEventArgs e) { bool isPaperOn = false; Twain twain = null; try { twain = new Twain(new WpfWindowMessageHook(this)); twain.SelectSource("A8 ColorScanner PP"); isPaperOn = twain.IsPaperOn(); twain.Dispose(); } catch (TwainException ex) { Console.WriteLine(ex); isPaperOn = false; twain?.Dispose(); } catch (Exception ex) { Console.WriteLine(ex); isPaperOn = false; twain?.Dispose(); } if (isPaperOn) { MessageBox.Show("有紙"); } else { MessageBox.Show("沒紙"); } }
public Scanning() { this.InitializeComponent(); //// this.firstImagePath = tempPath; tw = new Twain(); tw.Init(this.Handle); }
public frmTwain() { InitializeComponent(); tw = new Twain(); tw.Init(this.Handle); GetGlobalParameters(); }
public cBaseTwainScan(Form winForm) { ActiveForm = winForm; _twain = new Twain(new WinFormsWindowMessageHook(winForm)); DJScanCompletList = new List <string>(); DJOneScanList = new List <string>(); _twain.TransferImage += delegate(Object sender, TransferImageEventArgs args) { if (args.Image != null) { string img = DJScanPath + DateTime.Now.ToString(@"\" + DJScanTitle + "yyMMddHHmmssff") + ".jpg"; args.Image.Save(img, System.Drawing.Imaging.ImageFormat.Jpeg); DJImageProcess.EncryptJpg(img, DJJpgEncodeLevel, DJImgEncrypt); //DJScanCompletList.Add(img); DJOneScanList.Add(img); } }; _twain.ScanningComplete += delegate { ResetImgToAB(DJOneScanList); DJScanCompletList.AddRange(DJOneScanList); winForm.Enabled = true; winForm.Activate(); ScanComplete(winForm); //ScanComplete.Invoke(winForm); DJOneScanList.Clear(); }; }
private void scan_twain_Click(object sender, RoutedEventArgs e) { reportViewer.Reset(); // Tarihi yaz txtTarih.Text = DateTime.Now.ToShortDateString(); _twain = new Twain(new TwainDotNet.Wpf.WpfWindowMessageHook(this)); _twain.TransferImage += _twain_TransferImage; _twain.ScanningComplete += _twain_ScanningComplete; var ss = new ScanSettings(); ss.UseDuplex = true; //ss.ShowTwainUI = true; ss.Rotation = new RotationSettings() { AutomaticRotate = true }; ss.Resolution = new ResolutionSettings() { ColourSetting = ColourSetting.Colour, Dpi = 72 }; _twain.StartScanning(ss); }
public void Initialize(Form form) { try { m_Twain = new Twain(new WinFormsWindowMessageHook(form)); m_CurrentScanSettings = new ScanSettings { ShowProgressIndicatorUI = true, Resolution = ResolutionSettings.ColourPhotocopier, Rotation = new RotationSettings() { AutomaticRotate = true, AutomaticBorderDetection = true, } }; m_Twain.ScanningComplete += delegate { IsScanning = false; }; IsInitialized = true; } catch (Exception e) { IsInitialized = false; } }
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); }
private void frmFunSet_Load(object sender, EventArgs e) { this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;//去掉窗体边框 try { string setValue = SetConfig.GetValue("ScanDrive"); _twain = new Twain(new WinFormsWindowMessageHook(this)); List <DictionaryEntry> listDS = _twain.GetAllSources().Select(x => new DictionaryEntry() { Key = x.SourceId.ProductName, Value = x.SourceId.ProductName + " " + x.SourceId.Version.Info }).ToList(); int index = listDS.FindIndex(x => x.Key.ToString() == setValue); dgvCompany.DataSource = listDS; if ((dgvCompany.DataSource as List <DictionaryEntry>) != null && (dgvCompany.DataSource as List <DictionaryEntry>).Count > 0) { dgvCompany.ClearSelection(); } if (index >= 0) { dgvCompany.Rows[index].Selected = true; dgvCompany.CurrentCell = this.dgvCompany.Rows[index].Cells[1]; } } catch (Exception) { //MessageBox.Show("未检测到有扫描仪驱动!"); } }
public Window1() { InitializeComponent(); Loaded += delegate { _twain = new Twain(new WpfWindowMessageHook(this)); _twain.TransferImage += delegate(Object sender, TransferImageEventArgs args) { if (args.Image != null) { resultImage = args.Image; IntPtr hbitmap = new Bitmap(args.Image).GetHbitmap(); MainImage.Source = Imaging.CreateBitmapSourceFromHBitmap( hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); Gdi32Native.DeleteObject(hbitmap); } }; _twain.ScanningComplete += delegate { IsEnabled = true; }; var sourceList = _twain.SourceNames; ManualSource.ItemsSource = sourceList; if (sourceList != null && sourceList.Count > 0) { ManualSource.SelectedItem = sourceList[0]; } }; }
private List <Scaner> GetScanersList() { List <Scaner> ls = new List <Scaner>(); Scaner s; try { Twain _twain = new Twain(_wh); if (_twain.SourceNames.Count != 0) { _twain.SelectSource(); s = new Scaner(_twain.DefaultSourceName, EnumScanerType.Twain, _wh); ls.Add(s); } } catch (TwainException) { } List <string> devices = WIAScanner.GetDevices(); foreach (string device in devices) { s = new Scaner(device, EnumScanerType.WIA, _wh); ls.Add(s); } s = new Scaner("Изображение из файла", EnumScanerType.File, _wh); ls.Add(s); return(ls); }
public TwainSettingForm() { try { InitializeComponent(); this.comBoxSettingList.SelectedIndexChanged += new EventHandler(this.comBoxSettingList_SelectedIndexChanged); this.chBoxUseDocumentFeeder.CheckedChanged += delegate(object sender, EventArgs e) { this.comBoxPageType.Enabled = !this.chBoxUseDocumentFeeder.Checked; }; try { this.TwainLib = new Twain(new WinFormsWindowMessageHook(this)); } catch (TwainException) { this.INFO("未接掃描器!"); } this.LoadPageType(this.comBoxPageType); this.LoadPixelType(this.comBoxPixelType); this.LoadSettingMode(this.comBoxSetting); this.LoadDataSource(this.comBoxDataSource); } catch (System.Exception ex) { this.ERROR(ex.Message, true); } }
/// <summary> /// 掃描初始化 /// </summary> /// <param name="hwndp"></param> /// <param name="senderForm"></param> public void scanInit(IntPtr hwndp, Form senderForm) { tw = new Twain(); tw.Init(hwndp); mainForm = senderForm; ScanComplete += new OnScanCompleteEvent(djScanComplete); }
private void PageScanningTestDialog_Loaded(object send, RoutedEventArgs e) { _twain = new Twain(new WpfWindowMessageHook(this)); _twain.TransferImage += delegate(Object sender, TransferImageEventArgs args) { if (args.Image != null) { image1.Source = Imaging.CreateBitmapSourceFromHBitmap( new System.Drawing.Bitmap(args.Image).GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } }; _twain.ScanningComplete += delegate { IsEnabled = true; }; var sourceList = _twain.SourceNames; ManualSource.ItemsSource = sourceList; if (sourceList != null && sourceList.Count > 0) { ManualSource.SelectedItem = sourceList[0]; } }
public Scaner() { InitializeComponent(); _twain = new Twain(new WinFormsWindowMessageHook(this)); _twain.TransferImage += delegate(Object sender, TransferImageEventArgs args) { if (args.Image != null) { if (!InvokeRequired) { this.Invoke(new MethodInvoker(delegate { Bitmap bitmap = new Bitmap(args.Image); if (imgcrop.Checked) { bitmap = CropBitmap(args.Image, 0, 0, 800, 700); } Bitmap newBitmap = new Bitmap(bitmap); float fdpi = (float)quality.Value; newBitmap.SetResolution(fdpi, fdpi); base64 = Convert_ImageTo_Base64(newBitmap, System.Drawing.Imaging.ImageFormat.Png); })); } } }; _twain.ScanningComplete += delegate { Enabled = true; }; server = new Server(this); }
public frmMain() { InitializeComponent(); tw = new Twain(); tw.Init(this.Handle); SavePath = System.Configuration.ConfigurationSettings.AppSettings["SavePath"]; }
public MainForm() { InitializeComponent(); Init(); OnInitFunction(null, mainFormArgs); Tw = new Twain(MyProductName); Tw.Init(this.Handle); }
private void DocumentScanningPage_Loaded(object o, RoutedEventArgs e) { this.m_ImageList = new List <Image>(); this.m_Twain = new Twain(new WpfWindowMessageHook(Window.GetWindow(this))); this.m_Twain.TransferImage += new EventHandler <TransferImageEventArgs>(Twain_TransferImage); this.m_Twain.ScanningComplete += new EventHandler <ScanningCompleteEventArgs>(Twain_ScanningComplete); this.ButtonNext.Focus(); }
public TwainHelper(Control ctr) { tw = new Twain(); this.ctr = ctr; frm = ctr.FindForm(); ctr.BackgroundImageLayout = ImageLayout.Stretch; tw.Init(ctr.Handle); }
public ScanForm(string path, string recordNO, string inhosTimes) { InitializeComponent(); Tw = new Twain(MyProductName); Tw.Init(this.Handle); txtFolder.Text = path; txtID.Text = recordNO; txtTimes.Text = inhosTimes; }
public NewMainForm() { InitializeComponent(); Init(); OnInitFunction(null, mainFormArgs); Tw = new Twain(MyProductName); Tw.Init(this.Handle); this.Text = this.Text + " " + CJia.Health.Tools.ConfigHelper.GetAppStrings("Version"); }
/// <summary> /// 图片缓存(已入库) /// </summary> //private CJia.Health.Tools.ImageCache ImageCancheForInput; public PictureInputView() { InitializeComponent(); LURecordNO.GetData += LURecordNO_GetData; LURecordNO.SelectValueChanged += LURecordNO_SelectValueChanged; Tw = new Twain(MyProductName); Tw.Init(this.Handle); axCmCaptureOcx1.Visible = false; }
public JJCJScanView() { InitializeComponent(); LURecordNO.GetData += LURecordNO_GetData; LURecordNO.SelectValueChanged += LURecordNO_SelectValueChanged; Tw = new Twain(MyProductName); Tw.Init(this.Handle); LURecordNO.Focus(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; }
public frmEscaner(string sImgName = "") { InitializeComponent(); this.sFileName = sImgName; this.sErrorMsg = String.Empty; this.sWSResponse = String.Empty; this.bImageReady = false; tw = new Twain(); tw.Init(this.Handle); }
/// <summary> /// 掃描初始化 /// </summary> /// <param name="hwndp"></param> /// <param name="senderForm"></param> /// <param name="twSuccess"></param> /// <returns></returns> public bool ScanInit(IntPtr hwndp, Form senderForm, string twSuccess) { bool tws = false; tw = new Twain(); tws = tw.Init(hwndp, tws); mainForm = senderForm; ScanComplete += new OnScanCompleteEvent(djScanComplete); return(tws); }
public frmScannedDocs(int _id_Fines, string _PaymentName, DateTime _date, string _Sum) { InitializeComponent(); id_Fines = _id_Fines; PaymentName = _PaymentName; date = _date; Sum = _Sum; tw = new Twain(); tw.Init(this.Handle); }
public frmAtualizarDocumentosDigitalizados() { InitializeComponent(); //Inicializando uma instancia do scanner objTwain = new Twain(); objTwain.Init(this.Handle); //para Salvar bmprect = new Rectangle(0, 0, 0, 0); }
public MainForm() { InitializeComponent(); this.Text = "ScanWorker"; this.WindowState = FormWindowState.Minimized; // when we are ready, we can hide the worker from the taskbar // this.ShowInTaskbar = false; _twain = new Twain(twain_hook = new WinFormsWindowMessageHook(this)); }
//Thread thread; //UI.Loading load; public MergeView() { InitializeComponent(); LURecordNO.GetData += LURecordNO_GetData; LURecordNO.SelectValueChanged += LURecordNO_SelectValueChanged; lblMesg.Text = ""; Tw = new Twain(MyProductName); Tw.Init(this.Handle); LURecordNO.Focus(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; NoBlankPage = new List <string>(); lblNoBlank.Text = ""; }
private void chooseTWAIN() { Twain tw = new Twain(); if (!tw.Init(this.Handle)) { MessageBox.Show("No device found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } tw.Select(); txtDevice.Text = tw.GetCurrentName(); currentDeviceID = tw.GetCurrentName(); }