diff --git a/NAPS2.Images.Gdi/NAPS2.Images.Gdi.csproj b/NAPS2.Images.Gdi/NAPS2.Images.Gdi.csproj
index 22187b98d..207477f6e 100644
--- a/NAPS2.Images.Gdi/NAPS2.Images.Gdi.csproj
+++ b/NAPS2.Images.Gdi/NAPS2.Images.Gdi.csproj
@@ -1,7 +1,7 @@
- net6;net462;netcoreapp2.1;netstandard2.0
+ net6;net462;netstandard2.0
enable
true
false
@@ -13,7 +13,7 @@
-
+
diff --git a/NAPS2.Lib.Mac/Modules/MacModule.cs b/NAPS2.Lib.Mac/Modules/MacModule.cs
index 457a2a4af..bb54417c1 100644
--- a/NAPS2.Lib.Mac/Modules/MacModule.cs
+++ b/NAPS2.Lib.Mac/Modules/MacModule.cs
@@ -3,7 +3,7 @@ using NAPS2.EtoForms.Mac;
using NAPS2.EtoForms.Ui;
using NAPS2.Images.Mac;
using NAPS2.ImportExport;
-using NAPS2.ImportExport.Email;
+using NAPS2.ImportExport.Images;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.Update;
@@ -27,6 +27,7 @@ public class MacModule : NinjectModule
Bind().To().InSingletonScope();
Bind().ToMethod(ctx => ctx.Kernel.Get());
Bind().To();
+ Bind().To();
Bind().ToSelf().InSingletonScope();
Bind().To();
Bind().To();
diff --git a/NAPS2.Lib.Tests/Automation/TestModule.cs b/NAPS2.Lib.Tests/Automation/TestModule.cs
index 4a3fd0d48..9db4aa84a 100644
--- a/NAPS2.Lib.Tests/Automation/TestModule.cs
+++ b/NAPS2.Lib.Tests/Automation/TestModule.cs
@@ -1,4 +1,5 @@
using NAPS2.Automation;
+using NAPS2.ImportExport.Images;
using NAPS2.Ocr;
using NAPS2.Recovery;
using NAPS2.Scan;
@@ -31,7 +32,8 @@ internal class TestModule : NinjectModule
public override void Load()
{
- Rebind().ToConstant(_imageContext);
+ Bind().ToConstant(_imageContext);
+ Bind().To();
Rebind().ToConstant(_scanDriverFactory);
Rebind().To();
Rebind().ToSelf()
diff --git a/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs b/NAPS2.Lib.WinForms/EntryPoints/ConsoleEntryPoint.cs
similarity index 92%
rename from NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs
rename to NAPS2.Lib.WinForms/EntryPoints/ConsoleEntryPoint.cs
index 753cdfa0b..00212e43d 100644
--- a/NAPS2.Lib/EntryPoints/ConsoleEntryPoint.cs
+++ b/NAPS2.Lib.WinForms/EntryPoints/ConsoleEntryPoint.cs
@@ -23,8 +23,8 @@ public static class ConsoleEntryPoint
}
// Initialize Ninject (the DI framework)
- var kernel = new StandardKernel(new CommonModule(), new ConsoleModule(options), new RecoveryModule(),
- new ContextModule());
+ var kernel = new StandardKernel(new CommonModule(), new GdiModule(), new ConsoleModule(options),
+ new RecoveryModule(), new ContextModule());
Paths.ClearTemp();
diff --git a/NAPS2.Lib.WinForms/EntryPoints/WinFormsEntryPoint.cs b/NAPS2.Lib.WinForms/EntryPoints/WinFormsEntryPoint.cs
index a722d7424..853e1cac7 100644
--- a/NAPS2.Lib.WinForms/EntryPoints/WinFormsEntryPoint.cs
+++ b/NAPS2.Lib.WinForms/EntryPoints/WinFormsEntryPoint.cs
@@ -19,7 +19,8 @@ public static class WinFormsEntryPoint
public static void Run(string[] args)
{
// Initialize Ninject (the DI framework)
- var kernel = new StandardKernel(new CommonModule(), new WinFormsModule(), new RecoveryModule(), new ContextModule());
+ var kernel = new StandardKernel(new CommonModule(), new GdiModule(), new WinFormsModule(),
+ new RecoveryModule(), new ContextModule());
Paths.ClearTemp();
diff --git a/NAPS2.Lib.WinForms/EntryPoints/WorkerEntryPoint.cs b/NAPS2.Lib.WinForms/EntryPoints/WorkerEntryPoint.cs
index 61f883791..443f6cfb5 100644
--- a/NAPS2.Lib.WinForms/EntryPoints/WorkerEntryPoint.cs
+++ b/NAPS2.Lib.WinForms/EntryPoints/WorkerEntryPoint.cs
@@ -29,8 +29,8 @@ public static class WorkerEntryPoint
#endif
// Initialize Ninject (the DI framework)
- var kernel = new StandardKernel(new CommonModule(), new WinFormsModule(), new WorkerModule(),
- new ContextModule());
+ var kernel = new StandardKernel(new CommonModule(), new GdiModule(), new WinFormsModule(),
+ new WorkerModule(), new ContextModule());
// Expect a single argument, the parent process id
if (args.Length != 1 || !int.TryParse(args[0], out int procId) || !IsProcessRunning(procId))
diff --git a/NAPS2.Lib/ImportExport/Images/TiffHelper.cs b/NAPS2.Lib.WinForms/ImportExport/Images/TiffHelper.cs
similarity index 99%
rename from NAPS2.Lib/ImportExport/Images/TiffHelper.cs
rename to NAPS2.Lib.WinForms/ImportExport/Images/TiffHelper.cs
index 8b9616c4e..d1c1d7cfb 100644
--- a/NAPS2.Lib/ImportExport/Images/TiffHelper.cs
+++ b/NAPS2.Lib.WinForms/ImportExport/Images/TiffHelper.cs
@@ -6,7 +6,7 @@ using NAPS2.Images.Gdi;
namespace NAPS2.ImportExport.Images;
-public class TiffHelper
+public class TiffHelper : ITiffHelper
{
public bool SaveMultipage(IList images, string location, TiffCompression compression, ProgressHandler progressCallback, CancellationToken cancelToken)
{
diff --git a/NAPS2.Lib.WinForms/Modules/GdiModule.cs b/NAPS2.Lib.WinForms/Modules/GdiModule.cs
new file mode 100644
index 000000000..909a13735
--- /dev/null
+++ b/NAPS2.Lib.WinForms/Modules/GdiModule.cs
@@ -0,0 +1,15 @@
+using NAPS2.Images.Gdi;
+using NAPS2.ImportExport.Images;
+using Ninject.Modules;
+
+namespace NAPS2.Modules;
+
+public class GdiModule : NinjectModule
+{
+ public override void Load()
+ {
+ Bind().To();
+ Bind().To();
+ Bind().ToSelf();
+ }
+}
\ No newline at end of file
diff --git a/NAPS2.Lib.WinForms/Modules/WinFormsModule.cs b/NAPS2.Lib.WinForms/Modules/WinFormsModule.cs
index ef3f3a7e1..dc9f03855 100644
--- a/NAPS2.Lib.WinForms/Modules/WinFormsModule.cs
+++ b/NAPS2.Lib.WinForms/Modules/WinFormsModule.cs
@@ -1,7 +1,6 @@
using NAPS2.EtoForms;
using NAPS2.EtoForms.Ui;
using NAPS2.EtoForms.WinForms;
-using NAPS2.Images.Gdi;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
@@ -33,8 +32,6 @@ public class WinFormsModule : NinjectModule
Bind().To();
Bind().To();
Bind().ToSelf().InSingletonScope();
- Bind().To();
- Bind().ToSelf();
Bind().To();
diff --git a/NAPS2.Lib.WinForms/NAPS2.Lib.WinForms.csproj b/NAPS2.Lib.WinForms/NAPS2.Lib.WinForms.csproj
index 092daf041..506f51798 100644
--- a/NAPS2.Lib.WinForms/NAPS2.Lib.WinForms.csproj
+++ b/NAPS2.Lib.WinForms/NAPS2.Lib.WinForms.csproj
@@ -17,8 +17,8 @@
-
+
@@ -362,7 +362,6 @@
-
diff --git a/NAPS2.Lib.WinForms/Scan/Twain/Legacy/DibUtils.cs b/NAPS2.Lib.WinForms/Scan/Twain/Legacy/DibUtils.cs
index 70b4434ca..5f0ced035 100644
--- a/NAPS2.Lib.WinForms/Scan/Twain/Legacy/DibUtils.cs
+++ b/NAPS2.Lib.WinForms/Scan/Twain/Legacy/DibUtils.cs
@@ -1,5 +1,6 @@
using System.Drawing;
using System.Runtime.InteropServices;
+using NAPS2.Images.Gdi;
namespace NAPS2.Scan.Twain.Legacy;
diff --git a/NAPS2.Sdk/Util/StringWrapper.cs b/NAPS2.Lib.WinForms/Util/StringWrapper.cs
similarity index 100%
rename from NAPS2.Sdk/Util/StringWrapper.cs
rename to NAPS2.Lib.WinForms/Util/StringWrapper.cs
diff --git a/NAPS2.Lib.WinForms/WinForms/FEmailProvider.cs b/NAPS2.Lib.WinForms/WinForms/FEmailProvider.cs
index 062467b36..c75a0ad8e 100644
--- a/NAPS2.Lib.WinForms/WinForms/FEmailProvider.cs
+++ b/NAPS2.Lib.WinForms/WinForms/FEmailProvider.cs
@@ -36,10 +36,13 @@ public partial class FEmailProvider : FormBase
foreach (var clientName in _systemClientNames.OrderBy(x => x == _defaultSystemClientName ? 0 : 1))
{
+ var exePath = _systemEmailClients.GetExePath(clientName);
+ var icon = exePath == null ? null : Icon.ExtractAssociatedIcon(exePath);
+ var bitmap = icon?.ToBitmap();
_providerWidgets.Add(new EmailProviderWidget
{
ProviderType = EmailProviderType.System,
- ProviderIcon = _systemEmailClients.GetIcon(clientName) ?? Icons.mail_yellow.ToEtoImage().ToSD(),
+ ProviderIcon = bitmap ?? Icons.mail_yellow.ToEtoImage().ToSD(),
ProviderName = clientName,
ClickAction = () => ChooseSystem(clientName)
});
diff --git a/NAPS2.Lib/Images/UiThumbnailProvider.cs b/NAPS2.Lib/Images/UiThumbnailProvider.cs
index 2c3435d27..73726747f 100644
--- a/NAPS2.Lib/Images/UiThumbnailProvider.cs
+++ b/NAPS2.Lib/Images/UiThumbnailProvider.cs
@@ -1,7 +1,4 @@
-using System.Drawing;
-using System.Drawing.Imaging;
using NAPS2.EtoForms;
-using NAPS2.Images.Gdi;
namespace NAPS2.Images;
diff --git a/NAPS2.Lib/ImportExport/AutoSaver.cs b/NAPS2.Lib/ImportExport/AutoSaver.cs
index e8e9ce8bb..12a6cf951 100644
--- a/NAPS2.Lib/ImportExport/AutoSaver.cs
+++ b/NAPS2.Lib/ImportExport/AutoSaver.cs
@@ -14,12 +14,12 @@ public class AutoSaver
private readonly IPdfExporter _pdfExporter;
private readonly IOverwritePrompt _overwritePrompt;
private readonly Naps2Config _config;
- private readonly TiffHelper _tiffHelper;
+ private readonly ITiffHelper _tiffHelper;
private readonly ImageContext _imageContext;
public AutoSaver(ErrorOutput errorOutput, DialogHelper dialogHelper,
OperationProgress operationProgress, ISaveNotify notify, IPdfExporter pdfExporter,
- IOverwritePrompt overwritePrompt, Naps2Config config, TiffHelper tiffHelper, ImageContext imageContext)
+ IOverwritePrompt overwritePrompt, Naps2Config config, ITiffHelper tiffHelper, ImageContext imageContext)
{
_errorOutput = errorOutput;
_dialogHelper = dialogHelper;
diff --git a/NAPS2.Lib/ImportExport/Images/ITiffHelper.cs b/NAPS2.Lib/ImportExport/Images/ITiffHelper.cs
new file mode 100644
index 000000000..ba44ae07c
--- /dev/null
+++ b/NAPS2.Lib/ImportExport/Images/ITiffHelper.cs
@@ -0,0 +1,9 @@
+using System.Threading;
+
+namespace NAPS2.ImportExport.Images;
+
+// TODO: Merge this functionality into ImageContext or something
+public interface ITiffHelper
+{
+ bool SaveMultipage(IList images, string location, TiffCompression compression, ProgressHandler progressCallback, CancellationToken cancelToken);
+}
\ No newline at end of file
diff --git a/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs b/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs
index deead5570..85e4a98e6 100644
--- a/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs
+++ b/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs
@@ -7,9 +7,9 @@ namespace NAPS2.ImportExport.Images;
public class SaveImagesOperation : OperationBase
{
private readonly IOverwritePrompt _overwritePrompt;
- private readonly TiffHelper _tiffHelper;
+ private readonly ITiffHelper _tiffHelper;
- public SaveImagesOperation(IOverwritePrompt overwritePrompt, TiffHelper tiffHelper)
+ public SaveImagesOperation(IOverwritePrompt overwritePrompt, ITiffHelper tiffHelper)
{
_overwritePrompt = overwritePrompt;
_tiffHelper = tiffHelper;
diff --git a/NAPS2.Lib/ImportExport/Images/StubTiffHelper.cs b/NAPS2.Lib/ImportExport/Images/StubTiffHelper.cs
new file mode 100644
index 000000000..f37f77334
--- /dev/null
+++ b/NAPS2.Lib/ImportExport/Images/StubTiffHelper.cs
@@ -0,0 +1,12 @@
+using System.Threading;
+
+namespace NAPS2.ImportExport.Images;
+
+public class StubTiffHelper : ITiffHelper
+{
+ public bool SaveMultipage(IList images, string location, TiffCompression compression, ProgressHandler progressCallback,
+ CancellationToken cancelToken)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/NAPS2.Lib/Modules/ConsoleModule.cs b/NAPS2.Lib/Modules/ConsoleModule.cs
index dda51eabd..6465fda31 100644
--- a/NAPS2.Lib/Modules/ConsoleModule.cs
+++ b/NAPS2.Lib/Modules/ConsoleModule.cs
@@ -1,6 +1,4 @@
using NAPS2.Automation;
-using NAPS2.Dependencies;
-using NAPS2.Images.Gdi;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.WinForms;
@@ -30,6 +28,5 @@ public class ConsoleModule : NinjectModule
Bind().ToSelf().WithConstructorArgument("writer", Console.Out);
Bind().To();
Bind().To();
- Bind().To();
}
}
\ No newline at end of file
diff --git a/NAPS2.Sdk.Samples/NAPS2.Sdk.Samples.csproj b/NAPS2.Sdk.Samples/NAPS2.Sdk.Samples.csproj
index c97b92758..b48a84d56 100644
--- a/NAPS2.Sdk.Samples/NAPS2.Sdk.Samples.csproj
+++ b/NAPS2.Sdk.Samples/NAPS2.Sdk.Samples.csproj
@@ -8,7 +8,8 @@
-
+
+
\ No newline at end of file
diff --git a/NAPS2.Sdk.Tests/NAPS2.Sdk.Tests.csproj b/NAPS2.Sdk.Tests/NAPS2.Sdk.Tests.csproj
index ecd5130bc..bc43ffda9 100644
--- a/NAPS2.Sdk.Tests/NAPS2.Sdk.Tests.csproj
+++ b/NAPS2.Sdk.Tests/NAPS2.Sdk.Tests.csproj
@@ -19,6 +19,7 @@
+
diff --git a/NAPS2.Sdk/Images/BlankDetector.cs b/NAPS2.Sdk/Images/BlankDetector.cs
index 34d487df2..5708c3938 100644
--- a/NAPS2.Sdk/Images/BlankDetector.cs
+++ b/NAPS2.Sdk/Images/BlankDetector.cs
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
-using NAPS2.Images.Gdi;
namespace NAPS2.Images;
diff --git a/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs b/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs
index f81266284..731a2e63d 100644
--- a/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs
+++ b/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs
@@ -1,5 +1,4 @@
-using System.Drawing;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using Microsoft.Win32;
using NAPS2.Platform.Windows;
@@ -29,7 +28,7 @@ public class SystemEmailClients
}).ToArray() ?? Array.Empty();
}
- public Image? GetIcon(string clientName)
+ public string? GetExePath(string clientName)
{
using var command = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\Clients\Mail\{clientName}\shell\open\command", false);
string commandText = command?.GetValue(null)?.ToString() ?? "";
@@ -37,9 +36,8 @@ public class SystemEmailClients
{
return null;
}
- string exePath = commandText.Substring(1, commandText.IndexOf("\"", 1, StringComparison.InvariantCulture) - 1);
- var icon = Icon.ExtractAssociatedIcon(exePath);
- return icon?.ToBitmap();
+ return commandText.Substring(1, commandText.IndexOf("\"", 1, StringComparison.InvariantCulture) - 1);
+
}
internal IntPtr GetLibrary(string? clientName)
diff --git a/NAPS2.Sdk/NAPS2.Sdk.csproj b/NAPS2.Sdk/NAPS2.Sdk.csproj
index 1528d2f6b..1de8b6706 100644
--- a/NAPS2.Sdk/NAPS2.Sdk.csproj
+++ b/NAPS2.Sdk/NAPS2.Sdk.csproj
@@ -49,9 +49,6 @@
-
-
-
@@ -89,7 +86,6 @@
-
diff --git a/NAPS2.Sdk/Util/ImageExtensions.cs b/NAPS2.Sdk/Util/ImageExtensions.cs
deleted file mode 100644
index 7e17e1306..000000000
--- a/NAPS2.Sdk/Util/ImageExtensions.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Drawing;
-
-namespace NAPS2.Util;
-
-public static class ImageExtensions
-{
- public static void SafeSetResolution(this Bitmap image, float xDpi, float yDpi)
- {
- if (xDpi > 0 && yDpi > 0)
- {
- image.SetResolution(xDpi, yDpi);
- }
- }
-}
\ No newline at end of file