private void GetFromDevice(ImageAcquisitionService.DeviceKind deviceKind) { //_pictureBox.Image = SampleImages.sampleScan; try { var acquisitionService = new ImageAcquisitionService(deviceKind); var wiaImageFile = acquisitionService.Acquire(); if (wiaImageFile == null) { return; } var imageFile = ConvertToPngOrJpegIfNotAlready(wiaImageFile); _currentImage = PalasoImage.FromFile(imageFile); _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) { ImageChanged.Invoke(this, null); } } catch (ImageDeviceNotFoundException error) { _messageLabel.Text = error.Message + Environment.NewLine + Environment.NewLine + "Note: this program works with devices that have a 'WIA' driver, not the old-style 'TWAIN' driver"; _messageLabel.Visible = true; } catch (WIA_Version2_MissingException error) { _messageLabel.Text = "Windows XP does not come with a crucial DLL that lets you use a WIA scanner with this program. Get a technical person to downloand and follow the directions at http://vbnet.mvps.org/files/updates/wiaautsdk.zip"; _messageLabel.Visible = true; } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Problem Getting Image".Localize("ImageToolbox.ProblemGettingImageFromDevice")); } }
private void GetFromDevice(ImageAcquisitionService.DeviceKind deviceKind) { //_pictureBox.Image = SampleImages.sampleScan; try { var acquisitionService = new ImageAcquisitionService(deviceKind); var wiaImageFile = acquisitionService.Acquire(); if (wiaImageFile == null) return; var imageFile = ConvertToPngOrJpegIfNotAlready(wiaImageFile); _currentImage = PalasoImage.FromFile(imageFile); _pictureBox.Image = _currentImage.Image; if (ImageChanged != null) ImageChanged.Invoke(this, null); } catch (ImageDeviceNotFoundException error) { _messageLabel.Text = error.Message + Environment.NewLine +Environment.NewLine+ "Note: this program works with devices that have a 'WIA' driver, not the old-style 'TWAIN' driver"; _messageLabel.Visible = true; } catch (WIA_Version2_MissingException error) { _messageLabel.Text = "Windows XP does not come with a crucial DLL that lets you use a WIA scanner with this program. Get a technical person to downloand and follow the directions at http://vbnet.mvps.org/files/updates/wiaautsdk.zip"; _messageLabel.Visible = true; } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Problem Getting Image".Localize("ImageToolbox.ProblemGettingImageFromDevice")); } }