From 834d8c37f9e592e6aa9398beb184c91fd966a308 Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Mon, 5 Sep 2022 20:05:16 -0700 Subject: [PATCH] Migrate Edit Profiles form to Eto Some styling padding etc. still todo, but I'm leaving that for later. --- .../EtoForms/WinForms/WinFormsEtoPlatform.cs | 9 +- .../WinForms/DesktopScanController.cs | 9 +- NAPS2.Lib/EtoForms/C.cs | 28 + NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs | 609 +++++++++ NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs | 99 +- .../Resources/SettingsResources.Designer.cs | 111 +- .../Lang/Resources/SettingsResources.resx | 2 +- .../Lang/Resources/UiStrings.Designer.cs | 1096 +++++++++++------ NAPS2.Lib/Lang/Resources/UiStrings.resx | 69 ++ NAPS2.Sdk/Platform/ISystemCompat.cs | 2 + NAPS2.Sdk/Platform/LinuxSystemCompat.cs | 2 + NAPS2.Sdk/Platform/MacSystemCompat.cs | 2 + NAPS2.Sdk/Platform/WindowsSystemCompat.cs | 2 + NAPS2.Sdk/Scan/Driver.cs | 4 +- .../Scan/Internal/ScanOptionsValidator.cs | 38 +- NAPS2.sln.DotSettings | 1 + 16 files changed, 1600 insertions(+), 483 deletions(-) create mode 100644 NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs diff --git a/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs b/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs index 4f3982907..5f08000c3 100644 --- a/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs +++ b/NAPS2.Lib.WinForms/EtoForms/WinForms/WinFormsEtoPlatform.cs @@ -11,20 +11,15 @@ namespace NAPS2.EtoForms.WinForms; public class WinFormsEtoPlatform : EtoPlatform { - private const int MIN_BUTTON_WIDTH = 75; - private const int MIN_BUTTON_HEIGHT = 32; + private static readonly Size MinImageButtonSize = new(75, 32); private const int IMAGE_PADDING = 5; - static WinFormsEtoPlatform() - { - ButtonHandler.DefaultMinimumSize = new Eto.Drawing.Size(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); - } - public override IListView CreateListView(ListViewBehavior behavior) => new WinFormsListView(behavior); public override void ConfigureImageButton(Eto.Forms.Button button) { + button.MinimumSize = MinImageButtonSize; if (button.ImagePosition == ButtonImagePosition.Left) { var native = (System.Windows.Forms.Button) button.ToNative(); diff --git a/NAPS2.Lib.WinForms/WinForms/DesktopScanController.cs b/NAPS2.Lib.WinForms/WinForms/DesktopScanController.cs index abb7f9cc1..a782b7c51 100644 --- a/NAPS2.Lib.WinForms/WinForms/DesktopScanController.cs +++ b/NAPS2.Lib.WinForms/WinForms/DesktopScanController.cs @@ -1,3 +1,4 @@ +using NAPS2.EtoForms.Ui; using NAPS2.Scan; using NAPS2.Wia; @@ -57,7 +58,7 @@ public class DesktopScanController : IDesktopScanController } // No profile for the device we're scanning with, so prompt to create one - var editSettingsForm = _formFactory.Create(); + var editSettingsForm = _formFactory.Create(); editSettingsForm.ScanProfile = _config.DefaultProfileSettings(); try { @@ -69,7 +70,7 @@ public class DesktopScanController : IDesktopScanController catch (WiaException) { } - editSettingsForm.ShowDialog(); + editSettingsForm.ShowModal(); if (!editSettingsForm.Result) { return; @@ -102,9 +103,9 @@ public class DesktopScanController : IDesktopScanController public async Task ScanWithNewProfile() { - var editSettingsForm = _formFactory.Create(); + var editSettingsForm = _formFactory.Create(); editSettingsForm.ScanProfile = _config.DefaultProfileSettings(); - editSettingsForm.ShowDialog(); + editSettingsForm.ShowModal(); if (!editSettingsForm.Result) { return; diff --git a/NAPS2.Lib/EtoForms/C.cs b/NAPS2.Lib/EtoForms/C.cs index c1c1f4054..668714d42 100644 --- a/NAPS2.Lib/EtoForms/C.cs +++ b/NAPS2.Lib/EtoForms/C.cs @@ -1,6 +1,7 @@ using System.Windows.Input; using Eto.Drawing; using Eto.Forms; +using NAPS2.Scan; namespace NAPS2.EtoForms; @@ -120,4 +121,31 @@ public static class C pix.Add(imageView, 0, 0); return pix; } + + public static Label Label(string text) + { + return new Label + { + Text = text + }; + } + + public static DropDown EnumDropDown() where T : Enum + { + return EnumDropDown(x => x.Description()); + } + + public static DropDown EnumDropDown(Func format) where T : Enum + { + var combo = new DropDown(); + foreach (var item in Enum.GetValues(typeof(T))) + { + combo.Items.Add(new ListItem + { + Key = item.ToString(), + Text = format((T) item) + }); + } + return combo; + } } \ No newline at end of file diff --git a/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs new file mode 100644 index 000000000..ba7a3b8b2 --- /dev/null +++ b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs @@ -0,0 +1,609 @@ +using Eto.Drawing; +using Eto.Forms; +using NAPS2.Scan; +using NAPS2.Scan.Exceptions; +using NAPS2.Scan.Internal; + +namespace NAPS2.EtoForms.Ui; + +public class EditProfileForm : EtoDialogBase +{ + private readonly IScanPerformer _scanPerformer; + private readonly ErrorOutput _errorOutput; + private readonly ProfileNameTracker _profileNameTracker; + + private readonly TextBox _displayName = new(); + private readonly RadioButton _wiaDriver; + private readonly RadioButton _twainDriver; + private readonly RadioButton _appleDriver; + private readonly RadioButton _saneDriver; + private readonly TextBox _deviceName = new() { Enabled = false }; + private readonly Button _chooseDevice = new() { Text = UiStrings.ChooseDevice }; + private readonly RadioButton _predefinedSettings; + private readonly RadioButton _nativeUi; + private readonly DropDown _paperSource = C.EnumDropDown(); + private readonly DropDown _pageSize = C.EnumDropDown(); + private readonly DropDown _resolution = C.EnumDropDown(); + private readonly DropDown _bitDepth = C.EnumDropDown(); + private readonly DropDown _horAlign = C.EnumDropDown(); + private readonly DropDown _scale = C.EnumDropDown(); + private readonly CheckBox _enableAutoSave = new() { Text = UiStrings.EnableAutoSave }; + private readonly LinkButton _autoSaveSettings = new() { Text = UiStrings.AutoSaveSettings }; + private readonly Button _advanced = new() { Text = UiStrings.Advanced }; + private readonly Button _ok = new() { Text = UiStrings.OK }; + private readonly Button _cancel = new() { Text = UiStrings.Cancel }; + private readonly Slider _brightnessSlider = new() { MinValue = -1000, MaxValue = 1000, TickFrequency = 200 }; + private readonly NumericMaskedTextBox _brightnessText = new(); + private readonly Slider _contrastSlider = new() { MinValue = -1000, MaxValue = 1000, TickFrequency = 200 }; + private readonly NumericMaskedTextBox _contrastText = new(); + + private ScanProfile _scanProfile = null!; + private ScanDevice? _currentDevice; + private bool _isDefault; + private bool _result; + private bool _suppressChangeEvent; + + public EditProfileForm(Naps2Config config, IScanPerformer scanPerformer, ErrorOutput errorOutput, + ProfileNameTracker profileNameTracker) : base(config) + { + _scanPerformer = scanPerformer; + _errorOutput = errorOutput; + _profileNameTracker = profileNameTracker; + Title = UiStrings.EditProfileFormTitle; + Icon = new Icon(1f, Icons.blueprints_small.ToEtoImage()); + Size = new Size(448, 478); + MinimumSize = new Size(448, 478); + Resizable = true; + + _wiaDriver = new RadioButton { Text = UiStrings.WiaDriver }; + _twainDriver = new RadioButton(_wiaDriver) { Text = UiStrings.TwainDriver }; + _appleDriver = new RadioButton(_wiaDriver) { Text = UiStrings.AppleDriver }; + _saneDriver = new RadioButton(_wiaDriver) { Text = UiStrings.SaneDriver }; + _predefinedSettings = new RadioButton { Text = UiStrings.UsePredefinedSettings }; + _nativeUi = new RadioButton(_nativeUi) { Text = UiStrings.UseNativeUi }; + _pageSize.SelectedIndexChanged += PageSize_SelectedIndexChanged; + _contrastSlider.ValueChanged += ContrastSlider_Scroll; + _contrastText.TextChanged += ContrastText_TextChanged; + _brightnessSlider.ValueChanged += BrightnessSlider_Scroll; + _brightnessText.TextChanged += BrightnessText_TextChanged; + _wiaDriver.CheckedChanged += Driver_CheckedChanged; + _twainDriver.CheckedChanged += Driver_CheckedChanged; + _appleDriver.CheckedChanged += Driver_CheckedChanged; + _saneDriver.CheckedChanged += Driver_CheckedChanged; + _predefinedSettings.CheckedChanged += PredefinedSettings_CheckedChanged; + _nativeUi.CheckedChanged += NativeUi_CheckedChanged; + _ok.Click += Ok_Click; + _cancel.Click += Cancel_Click; + + // TODO: Don't show if only one driver is available + var driverElements = new List(); + if (PlatformCompat.System.IsWiaDriverSupported) + { + driverElements.Add(_wiaDriver.XScale()); + } + if (PlatformCompat.System.IsTwainDriverSupported) + { + driverElements.Add(_twainDriver.XScale()); + } + if (PlatformCompat.System.IsAppleDriverSupported) + { + driverElements.Add(_appleDriver.XScale()); + } + if (PlatformCompat.System.IsSaneDriverSupported) + { + driverElements.Add(_saneDriver.XScale()); + } + + _chooseDevice.Click += ChooseDevice; + _enableAutoSave.CheckedChanged += EnableAutoSave_CheckedChanged; + _autoSaveSettings.Click += AutoSaveSettings_LinkClicked; + _advanced.Click += Advanced_Click; + _deviceName.KeyDown += DeviceName_KeyDown; + + Content = L.Root(L.Column( + L.Row( + L.Column( + C.Label(UiStrings.DisplayNameLabel), + _displayName, + L.Row( + driverElements.ToArray() + ), + C.Label(UiStrings.DeviceLabel), + L.Row( + _deviceName.XScale(), + _chooseDevice + ) + ).XScale(), + new ImageView { Image = Icons.scanner_48.ToEtoImage() } + ), + L.Row( + _predefinedSettings.XScale(), + _nativeUi.XScale() + ), + L.Row( + L.Column( + C.Label(UiStrings.PaperSourceLabel), + _paperSource, + C.Label(UiStrings.PageSizeLabel), + _pageSize, + C.Label(UiStrings.ResolutionLabel), + _resolution, + C.Label(UiStrings.BrightnessLabel), + L.Row( + _brightnessSlider.XScale(), + _brightnessText.Width(40) + ) + ).XScale(), + L.Column( + C.Label(UiStrings.BitDepthLabel), + _bitDepth, + C.Label(UiStrings.HorizontalAlignLabel), + _horAlign, + C.Label(UiStrings.ScaleLabel), + _scale, + C.Label(UiStrings.ContrastLabel), + L.Row( + _contrastSlider.XScale(), + _contrastText.Width(40) + ) + ).XScale() + ), + L.Row( + _enableAutoSave, + _autoSaveSettings + ), + C.ZeroSpace().YScale(), + L.Row( + _advanced, + C.ZeroSpace().XScale(), + _ok, + _cancel + ) + )); + } + + + public bool Result => _result; + + public ScanProfile ScanProfile + { + get => _scanProfile; + set => _scanProfile = value.Clone(); + } + + public ScanDevice? CurrentDevice + { + get => _currentDevice; + set + { + _currentDevice = value; + _deviceName.Text = value?.Name ?? ""; + } + } + + private Driver DeviceDriver + { + get => _twainDriver.Checked ? Driver.Twain + : _wiaDriver.Checked ? Driver.Wia + : _appleDriver.Checked ? Driver.Apple + : _saneDriver.Checked ? Driver.Sane + : ScanOptionsValidator.SystemDefaultDriver; + set + { + if (value == Driver.Twain) + { + _twainDriver.Checked = true; + } + else if (value == Driver.Wia) + { + _wiaDriver.Checked = true; + } + else if (value == Driver.Apple) + { + _appleDriver.Checked = true; + } + else if (value == Driver.Sane) + { + _saneDriver.Checked = true; + } + } + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + // Don't trigger any onChange events + _suppressChangeEvent = true; + + _displayName.Text = ScanProfile.DisplayName; + CurrentDevice ??= ScanProfile.Device; + _isDefault = ScanProfile.IsDefault; + + _paperSource.SelectedIndex = (int) ScanProfile.PaperSource; + _bitDepth.SelectedIndex = (int) ScanProfile.BitDepth; + _resolution.SelectedIndex = (int) ScanProfile.Resolution; + _contrastText.Text = ScanProfile.Contrast.ToString("G"); + _brightnessText.Text = ScanProfile.Brightness.ToString("G"); + UpdatePageSizeList(); + SelectPageSize(); + _scale.SelectedIndex = (int) ScanProfile.AfterScanScale; + _horAlign.SelectedIndex = (int) ScanProfile.PageAlign; + + _enableAutoSave.Checked = ScanProfile.EnableAutoSave; + + DeviceDriver = new ScanOptionsValidator().ValidateDriver( + Enum.TryParse(ScanProfile.DriverName, true, out var driver) + ? driver + : Driver.Default); + + _nativeUi.Checked = ScanProfile.UseNativeUI; + _predefinedSettings.Checked = !ScanProfile.UseNativeUI; + + // Start triggering onChange events again + _suppressChangeEvent = false; + + UpdateEnabledControls(); + } + + private async void ChooseDevice(object? sender, EventArgs args) + { + ScanProfile.DriverName = DeviceDriver.ToString().ToLowerInvariant(); + try + { + var device = await _scanPerformer.PromptForDevice(ScanProfile, NativeHandle); + if (device != null) + { + if (string.IsNullOrEmpty(_deviceName.Text) || + CurrentDevice != null && CurrentDevice.Name == _deviceName.Text) + { + _deviceName.Text = device.Name; + } + CurrentDevice = device; + } + } + catch (ScanDriverException ex) + { + if (ex is ScanDriverUnknownException) + { + Log.ErrorException(ex.Message, ex.InnerException!); + _errorOutput.DisplayError(ex.Message, ex); + } + else + { + _errorOutput.DisplayError(ex.Message); + } + } + } + + private void UpdatePageSizeList() + { + _pageSize.Items.Clear(); + + // Defaults + foreach (ScanPageSize item in Enum.GetValues(typeof(ScanPageSize))) + { + _pageSize.Items.Add(new PageSizeListItem + { + Type = item, + Text = item.Description() + }); + } + + // Custom Presets + foreach (var preset in Config.Get(c => c.CustomPageSizePresets).OrderBy(x => x.Name)) + { + _pageSize.Items.Insert(_pageSize.Items.Count - 1, new PageSizeListItem + { + Type = ScanPageSize.Custom, + Text = string.Format(MiscResources.NamedPageSizeFormat, preset.Name, preset.Dimens.Width, + preset.Dimens.Height, preset.Dimens.Unit.Description()), + CustomName = preset.Name, + CustomDimens = preset.Dimens + }); + } + } + + private void SelectPageSize() + { + if (ScanProfile.PageSize == ScanPageSize.Custom) + { + if (ScanProfile.CustomPageSizeName != null && ScanProfile.CustomPageSize != null) + { + SelectCustomPageSize(ScanProfile.CustomPageSizeName, ScanProfile.CustomPageSize); + } + else + { + _pageSize.SelectedIndex = 0; + } + } + else + { + _pageSize.SelectedIndex = (int) ScanProfile.PageSize; + } + } + + private void SelectCustomPageSize(string name, PageDimensions dimens) + { + for (int i = 0; i < _pageSize.Items.Count; i++) + { + var item = (PageSizeListItem) _pageSize.Items[i]; + if (item.Type == ScanPageSize.Custom && item.CustomName == name && item.CustomDimens == dimens) + { + _pageSize.SelectedIndex = i; + return; + } + } + + // Not found, so insert a new item + _pageSize.Items.Insert(_pageSize.Items.Count - 1, new PageSizeListItem + { + Type = ScanPageSize.Custom, + Text = string.IsNullOrEmpty(name) + ? string.Format(MiscResources.CustomPageSizeFormat, dimens.Width, dimens.Height, + dimens.Unit.Description()) + : string.Format(MiscResources.NamedPageSizeFormat, name, dimens.Width, dimens.Height, + dimens.Unit.Description()), + CustomName = name, + CustomDimens = dimens + }); + _pageSize.SelectedIndex = _pageSize.Items.Count - 2; + } + + + private void SaveSettings() + { + if (ScanProfile.IsLocked) + { + if (!ScanProfile.IsDeviceLocked) + { + ScanProfile.Device = CurrentDevice; + } + return; + } + var pageSize = (PageSizeListItem) _pageSize.SelectedValue; + if (ScanProfile.DisplayName != null) + { + _profileNameTracker.RenamingProfile(ScanProfile.DisplayName, _displayName.Text); + } + _scanProfile = new ScanProfile + { + Version = ScanProfile.CURRENT_VERSION, + + Device = CurrentDevice, + IsDefault = _isDefault, + DriverName = DeviceDriver.ToString().ToLowerInvariant(), + DisplayName = _displayName.Text, + IconID = 0, + MaxQuality = ScanProfile.MaxQuality, + UseNativeUI = _nativeUi.Checked, + + AfterScanScale = (ScanScale) _scale.SelectedIndex, + BitDepth = (ScanBitDepth) _bitDepth.SelectedIndex, + Brightness = _brightnessSlider.Value, + Contrast = _contrastSlider.Value, + PageAlign = (ScanHorizontalAlign) _horAlign.SelectedIndex, + PageSize = pageSize.Type, + CustomPageSizeName = pageSize.CustomName, + CustomPageSize = pageSize.CustomDimens, + Resolution = (ScanDpi) _resolution.SelectedIndex, + PaperSource = (ScanSource) _paperSource.SelectedIndex, + + EnableAutoSave = _enableAutoSave.Checked == true, + AutoSaveSettings = ScanProfile.AutoSaveSettings, + Quality = ScanProfile.Quality, + BrightnessContrastAfterScan = ScanProfile.BrightnessContrastAfterScan, + AutoDeskew = ScanProfile.AutoDeskew, + WiaOffsetWidth = ScanProfile.WiaOffsetWidth, + WiaRetryOnFailure = ScanProfile.WiaRetryOnFailure, + WiaDelayBetweenScans = ScanProfile.WiaDelayBetweenScans, + WiaDelayBetweenScansSeconds = ScanProfile.WiaDelayBetweenScansSeconds, + WiaVersion = ScanProfile.WiaVersion, + ForcePageSize = ScanProfile.ForcePageSize, + ForcePageSizeCrop = ScanProfile.ForcePageSizeCrop, + FlipDuplexedPages = ScanProfile.FlipDuplexedPages, + TwainImpl = ScanProfile.TwainImpl, + + ExcludeBlankPages = ScanProfile.ExcludeBlankPages, + BlankPageWhiteThreshold = ScanProfile.BlankPageWhiteThreshold, + BlankPageCoverageThreshold = ScanProfile.BlankPageCoverageThreshold + }; + } + + private void Ok_Click(object? sender, EventArgs e) + { + // Note: If CurrentDevice is null, that's fine. A prompt will be shown when scanning. + + if (_displayName.Text == "") + { + _errorOutput.DisplayError(MiscResources.NameMissing); + return; + } + _result = true; + SaveSettings(); + Close(); + } + + private void Cancel_Click(object? sender, EventArgs e) + { + Close(); + } + + private void PredefinedSettings_CheckedChanged(object? sender, EventArgs e) + { + UpdateEnabledControls(); + } + + private void NativeUi_CheckedChanged(object? sender, EventArgs e) + { + UpdateEnabledControls(); + } + + private void UpdateEnabledControls() + { + if (!_suppressChangeEvent) + { + _suppressChangeEvent = true; + + bool canUseNativeUi = DeviceDriver is Driver.Wia or Driver.Twain; + bool locked = ScanProfile.IsLocked; + bool deviceLocked = ScanProfile.IsDeviceLocked; + bool settingsEnabled = !locked && (_predefinedSettings.Checked || !canUseNativeUi); + + _displayName.Enabled = !locked; + _wiaDriver.Enabled = _twainDriver.Enabled = _appleDriver.Enabled = _saneDriver.Enabled = !locked; + _chooseDevice.Enabled = !deviceLocked; + _predefinedSettings.Enabled = _nativeUi.Enabled = !locked; + + _paperSource.Enabled = settingsEnabled; + _resolution.Enabled = settingsEnabled; + _pageSize.Enabled = settingsEnabled; + _bitDepth.Enabled = settingsEnabled; + _horAlign.Enabled = settingsEnabled; + _scale.Enabled = settingsEnabled; + _brightnessSlider.Enabled = settingsEnabled; + _contrastSlider.Enabled = settingsEnabled; + _brightnessText.Enabled = settingsEnabled; + _contrastText.Enabled = settingsEnabled; + + _enableAutoSave.Enabled = !locked && !Config.Get(c => c.DisableAutoSave); + _autoSaveSettings.Enabled = _enableAutoSave.Checked == true; + _autoSaveSettings.Visible = !locked && !Config.Get(c => c.DisableAutoSave); + + _advanced.Enabled = !locked; + + // TODO: Adjust form height? + + _suppressChangeEvent = false; + } + } + + private void Driver_CheckedChanged(object? sender, EventArgs e) + { + if (((RadioButton) sender!).Checked && !_suppressChangeEvent) + { + ScanProfile.Device = null; + CurrentDevice = null; + UpdateEnabledControls(); + } + } + + private void BrightnessText_TextChanged(object? sender, EventArgs e) + { + if (int.TryParse(_brightnessText.Text, out int value)) + { + if (value >= _brightnessSlider.MinValue && value <= _brightnessSlider.MaxValue) + { + _brightnessSlider.Value = value; + } + } + } + + private void BrightnessSlider_Scroll(object? sender, EventArgs e) + { + _brightnessText.Text = _brightnessSlider.Value.ToString("G"); + } + + private void ContrastText_TextChanged(object? sender, EventArgs e) + { + if (int.TryParse(_contrastText.Text, out int value)) + { + if (value >= _contrastSlider.MinValue && value <= _contrastSlider.MaxValue) + { + _contrastSlider.Value = value; + } + } + } + + private void ContrastSlider_Scroll(object? sender, EventArgs e) + { + _contrastText.Text = _contrastSlider.Value.ToString("G"); + } + + private int _lastPageSizeIndex = -1; + private PageSizeListItem _lastPageSizeItem = null; + + private void PageSize_SelectedIndexChanged(object? sender, EventArgs e) + { + if (_pageSize.SelectedIndex == _pageSize.Items.Count - 1) + { + // "Custom..." selected + // var form = FormFactory.Create(); + // form.PageSizeDimens = _lastPageSizeItem.Type == ScanPageSize.Custom + // ? _lastPageSizeItem.CustomDimens + // : _lastPageSizeItem.Type.PageDimensions(); + // if (form.ShowDialog() == DialogResult.OK) + // { + // UpdatePageSizeList(); + // SelectCustomPageSize(form.PageSizeName, form.PageSizeDimens); + // } + // else + // { + // _pageSize.SelectedIndex = _lastPageSizeIndex; + // } + } + _lastPageSizeIndex = _pageSize.SelectedIndex; + _lastPageSizeItem = (PageSizeListItem) _pageSize.SelectedValue; + } + + private void AutoSaveSettings_LinkClicked(object? sender, EventArgs eventArgs) + { + if (Config.Get(c => c.DisableAutoSave)) + { + return; + } + // var form = FormFactory.Create(); + // ScanProfile.DriverName = DeviceDriver.ToString().ToLowerInvariant(); + // form.ScanProfile = ScanProfile; + // form.ShowDialog(); + } + + private void Advanced_Click(object? sender, EventArgs e) + { + // var form = FormFactory.Create(); + // ScanProfile.DriverName = DeviceDriver.ToString().ToLowerInvariant(); + // ScanProfile.BitDepth = (ScanBitDepth)_bitDepth.SelectedIndex; + // form.ScanProfile = ScanProfile; + // form.ShowDialog(); + } + + private void EnableAutoSave_CheckedChanged(object? sender, EventArgs e) + { + if (!_suppressChangeEvent) + { + if (_enableAutoSave.Checked == true) + { + _autoSaveSettings.Enabled = true; + // var form = FormFactory.Create(); + // form.ScanProfile = ScanProfile; + // form.ShowDialog(); + // if (!form.Result) + // { + // _enableAutoSave.Checked = false; + // } + } + } + _autoSaveSettings.Enabled = _enableAutoSave.Checked == true; + } + + private void DeviceName_KeyDown(object? sender, KeyEventArgs e) + { + if (e.Key == Keys.Delete) + { + CurrentDevice = null; + } + } + + private class PageSizeListItem : IListItem + { + public string Text { get; set; } = null!; + + public string Key => Text; + + public ScanPageSize Type { get; set; } + + public string? CustomName { get; set; } + + public PageDimensions? CustomDimens { get; set; } + } +} \ No newline at end of file diff --git a/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs b/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs index 4dc24a418..65a949102 100644 --- a/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/ProfilesForm.cs @@ -231,64 +231,63 @@ public class ProfilesForm : EtoDialogBase private async void DoScan() { - // TODO: Migrate FEditProfile to eto - // if (ImageCallback == null) - // { - // throw new InvalidOperationException("Image callback not specified"); - // } - // if (_profileManager.Profiles.Count == 0) - // { - // var editSettingsForm = FormFactory.Create(); - // editSettingsForm.ScanProfile = new ScanProfile - // { - // Version = ScanProfile.CURRENT_VERSION - // }; - // editSettingsForm.ShowDialog(); - // if (!editSettingsForm.Result) - // { - // return; - // } - // _profileManager.Mutate(new ListMutation.Append(editSettingsForm.ScanProfile), ListSelection.Empty()); - // _profileManager.DefaultProfile = editSettingsForm.ScanProfile; - // } - // if (SelectedProfile == null) - // { - // MessageBox.Show(MiscResources.SelectProfileBeforeScan, MiscResources.ChooseProfile, MessageBoxButtons.OK, MessageBoxType.Warning); - // return; - // } - // if (_profileManager.DefaultProfile == null) - // { - // _profileManager.DefaultProfile = SelectedProfile; - // } - // var source = await _scanPerformer.PerformScan(SelectedProfile, DefaultScanParams(), this.ToNative().Handle); - // await source.ForEach(ImageCallback); - // this.ToNative().Activate(); + if (ImageCallback == null) + { + throw new InvalidOperationException("Image callback not specified"); + } + if (_profileManager.Profiles.Count == 0) + { + var editSettingsForm = FormFactory.Create(); + editSettingsForm.ScanProfile = new ScanProfile + { + Version = ScanProfile.CURRENT_VERSION + }; + editSettingsForm.ShowModal(); + if (!editSettingsForm.Result) + { + return; + } + _profileManager.Mutate(new ListMutation.Append(editSettingsForm.ScanProfile), ListSelection.Empty()); + _profileManager.DefaultProfile = editSettingsForm.ScanProfile; + } + if (SelectedProfile == null) + { + MessageBox.Show(MiscResources.SelectProfileBeforeScan, MiscResources.ChooseProfile, MessageBoxButtons.OK, MessageBoxType.Warning); + return; + } + if (_profileManager.DefaultProfile == null) + { + _profileManager.DefaultProfile = SelectedProfile; + } + var source = await _scanPerformer.PerformScan(SelectedProfile, DefaultScanParams(), NativeHandle); + await source.ForEach(ImageCallback); + Focus(); } private void DoAdd() { - // var fedit = FormFactory.Create(); - // fedit.ScanProfile = Config.DefaultProfileSettings(); - // fedit.ShowDialog(); - // if (fedit.Result) - // { - // _profileManager.Mutate(new ListMutation.Append(fedit.ScanProfile), _listView); - // } + var fedit = FormFactory.Create(); + fedit.ScanProfile = Config.DefaultProfileSettings(); + fedit.ShowModal(); + if (fedit.Result) + { + _profileManager.Mutate(new ListMutation.Append(fedit.ScanProfile), _listView); + } } private void DoEdit() { - // var originalProfile = SelectedProfile; - // if (originalProfile != null) - // { - // var fedit = FormFactory.Create(); - // fedit.ScanProfile = originalProfile; - // fedit.ShowDialog(); - // if (fedit.Result) - // { - // _profileManager.Mutate(new ListMutation.ReplaceWith(fedit.ScanProfile), _listView); - // } - // } + var originalProfile = SelectedProfile; + if (originalProfile != null) + { + var fedit = FormFactory.Create(); + fedit.ScanProfile = originalProfile; + fedit.ShowModal(); + if (fedit.Result) + { + _profileManager.Mutate(new ListMutation.ReplaceWith(fedit.ScanProfile), _listView); + } + } } private void DoDelete() diff --git a/NAPS2.Lib/Lang/Resources/SettingsResources.Designer.cs b/NAPS2.Lib/Lang/Resources/SettingsResources.Designer.cs index 69b69645d..4e81bac3a 100644 --- a/NAPS2.Lib/Lang/Resources/SettingsResources.Designer.cs +++ b/NAPS2.Lib/Lang/Resources/SettingsResources.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -22,7 +21,7 @@ namespace NAPS2.Lang.Resources { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class SettingsResources { + internal class SettingsResources { private static global::System.Resources.ResourceManager resourceMan; @@ -61,9 +60,9 @@ namespace NAPS2.Lang.Resources { } /// - /// Looks up a localized string similar to Black & White. + /// Looks up a localized string similar to Black/White. /// - public static string BitDepth_1BlackAndWhite { + internal static string BitDepth_1BlackAndWhite { get { return ResourceManager.GetString("BitDepth_1BlackAndWhite", resourceCulture); } @@ -72,7 +71,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 24-bit Color. /// - public static string BitDepth_24Color { + internal static string BitDepth_24Color { get { return ResourceManager.GetString("BitDepth_24Color", resourceCulture); } @@ -81,7 +80,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Grayscale. /// - public static string BitDepth_8Grayscale { + internal static string BitDepth_8Grayscale { get { return ResourceManager.GetString("BitDepth_8Grayscale", resourceCulture); } @@ -90,7 +89,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 100 dpi. /// - public static string Dpi_100 { + internal static string Dpi_100 { get { return ResourceManager.GetString("Dpi_100", resourceCulture); } @@ -99,7 +98,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1200 dpi. /// - public static string Dpi_1200 { + internal static string Dpi_1200 { get { return ResourceManager.GetString("Dpi_1200", resourceCulture); } @@ -108,7 +107,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 150 dpi. /// - public static string Dpi_150 { + internal static string Dpi_150 { get { return ResourceManager.GetString("Dpi_150", resourceCulture); } @@ -117,7 +116,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 200 dpi. /// - public static string Dpi_200 { + internal static string Dpi_200 { get { return ResourceManager.GetString("Dpi_200", resourceCulture); } @@ -126,7 +125,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 300 dpi. /// - public static string Dpi_300 { + internal static string Dpi_300 { get { return ResourceManager.GetString("Dpi_300", resourceCulture); } @@ -135,7 +134,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 400 dpi. /// - public static string Dpi_400 { + internal static string Dpi_400 { get { return ResourceManager.GetString("Dpi_400", resourceCulture); } @@ -144,7 +143,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 600 dpi. /// - public static string Dpi_600 { + internal static string Dpi_600 { get { return ResourceManager.GetString("Dpi_600", resourceCulture); } @@ -153,7 +152,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 800 dpi. /// - public static string Dpi_800 { + internal static string Dpi_800 { get { return ResourceManager.GetString("Dpi_800", resourceCulture); } @@ -162,7 +161,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to No provider selected.. /// - public static string EmailProvider_NotSelected { + internal static string EmailProvider_NotSelected { get { return ResourceManager.GetString("EmailProvider_NotSelected", resourceCulture); } @@ -171,7 +170,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Custom SMTP. /// - public static string EmailProviderType_CustomSmtp { + internal static string EmailProviderType_CustomSmtp { get { return ResourceManager.GetString("EmailProviderType_CustomSmtp", resourceCulture); } @@ -180,7 +179,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Gmail. /// - public static string EmailProviderType_Gmail { + internal static string EmailProviderType_Gmail { get { return ResourceManager.GetString("EmailProviderType_Gmail", resourceCulture); } @@ -189,7 +188,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Outlook Web Access. /// - public static string EmailProviderType_OutlookWeb { + internal static string EmailProviderType_OutlookWeb { get { return ResourceManager.GetString("EmailProviderType_OutlookWeb", resourceCulture); } @@ -198,7 +197,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Center. /// - public static string HorizontalAlign_Center { + internal static string HorizontalAlign_Center { get { return ResourceManager.GetString("HorizontalAlign_Center", resourceCulture); } @@ -207,7 +206,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Left. /// - public static string HorizontalAlign_Left { + internal static string HorizontalAlign_Left { get { return ResourceManager.GetString("HorizontalAlign_Left", resourceCulture); } @@ -216,7 +215,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Right. /// - public static string HorizontalAlign_Right { + internal static string HorizontalAlign_Right { get { return ResourceManager.GetString("HorizontalAlign_Right", resourceCulture); } @@ -225,7 +224,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to A3 (297x420 mm). /// - public static string PageSize_A3 { + internal static string PageSize_A3 { get { return ResourceManager.GetString("PageSize_A3", resourceCulture); } @@ -234,7 +233,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to A4 (210x297 mm). /// - public static string PageSize_A4 { + internal static string PageSize_A4 { get { return ResourceManager.GetString("PageSize_A4", resourceCulture); } @@ -243,7 +242,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to A5 (148x210 mm). /// - public static string PageSize_A5 { + internal static string PageSize_A5 { get { return ResourceManager.GetString("PageSize_A5", resourceCulture); } @@ -252,7 +251,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to B4 (250x353 mm). /// - public static string PageSize_B4 { + internal static string PageSize_B4 { get { return ResourceManager.GetString("PageSize_B4", resourceCulture); } @@ -261,7 +260,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to B5 (176x250 mm). /// - public static string PageSize_B5 { + internal static string PageSize_B5 { get { return ResourceManager.GetString("PageSize_B5", resourceCulture); } @@ -270,7 +269,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Custom.... /// - public static string PageSize_Custom { + internal static string PageSize_Custom { get { return ResourceManager.GetString("PageSize_Custom", resourceCulture); } @@ -279,7 +278,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to US Legal (8.5x14 in). /// - public static string PageSize_Legal { + internal static string PageSize_Legal { get { return ResourceManager.GetString("PageSize_Legal", resourceCulture); } @@ -288,7 +287,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to US Letter (8.5x11 in). /// - public static string PageSize_Letter { + internal static string PageSize_Letter { get { return ResourceManager.GetString("PageSize_Letter", resourceCulture); } @@ -297,7 +296,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to cm. /// - public static string PageSizeUnit_Centimetre { + internal static string PageSizeUnit_Centimetre { get { return ResourceManager.GetString("PageSizeUnit_Centimetre", resourceCulture); } @@ -306,7 +305,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to in. /// - public static string PageSizeUnit_Inch { + internal static string PageSizeUnit_Inch { get { return ResourceManager.GetString("PageSizeUnit_Inch", resourceCulture); } @@ -315,7 +314,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to mm. /// - public static string PageSizeUnit_Millimetre { + internal static string PageSizeUnit_Millimetre { get { return ResourceManager.GetString("PageSizeUnit_Millimetre", resourceCulture); } @@ -324,7 +323,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Default. /// - public static string PdfCompat_Default { + internal static string PdfCompat_Default { get { return ResourceManager.GetString("PdfCompat_Default", resourceCulture); } @@ -333,7 +332,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to PDF/A-1b. /// - public static string PdfCompat_PdfA1B { + internal static string PdfCompat_PdfA1B { get { return ResourceManager.GetString("PdfCompat_PdfA1B", resourceCulture); } @@ -342,7 +341,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to PDF/A-2b. /// - public static string PdfCompat_PdfA2B { + internal static string PdfCompat_PdfA2B { get { return ResourceManager.GetString("PdfCompat_PdfA2B", resourceCulture); } @@ -351,7 +350,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to PDF/A-3b. /// - public static string PdfCompat_PdfA3B { + internal static string PdfCompat_PdfA3B { get { return ResourceManager.GetString("PdfCompat_PdfA3B", resourceCulture); } @@ -360,7 +359,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to PDF/A-3u. /// - public static string PdfCompat_PdfA3U { + internal static string PdfCompat_PdfA3U { get { return ResourceManager.GetString("PdfCompat_PdfA3U", resourceCulture); } @@ -369,7 +368,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1:1. /// - public static string Scale_1_1 { + internal static string Scale_1_1 { get { return ResourceManager.GetString("Scale_1_1", resourceCulture); } @@ -378,7 +377,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1:2. /// - public static string Scale_1_2 { + internal static string Scale_1_2 { get { return ResourceManager.GetString("Scale_1_2", resourceCulture); } @@ -387,7 +386,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1:4. /// - public static string Scale_1_4 { + internal static string Scale_1_4 { get { return ResourceManager.GetString("Scale_1_4", resourceCulture); } @@ -396,7 +395,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1:8. /// - public static string Scale_1_8 { + internal static string Scale_1_8 { get { return ResourceManager.GetString("Scale_1_8", resourceCulture); } @@ -405,7 +404,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Duplex. /// - public static string Source_Duplex { + internal static string Source_Duplex { get { return ResourceManager.GetString("Source_Duplex", resourceCulture); } @@ -414,7 +413,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Feeder. /// - public static string Source_Feeder { + internal static string Source_Feeder { get { return ResourceManager.GetString("Source_Feeder", resourceCulture); } @@ -423,7 +422,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Glass. /// - public static string Source_Glass { + internal static string Source_Glass { get { return ResourceManager.GetString("Source_Glass", resourceCulture); } @@ -432,7 +431,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Auto. /// - public static string TiffComp_Auto { + internal static string TiffComp_Auto { get { return ResourceManager.GetString("TiffComp_Auto", resourceCulture); } @@ -441,7 +440,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to CCITT4. /// - public static string TiffComp_Ccitt4 { + internal static string TiffComp_Ccitt4 { get { return ResourceManager.GetString("TiffComp_Ccitt4", resourceCulture); } @@ -450,7 +449,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to LZW. /// - public static string TiffComp_Lzw { + internal static string TiffComp_Lzw { get { return ResourceManager.GetString("TiffComp_Lzw", resourceCulture); } @@ -459,7 +458,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to None. /// - public static string TiffComp_None { + internal static string TiffComp_None { get { return ResourceManager.GetString("TiffComp_None", resourceCulture); } @@ -468,7 +467,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Default. /// - public static string TwainImpl_Default { + internal static string TwainImpl_Default { get { return ResourceManager.GetString("TwainImpl_Default", resourceCulture); } @@ -477,7 +476,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Legacy (native UI only). /// - public static string TwainImpl_Legacy { + internal static string TwainImpl_Legacy { get { return ResourceManager.GetString("TwainImpl_Legacy", resourceCulture); } @@ -486,7 +485,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Alternative Transfer. /// - public static string TwainImpl_MemXfer { + internal static string TwainImpl_MemXfer { get { return ResourceManager.GetString("TwainImpl_MemXfer", resourceCulture); } @@ -495,7 +494,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Old DSM. /// - public static string TwainImpl_OldDsm { + internal static string TwainImpl_OldDsm { get { return ResourceManager.GetString("TwainImpl_OldDsm", resourceCulture); } @@ -504,7 +503,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to x64. /// - public static string TwainImpl_X64 { + internal static string TwainImpl_X64 { get { return ResourceManager.GetString("TwainImpl_X64", resourceCulture); } @@ -513,7 +512,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to Default. /// - public static string WiaVersion_Default { + internal static string WiaVersion_Default { get { return ResourceManager.GetString("WiaVersion_Default", resourceCulture); } @@ -522,7 +521,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 1.0. /// - public static string WiaVersion_Wia10 { + internal static string WiaVersion_Wia10 { get { return ResourceManager.GetString("WiaVersion_Wia10", resourceCulture); } @@ -531,7 +530,7 @@ namespace NAPS2.Lang.Resources { /// /// Looks up a localized string similar to 2.0. /// - public static string WiaVersion_Wia20 { + internal static string WiaVersion_Wia20 { get { return ResourceManager.GetString("WiaVersion_Wia20", resourceCulture); } diff --git a/NAPS2.Lib/Lang/Resources/SettingsResources.resx b/NAPS2.Lib/Lang/Resources/SettingsResources.resx index a06903cd0..624a02751 100644 --- a/NAPS2.Lib/Lang/Resources/SettingsResources.resx +++ b/NAPS2.Lib/Lang/Resources/SettingsResources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Black & White + Black/White 24-bit Color diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs index b8acb08c6..8dc6f2e3a 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs +++ b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs @@ -11,32 +11,46 @@ namespace NAPS2.Lang.Resources { using System; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class UiStrings { - private static System.Resources.ResourceManager resourceMan; + private static global::System.Resources.ResourceManager resourceMan; - private static System.Globalization.CultureInfo resourceCulture; + private static global::System.Globalization.CultureInfo resourceCulture; - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal UiStrings() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager { + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { get { - if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("NAPS2.Lang.Resources.UiStrings", typeof(UiStrings).Assembly); + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NAPS2.Lang.Resources.UiStrings", typeof(UiStrings).Assembly); resourceMan = temp; } return resourceMan; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture { + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -45,388 +59,778 @@ namespace NAPS2.Lang.Resources { } } - internal static string AboutFormTitle { - get { - return ResourceManager.GetString("AboutFormTitle", resourceCulture); - } - } - - internal static string Copyright { - get { - return ResourceManager.GetString("Copyright", resourceCulture); - } - } - - internal static string IconsFrom { - get { - return ResourceManager.GetString("IconsFrom", resourceCulture); - } - } - - internal static string CheckForUpdates { - get { - return ResourceManager.GetString("CheckForUpdates", resourceCulture); - } - } - - internal static string OK { - get { - return ResourceManager.GetString("OK", resourceCulture); - } - } - - internal static string Donate { - get { - return ResourceManager.GetString("Donate", resourceCulture); - } - } - - internal static string ProfilesFormTitle { - get { - return ResourceManager.GetString("ProfilesFormTitle", resourceCulture); - } - } - - internal static string Add { - get { - return ResourceManager.GetString("Add", resourceCulture); - } - } - - internal static string Edit { - get { - return ResourceManager.GetString("Edit", resourceCulture); - } - } - - internal static string Delete { - get { - return ResourceManager.GetString("Delete", resourceCulture); - } - } - - internal static string Scan { - get { - return ResourceManager.GetString("Scan", resourceCulture); - } - } - - internal static string SetDefault { - get { - return ResourceManager.GetString("SetDefault", resourceCulture); - } - } - - internal static string Copy { - get { - return ResourceManager.GetString("Copy", resourceCulture); - } - } - - internal static string Paste { - get { - return ResourceManager.GetString("Paste", resourceCulture); - } - } - - internal static string Done { - get { - return ResourceManager.GetString("Done", resourceCulture); - } - } - - internal static string Default { - get { - return ResourceManager.GetString("Default", resourceCulture); - } - } - - internal static string NewProfile { - get { - return ResourceManager.GetString("NewProfile", resourceCulture); - } - } - - internal static string BatchScan { - get { - return ResourceManager.GetString("BatchScan", resourceCulture); - } - } - - internal static string Ocr { - get { - return ResourceManager.GetString("Ocr", resourceCulture); - } - } - - internal static string Profiles { - get { - return ResourceManager.GetString("Profiles", resourceCulture); - } - } - - internal static string Import { - get { - return ResourceManager.GetString("Import", resourceCulture); - } - } - - internal static string SavePdf { - get { - return ResourceManager.GetString("SavePdf", resourceCulture); - } - } - - internal static string PdfSettings { - get { - return ResourceManager.GetString("PdfSettings", resourceCulture); - } - } - - internal static string SaveImages { - get { - return ResourceManager.GetString("SaveImages", resourceCulture); - } - } - - internal static string ImageSettings { - get { - return ResourceManager.GetString("ImageSettings", resourceCulture); - } - } - - internal static string EmailPdf { - get { - return ResourceManager.GetString("EmailPdf", resourceCulture); - } - } - - internal static string EmailSettings { - get { - return ResourceManager.GetString("EmailSettings", resourceCulture); - } - } - - internal static string Print { - get { - return ResourceManager.GetString("Print", resourceCulture); - } - } - - internal static string Image { - get { - return ResourceManager.GetString("Image", resourceCulture); - } - } - - internal static string View { - get { - return ResourceManager.GetString("View", resourceCulture); - } - } - - internal static string Crop { - get { - return ResourceManager.GetString("Crop", resourceCulture); - } - } - - internal static string BrightnessContrast { - get { - return ResourceManager.GetString("BrightnessContrast", resourceCulture); - } - } - - internal static string HueSaturation { - get { - return ResourceManager.GetString("HueSaturation", resourceCulture); - } - } - - internal static string BlackAndWhite { - get { - return ResourceManager.GetString("BlackAndWhite", resourceCulture); - } - } - - internal static string Sharpen { - get { - return ResourceManager.GetString("Sharpen", resourceCulture); - } - } - - internal static string Reset { - get { - return ResourceManager.GetString("Reset", resourceCulture); - } - } - - internal static string Rotate { - get { - return ResourceManager.GetString("Rotate", resourceCulture); - } - } - - internal static string RotateLeft { - get { - return ResourceManager.GetString("RotateLeft", resourceCulture); - } - } - - internal static string RotateRight { - get { - return ResourceManager.GetString("RotateRight", resourceCulture); - } - } - - internal static string Flip { - get { - return ResourceManager.GetString("Flip", resourceCulture); - } - } - - internal static string Deskew { - get { - return ResourceManager.GetString("Deskew", resourceCulture); - } - } - - internal static string CustomRotation { - get { - return ResourceManager.GetString("CustomRotation", resourceCulture); - } - } - - internal static string MoveUp { - get { - return ResourceManager.GetString("MoveUp", resourceCulture); - } - } - - internal static string MoveDown { - get { - return ResourceManager.GetString("MoveDown", resourceCulture); - } - } - - internal static string Reorder { - get { - return ResourceManager.GetString("Reorder", resourceCulture); - } - } - - internal static string Interleave { - get { - return ResourceManager.GetString("Interleave", resourceCulture); - } - } - - internal static string Deinterleave { - get { - return ResourceManager.GetString("Deinterleave", resourceCulture); - } - } - - internal static string AltInterleave { - get { - return ResourceManager.GetString("AltInterleave", resourceCulture); - } - } - - internal static string AltDeinterleave { - get { - return ResourceManager.GetString("AltDeinterleave", resourceCulture); - } - } - - internal static string Reverse { - get { - return ResourceManager.GetString("Reverse", resourceCulture); - } - } - - internal static string Clear { - get { - return ResourceManager.GetString("Clear", resourceCulture); - } - } - - internal static string ClearAll { - get { - return ResourceManager.GetString("ClearAll", resourceCulture); - } - } - - internal static string Language { - get { - return ResourceManager.GetString("Language", resourceCulture); - } - } - + /// + /// Looks up a localized string similar to About. + /// internal static string About { get { return ResourceManager.GetString("About", resourceCulture); } } - internal static string Zoom { + /// + /// Looks up a localized string similar to About. + /// + internal static string AboutFormTitle { get { - return ResourceManager.GetString("Zoom", resourceCulture); + return ResourceManager.GetString("AboutFormTitle", resourceCulture); } } - internal static string ZoomIn { + /// + /// Looks up a localized string similar to Add. + /// + internal static string Add { get { - return ResourceManager.GetString("ZoomIn", resourceCulture); + return ResourceManager.GetString("Add", resourceCulture); } } - internal static string ZoomOut { + /// + /// Looks up a localized string similar to Advanced. + /// + internal static string Advanced { get { - return ResourceManager.GetString("ZoomOut", resourceCulture); + return ResourceManager.GetString("Advanced", resourceCulture); } } - internal static string Save { + /// + /// Looks up a localized string similar to Alternate Deinterleave. + /// + internal static string AltDeinterleave { get { - return ResourceManager.GetString("Save", resourceCulture); + return ResourceManager.GetString("AltDeinterleave", resourceCulture); } } - internal static string SaveAllAsPdf { + /// + /// Looks up a localized string similar to Alternate Interleave. + /// + internal static string AltInterleave { get { - return ResourceManager.GetString("SaveAllAsPdf", resourceCulture); + return ResourceManager.GetString("AltInterleave", resourceCulture); } } - internal static string SaveSelectedAsPdf { + /// + /// Looks up a localized string similar to Apple Driver. + /// + internal static string AppleDriver { get { - return ResourceManager.GetString("SaveSelectedAsPdf", resourceCulture); + return ResourceManager.GetString("AppleDriver", resourceCulture); } } - internal static string SaveAllAsImages { + /// + /// Looks up a localized string similar to Auto Save Settings. + /// + internal static string AutoSaveSettings { get { - return ResourceManager.GetString("SaveAllAsImages", resourceCulture); + return ResourceManager.GetString("AutoSaveSettings", resourceCulture); } } - internal static string SaveSelectedAsImages { + /// + /// Looks up a localized string similar to Batch Scan. + /// + internal static string BatchScan { get { - return ResourceManager.GetString("SaveSelectedAsImages", resourceCulture); + return ResourceManager.GetString("BatchScan", resourceCulture); } } + /// + /// Looks up a localized string similar to Bit depth:. + /// + internal static string BitDepthLabel { + get { + return ResourceManager.GetString("BitDepthLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Black and White. + /// + internal static string BlackAndWhite { + get { + return ResourceManager.GetString("BlackAndWhite", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Brightness / Contrast. + /// + internal static string BrightnessContrast { + get { + return ResourceManager.GetString("BrightnessContrast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Brightness:. + /// + internal static string BrightnessLabel { + get { + return ResourceManager.GetString("BrightnessLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string Cancel { + get { + return ResourceManager.GetString("Cancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Check for updates. + /// + internal static string CheckForUpdates { + get { + return ResourceManager.GetString("CheckForUpdates", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Choose device. + /// + internal static string ChooseDevice { + get { + return ResourceManager.GetString("ChooseDevice", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear. + /// + internal static string Clear { + get { + return ResourceManager.GetString("Clear", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear All. + /// + internal static string ClearAll { + get { + return ResourceManager.GetString("ClearAll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Contrast:. + /// + internal static string ContrastLabel { + get { + return ResourceManager.GetString("ContrastLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copy. + /// + internal static string Copy { + get { + return ResourceManager.GetString("Copy", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copyright 2009, 2012-2020 NAPS2 Contributors. + /// + internal static string Copyright { + get { + return ResourceManager.GetString("Copyright", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Crop. + /// + internal static string Crop { + get { + return ResourceManager.GetString("Crop", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Custom Rotation. + /// + internal static string CustomRotation { + get { + return ResourceManager.GetString("CustomRotation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default. + /// + internal static string Default { + get { + return ResourceManager.GetString("Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deinterleave. + /// + internal static string Deinterleave { + get { + return ResourceManager.GetString("Deinterleave", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + internal static string Delete { + get { + return ResourceManager.GetString("Delete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deskew. + /// + internal static string Deskew { + get { + return ResourceManager.GetString("Deskew", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Device:. + /// + internal static string DeviceLabel { + get { + return ResourceManager.GetString("DeviceLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Display name:. + /// + internal static string DisplayNameLabel { + get { + return ResourceManager.GetString("DisplayNameLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Donate. + /// + internal static string Donate { + get { + return ResourceManager.GetString("Donate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Done. + /// + internal static string Done { + get { + return ResourceManager.GetString("Done", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit. + /// + internal static string Edit { + get { + return ResourceManager.GetString("Edit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Profile Settings. + /// + internal static string EditProfileFormTitle { + get { + return ResourceManager.GetString("EditProfileFormTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Email All as PDF. + /// internal static string EmailAllAsPdf { get { return ResourceManager.GetString("EmailAllAsPdf", resourceCulture); } } + /// + /// Looks up a localized string similar to Email PDF. + /// + internal static string EmailPdf { + get { + return ResourceManager.GetString("EmailPdf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Email Selected as PDF. + /// internal static string EmailSelectedAsPdf { get { return ResourceManager.GetString("EmailSelectedAsPdf", resourceCulture); } } + + /// + /// Looks up a localized string similar to Email Settings. + /// + internal static string EmailSettings { + get { + return ResourceManager.GetString("EmailSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Enable Auto Save. + /// + internal static string EnableAutoSave { + get { + return ResourceManager.GetString("EnableAutoSave", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Flip. + /// + internal static string Flip { + get { + return ResourceManager.GetString("Flip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Horizontal align:. + /// + internal static string HorizontalAlignLabel { + get { + return ResourceManager.GetString("HorizontalAlignLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hue / Saturation. + /// + internal static string HueSaturation { + get { + return ResourceManager.GetString("HueSaturation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Icons from:. + /// + internal static string IconsFrom { + get { + return ResourceManager.GetString("IconsFrom", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image. + /// + internal static string Image { + get { + return ResourceManager.GetString("Image", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image Settings. + /// + internal static string ImageSettings { + get { + return ResourceManager.GetString("ImageSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Import. + /// + internal static string Import { + get { + return ResourceManager.GetString("Import", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Interleave. + /// + internal static string Interleave { + get { + return ResourceManager.GetString("Interleave", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language. + /// + internal static string Language { + get { + return ResourceManager.GetString("Language", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move Down. + /// + internal static string MoveDown { + get { + return ResourceManager.GetString("MoveDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move Up. + /// + internal static string MoveUp { + get { + return ResourceManager.GetString("MoveUp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New Profile. + /// + internal static string NewProfile { + get { + return ResourceManager.GetString("NewProfile", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OCR. + /// + internal static string Ocr { + get { + return ResourceManager.GetString("Ocr", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OK. + /// + internal static string OK { + get { + return ResourceManager.GetString("OK", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Page size:. + /// + internal static string PageSizeLabel { + get { + return ResourceManager.GetString("PageSizeLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Paper source:. + /// + internal static string PaperSourceLabel { + get { + return ResourceManager.GetString("PaperSourceLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Paste. + /// + internal static string Paste { + get { + return ResourceManager.GetString("Paste", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PDF Settings. + /// + internal static string PdfSettings { + get { + return ResourceManager.GetString("PdfSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Print. + /// + internal static string Print { + get { + return ResourceManager.GetString("Print", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Profiles. + /// + internal static string Profiles { + get { + return ResourceManager.GetString("Profiles", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Profiles. + /// + internal static string ProfilesFormTitle { + get { + return ResourceManager.GetString("ProfilesFormTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reorder. + /// + internal static string Reorder { + get { + return ResourceManager.GetString("Reorder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reset. + /// + internal static string Reset { + get { + return ResourceManager.GetString("Reset", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Resolution:. + /// + internal static string ResolutionLabel { + get { + return ResourceManager.GetString("ResolutionLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reverse. + /// + internal static string Reverse { + get { + return ResourceManager.GetString("Reverse", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Rotate. + /// + internal static string Rotate { + get { + return ResourceManager.GetString("Rotate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Rotate Left. + /// + internal static string RotateLeft { + get { + return ResourceManager.GetString("RotateLeft", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Rotate Right. + /// + internal static string RotateRight { + get { + return ResourceManager.GetString("RotateRight", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to SANE Driver. + /// + internal static string SaneDriver { + get { + return ResourceManager.GetString("SaneDriver", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save. + /// + internal static string Save { + get { + return ResourceManager.GetString("Save", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save All as Images. + /// + internal static string SaveAllAsImages { + get { + return ResourceManager.GetString("SaveAllAsImages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save All as PDF. + /// + internal static string SaveAllAsPdf { + get { + return ResourceManager.GetString("SaveAllAsPdf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save Images. + /// + internal static string SaveImages { + get { + return ResourceManager.GetString("SaveImages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save PDF. + /// + internal static string SavePdf { + get { + return ResourceManager.GetString("SavePdf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save Selected as Images. + /// + internal static string SaveSelectedAsImages { + get { + return ResourceManager.GetString("SaveSelectedAsImages", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save Selected as PDF. + /// + internal static string SaveSelectedAsPdf { + get { + return ResourceManager.GetString("SaveSelectedAsPdf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Scale:. + /// + internal static string ScaleLabel { + get { + return ResourceManager.GetString("ScaleLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Scan. + /// + internal static string Scan { + get { + return ResourceManager.GetString("Scan", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set Default. + /// + internal static string SetDefault { + get { + return ResourceManager.GetString("SetDefault", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sharpen. + /// + internal static string Sharpen { + get { + return ResourceManager.GetString("Sharpen", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to TWAIN Driver. + /// + internal static string TwainDriver { + get { + return ResourceManager.GetString("TwainDriver", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use native UI. + /// + internal static string UseNativeUi { + get { + return ResourceManager.GetString("UseNativeUi", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use predefined settings. + /// + internal static string UsePredefinedSettings { + get { + return ResourceManager.GetString("UsePredefinedSettings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to View. + /// + internal static string View { + get { + return ResourceManager.GetString("View", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to WIA Driver. + /// + internal static string WiaDriver { + get { + return ResourceManager.GetString("WiaDriver", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Zoom. + /// + internal static string Zoom { + get { + return ResourceManager.GetString("Zoom", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Zoom In. + /// + internal static string ZoomIn { + get { + return ResourceManager.GetString("ZoomIn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Zoom Out. + /// + internal static string ZoomOut { + get { + return ResourceManager.GetString("ZoomOut", resourceCulture); + } + } } } diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.resx b/NAPS2.Lib/Lang/Resources/UiStrings.resx index 8a672faf3..eccc33d3c 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.resx @@ -315,4 +315,73 @@ Email Selected as PDF + + Profile Settings + + + Display name: + + + WIA Driver + + + TWAIN Driver + + + Apple Driver + + + SANE Driver + + + Device: + + + Choose device + + + Use predefined settings + + + Use native UI + + + Paper source: + + + Page size: + + + Resolution: + + + Brightness: + + + Bit depth: + + + Horizontal align: + + + Scale: + + + Contrast: + + + Enable Auto Save + + + Auto Save Settings + + + Advanced + + + OK + + + Cancel + \ No newline at end of file diff --git a/NAPS2.Sdk/Platform/ISystemCompat.cs b/NAPS2.Sdk/Platform/ISystemCompat.cs index f8d80ad27..ea87238ed 100644 --- a/NAPS2.Sdk/Platform/ISystemCompat.cs +++ b/NAPS2.Sdk/Platform/ISystemCompat.cs @@ -6,6 +6,8 @@ public interface ISystemCompat bool IsTwainDriverSupported { get; } + bool IsAppleDriverSupported { get; } + bool IsSaneDriverSupported { get; } bool CanUseWin32 { get; } diff --git a/NAPS2.Sdk/Platform/LinuxSystemCompat.cs b/NAPS2.Sdk/Platform/LinuxSystemCompat.cs index a5d2f77ce..94d3059cc 100644 --- a/NAPS2.Sdk/Platform/LinuxSystemCompat.cs +++ b/NAPS2.Sdk/Platform/LinuxSystemCompat.cs @@ -13,6 +13,8 @@ public class LinuxSystemCompat : ISystemCompat public bool IsTwainDriverSupported => false; + public bool IsAppleDriverSupported => false; + public bool IsSaneDriverSupported => true; public bool CanUseWin32 => false; diff --git a/NAPS2.Sdk/Platform/MacSystemCompat.cs b/NAPS2.Sdk/Platform/MacSystemCompat.cs index 6eda3a343..b790a727f 100644 --- a/NAPS2.Sdk/Platform/MacSystemCompat.cs +++ b/NAPS2.Sdk/Platform/MacSystemCompat.cs @@ -14,6 +14,8 @@ public class MacSystemCompat : ISystemCompat public bool IsTwainDriverSupported => true; + public bool IsAppleDriverSupported => true; + public bool IsSaneDriverSupported => false; public bool CanUseWin32 => false; diff --git a/NAPS2.Sdk/Platform/WindowsSystemCompat.cs b/NAPS2.Sdk/Platform/WindowsSystemCompat.cs index 23fd6901c..86f8f2a4e 100644 --- a/NAPS2.Sdk/Platform/WindowsSystemCompat.cs +++ b/NAPS2.Sdk/Platform/WindowsSystemCompat.cs @@ -11,6 +11,8 @@ public abstract class WindowsSystemCompat : ISystemCompat public bool IsTwainDriverSupported => true; + public bool IsAppleDriverSupported => false; + public bool IsSaneDriverSupported => false; public bool CanUseWin32 => true; diff --git a/NAPS2.Sdk/Scan/Driver.cs b/NAPS2.Sdk/Scan/Driver.cs index 46f896c1a..2b8347325 100644 --- a/NAPS2.Sdk/Scan/Driver.cs +++ b/NAPS2.Sdk/Scan/Driver.cs @@ -5,5 +5,7 @@ public enum Driver Default, Wia, Twain, - Sane + Apple, + Sane, + Escl } \ No newline at end of file diff --git a/NAPS2.Sdk/Scan/Internal/ScanOptionsValidator.cs b/NAPS2.Sdk/Scan/Internal/ScanOptionsValidator.cs index 784aa3e6f..45aaa526b 100644 --- a/NAPS2.Sdk/Scan/Internal/ScanOptionsValidator.cs +++ b/NAPS2.Sdk/Scan/Internal/ScanOptionsValidator.cs @@ -10,7 +10,7 @@ public class ScanOptionsValidator // Easy deep copy. Ideally we'd do this in a more efficient way. options = options.ToXml().FromXml(); - options.Driver = ValidateDriver(options); + options.Driver = ValidateDriver(options.Driver); if (options.Driver == Driver.Sane) { options.UseNativeUI = false; @@ -69,28 +69,30 @@ public class ScanOptionsValidator return options; } - public Driver ValidateDriver(ScanOptions options) - { - if (options.Driver == Driver.Default) - { - return GetSystemDefaultDriver(); - } - // TODO: Throw NotSupportedException if the platform doesn't match the driver - return options.Driver; - } + public Driver ValidateDriver(Driver driver) => + driver == Driver.Default + ? SystemDefaultDriver + : driver; - private Driver GetSystemDefaultDriver() + public static Driver SystemDefaultDriver { - switch (Environment.OSVersion.Platform) + get { - case PlatformID.Win32NT: + if (PlatformCompat.System.IsWiaDriverSupported) + { + // TODO: Maybe default to TWAIN + // TODO: Also in general "default driver" handling should change return Driver.Wia; - case PlatformID.Unix: + } + if (PlatformCompat.System.IsAppleDriverSupported) + { + return Driver.Apple; + } + if (PlatformCompat.System.IsSaneDriverSupported) + { return Driver.Sane; - case PlatformID.MacOSX: - return Driver.Twain; - default: - throw new InvalidOperationException("Unsupported operating system."); + } + return Driver.Escl; } } } \ No newline at end of file diff --git a/NAPS2.sln.DotSettings b/NAPS2.sln.DotSettings index 1758aca46..27ad024bf 100644 --- a/NAPS2.sln.DotSettings +++ b/NAPS2.sln.DotSettings @@ -9,6 +9,7 @@ <data><IncludeFilters /><ExcludeFilters /></data> <data /> True + True True True True