mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Add "Show native TWAIN progress" compat option
This commit is contained in:
parent
91717d1750
commit
33043256c3
@ -29,6 +29,7 @@ public class AdvancedProfileForm : EtoDialogBase
|
||||
});
|
||||
|
||||
private readonly DropDown _twainImpl = C.EnumDropDown<TwainImpl>();
|
||||
private readonly CheckBox _twainProgress = new() { Text = UiStrings.ShowNativeTwainProgress };
|
||||
private readonly Button _restoreDefaults = new() { Text = UiStrings.RestoreDefaults };
|
||||
|
||||
public AdvancedProfileForm(Naps2Config config) : base(config)
|
||||
@ -88,7 +89,8 @@ public class AdvancedProfileForm : EtoDialogBase
|
||||
PlatformCompat.System.IsWiaDriverSupported ? C.Label(UiStrings.WiaVersionLabel) : C.None(),
|
||||
PlatformCompat.System.IsWiaDriverSupported ? _wiaVersion : C.None(),
|
||||
PlatformCompat.System.IsTwainDriverSupported ? C.Label(UiStrings.TwainImplLabel) : C.None(),
|
||||
PlatformCompat.System.IsTwainDriverSupported ? _twainImpl : C.None()
|
||||
PlatformCompat.System.IsTwainDriverSupported ? _twainImpl : C.None(),
|
||||
PlatformCompat.System.IsTwainDriverSupported ? _twainProgress : C.None()
|
||||
)
|
||||
),
|
||||
L.Row(
|
||||
@ -113,6 +115,7 @@ public class AdvancedProfileForm : EtoDialogBase
|
||||
_cropToPageSize.Checked = scanProfile.ForcePageSizeCrop;
|
||||
_flipDuplexed.Checked = scanProfile.FlipDuplexedPages;
|
||||
_twainImpl.SelectedIndex = (int) scanProfile.TwainImpl;
|
||||
_twainProgress.Checked = scanProfile.TwainProgress;
|
||||
_excludeBlank.Checked = scanProfile.ExcludeBlankPages;
|
||||
_whiteThreshold.IntValue = scanProfile.BlankPageWhiteThreshold;
|
||||
_coverageThreshold.IntValue = scanProfile.BlankPageCoverageThreshold;
|
||||
@ -121,6 +124,7 @@ public class AdvancedProfileForm : EtoDialogBase
|
||||
private void UpdateEnabled()
|
||||
{
|
||||
_twainImpl.Enabled = ScanProfile!.DriverName == DriverNames.TWAIN;
|
||||
_twainProgress.Enabled = ScanProfile!.DriverName == DriverNames.TWAIN;
|
||||
_offsetWidth.Enabled = ScanProfile.DriverName == DriverNames.WIA;
|
||||
_wiaVersion.Enabled = ScanProfile.DriverName == DriverNames.WIA;
|
||||
_quality.Enabled = !_maximumQuality.IsChecked();
|
||||
@ -148,6 +152,7 @@ public class AdvancedProfileForm : EtoDialogBase
|
||||
{
|
||||
ScanProfile.TwainImpl = (TwainImpl) _twainImpl.SelectedIndex;
|
||||
}
|
||||
ScanProfile.TwainProgress = _twainProgress.IsChecked();
|
||||
ScanProfile.ExcludeBlankPages = _excludeBlank.IsChecked();
|
||||
ScanProfile.BlankPageWhiteThreshold = _whiteThreshold.IntValue;
|
||||
ScanProfile.BlankPageCoverageThreshold = _coverageThreshold.IntValue;
|
||||
|
@ -404,6 +404,7 @@ public class EditProfileForm : EtoDialogBase
|
||||
ForcePageSizeCrop = ScanProfile.ForcePageSizeCrop,
|
||||
FlipDuplexedPages = ScanProfile.FlipDuplexedPages,
|
||||
TwainImpl = ScanProfile.TwainImpl,
|
||||
TwainProgress = ScanProfile.TwainProgress,
|
||||
|
||||
ExcludeBlankPages = ScanProfile.ExcludeBlankPages,
|
||||
BlankPageWhiteThreshold = ScanProfile.BlankPageWhiteThreshold,
|
||||
|
9
NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs
generated
9
NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs
generated
@ -2030,6 +2030,15 @@ namespace NAPS2.Lang.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show native TWAIN progress.
|
||||
/// </summary>
|
||||
internal static string ShowNativeTwainProgress {
|
||||
get {
|
||||
return ResourceManager.GetString("ShowNativeTwainProgress", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show page numbers.
|
||||
/// </summary>
|
||||
|
@ -870,4 +870,7 @@
|
||||
<data name="OcrMultiLangFormTitle" xml:space="preserve">
|
||||
<value>Multiple Languages</value>
|
||||
</data>
|
||||
<data name="ShowNativeTwainProgress" xml:space="preserve">
|
||||
<value>Show native TWAIN progress</value>
|
||||
</data>
|
||||
</root>
|
@ -183,7 +183,8 @@ internal class ScanPerformer : IScanPerformer
|
||||
private void ShowOperation(ScanOperation op, ScanOptions scanOptions, ScanParams scanParams)
|
||||
{
|
||||
bool isWia10 = scanOptions.Driver == Driver.Wia && scanOptions.WiaOptions.WiaApiVersion == WiaApiVersion.Wia10;
|
||||
if (scanParams.NoUI || scanOptions.UseNativeUI && !isWia10)
|
||||
bool showingTwainProgress = scanOptions.Driver == Driver.Twain && scanOptions.TwainOptions.ShowProgress;
|
||||
if (scanParams.NoUI || scanOptions.UseNativeUI && !isWia10 || showingTwainProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -233,6 +234,7 @@ internal class ScanPerformer : IScanPerformer
|
||||
TransferMode = scanProfile.TwainImpl is TwainImpl.Default or TwainImpl.MemXfer
|
||||
? TwainTransferMode.Memory
|
||||
: TwainTransferMode.Native,
|
||||
ShowProgress = scanProfile.TwainProgress,
|
||||
IncludeWiaDevices = false
|
||||
// TODO: Consider adding a user option for TwainOptions.ShowProgress instead of our progress window
|
||||
},
|
||||
|
@ -105,6 +105,8 @@ public class ScanProfile
|
||||
|
||||
public TwainImpl TwainImpl { get; set; }
|
||||
|
||||
public bool TwainProgress { get; set; }
|
||||
|
||||
public bool ExcludeBlankPages { get; set; }
|
||||
|
||||
public int BlankPageWhiteThreshold { get; set; }
|
||||
|
@ -52,7 +52,7 @@ internal class TwainScanDriver : IScanDriver
|
||||
|
||||
private void EnableWindow(ScanOptions options)
|
||||
{
|
||||
if (options.DialogParent != IntPtr.Zero && options.UseNativeUI)
|
||||
if (options.DialogParent != IntPtr.Zero && (options.UseNativeUI || options.TwainOptions.ShowProgress))
|
||||
{
|
||||
// At the Windows API level, a modal window is implemented by doing two things:
|
||||
// 1. Setting the parent on the child window
|
||||
|
@ -62,7 +62,7 @@ internal class TwainSessionScanRunner
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("NAPS2.TW - Opening session");
|
||||
var dsmHandle = _handleManager.GetDsmHandle(_options.DialogParent, _options.UseNativeUI);
|
||||
var dsmHandle = _handleManager.GetDsmHandle(_options.DialogParent, _options.UseNativeUI || _options.TwainOptions.ShowProgress);
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
if (!OperatingSystem.IsWindows()) throw new InvalidOperationException("Windows-only");
|
||||
@ -99,7 +99,7 @@ internal class TwainSessionScanRunner
|
||||
|
||||
_logger.LogDebug("NAPS2.TW - Enabling source");
|
||||
var ui = _options.UseNativeUI ? SourceEnableMode.ShowUI : SourceEnableMode.NoUI;
|
||||
var enableHandle = _handleManager.GetEnableHandle(_options.DialogParent, _options.UseNativeUI);
|
||||
var enableHandle = _handleManager.GetEnableHandle(_options.DialogParent, _options.UseNativeUI || _options.TwainOptions.ShowProgress);
|
||||
// Note that according to the twain spec, on Windows it is recommended to set the modal parameter to false
|
||||
rc = _source.Enable(ui, false, enableHandle);
|
||||
if (rc != ReturnCode.Success)
|
||||
|
Loading…
Reference in New Issue
Block a user