我的老板一周前告诉我,我们需要能够列出可用的扫描仪设备,并从中选择一个用于扫描UNO平台中的文档。我们主要需要为Wasm和Uwp工作。我试着使用Windows。设备。扫描仪和窗口。设备。枚举,因为我阅读了此microsoft文档https://github.com/MicrosoftDocs/windows-uwp/blob/docs/windows-apps-src/devices-sensors/scan-from-your-app.md(在UNO项目和UWP项目中尝试过(:
private async void OnScannerAdded(DeviceWatcher sender, DeviceInformation deviceInfo)
{
await
MainPage.Current.Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>
{
MainPage.Current.NotifyUser(String.Format("Scanner with device id {0} has been added", deviceInfo.Id), NotifyType.StatusMessage);
// search the device list for a device with a matching device id
ScannerDataItem match = FindInList(deviceInfo.Id);
// If we found a match then mark it as verified and return
if (match != null)
{
match.Matched = true;
return;
}
// Add the new element to the end of the list of devices
AppendToList(deviceInfo);
}
);
}
但当我复制列出所有扫描仪设备的代码时,我会遇到一些错误,无法构建项目。特别是这两条线:
主页。现在的调度员。RunAsync和另一个从MainPage调用Current的程序(它显示:MainPage不包含Current的定义。(
另一个是ScannerDataItem match=FindInList(deviceInfo.Id(;(找不到ScannerDataItem类,尽管我使用自述文件开头指定的文档编写了这两个类(。
我的老板告诉我,他几年前就用Twain和WIA做过,但我找不到Visual Studio 2019的任何信息,而且使用Twain的nugets包几乎没有任何文档。
这是我第一次在这里问什么,如果你需要更多的代码或其他什么,就说出来。我需要让它发挥作用,谢谢。
至于ScannerDataItem类,它也是一个自定义类,用于存储扫描仪设备信息,您需要定义扫描仪设备的属性。