cyanfish / naps2

Scan documents to PDF and more, as simply as possible.
https://www.naps2.com
Other
2.58k stars 315 forks source link

use sdk1.0.0 to scan files ,how to show the ShowOperation Progress #380

Closed 800903 closed 2 months ago

800903 commented 2 months ago

use demo from the website -->https://www.naps2.com/sdk the demo can not show the scan Progress.. vs2013 NAPS2.Threading.Invoker.Current cant not use by other application.

cyanfish commented 2 months ago

https://www.naps2.com/sdk/doc/api/NAPS2.Scan.ScanController.html#events

800903 commented 2 months ago

thanks ,get it done;

delegate void SetProcssBarCallback(int _value); private void SetProcssBar(int _value) { if (progressBarScan.InvokeRequired) { while (progressBarScan.IsHandleCreated == false) { if (progressBarScan.Disposing || progressBarScan.IsDisposed) return; } SetProcssBarCallback d = new SetProcssBarCallback(SetProcssBar); progressBarScan.Invoke(d, new object[] { _value }); } else { progressBarScan.Value = _value; } }

//============================== var op = new ScanOperation(options); scanController.PageStart += (sender, args) => { op.NextPage(args.PageNumber); SetProcssBar(10); }; scanController.ScanEnd += (sender, args) => { op.Completed(); if (args.Error != null) { MessageBox.Show(args.Error.ToString()); } SetProcssBar(100); };