using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using WIA; namespace PDF_Master.Views.Dialog.HomePageToolsDialogs { /// /// CreateFromScannerDialogs.xaml 的交互逻辑 /// public partial class CreateFromScannerDialogs : UserControl { public CreateFromScannerDialogs() { InitializeComponent(); ListScanners(); Loaded += Focus_Loaded; } public static ImageFile imageFile; private void Focus_Loaded(object sender, RoutedEventArgs e) { //if (Listboxscan.Items.Count > 0) //{ // Focus; //} } private void ListScanners() { DeviceManager deviceManager; deviceManager = new DeviceManager(); for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++) { if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType) { continue; } Listboxscan.Items.Add(deviceManager.DeviceInfos[i].Properties["Name"].get_Value()); } } } }