public DocScanDocumentViewModel(IScannerService scannerService) { this.scannerService = scannerService; FetchScanners(); BackHomeCommand = new DelegateCommand(NavigateBack); ScanCommand = new DelegateCommand(Scan); PreviewCommand = new DelegateCommand(Preview); ManageCommand = new DelegateCommand(ManageImage); SelectedScanner = Scanners.FirstOrDefault(); ResolutionsList = new ObservableCollection <Resolution>(Resolutions.List); Resolution = Resolutions.R300; }
private void LoadParametes() { try { _twain32 = new Twain32 { ShowUI = true, IsTwain2Enable = true }; _twain32.OpenDSM(); #region GetScanners for (int i = 0; i < _twain32.SourcesCount; i++) { _scanners.Add(_twain32.GetSourceProductName(i)); } #endregion GetScanners if (Scanners.Count > 0) { SelectedScanner = Scanners.FirstOrDefault(); } } catch (Exception ex) { var messagebox = CustomMessageBox.Show(ex.Message, "Error!", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Error); if (messagebox == System.Windows.Forms.DialogResult.Yes) { _twain32?.CloseDSM(); _twain32?.CloseDataSource(); _twain32.Dispose(); Environment.ExitCode = (int)ExitCodes.ExitCode.ERROR_DEVICE_UNREACHABLE; this.Close(); } } }