mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-16 18:50:45 +03:00
Remove final gdi references from NAPS2.Sdk
This commit is contained in:
parent
cecc40013f
commit
1c0a7074d2
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6;net462;netcoreapp2.1;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6;net462;netstandard2.0</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NAPS2.Images\NAPS2.Images.csproj" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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<INotificationManager>().To<StubNotificationManager>().InSingletonScope();
|
||||
Bind<ISaveNotify>().ToMethod(ctx => ctx.Kernel.Get<INotificationManager>());
|
||||
Bind<IScannedImagePrinter>().To<StubScannedImagePrinter>();
|
||||
Bind<ITiffHelper>().To<StubTiffHelper>();
|
||||
Bind<DesktopController>().ToSelf().InSingletonScope();
|
||||
Bind<IDesktopScanController>().To<DesktopScanController>();
|
||||
Bind<IUpdateChecker>().To<UpdateChecker>();
|
||||
|
@ -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<ImageContext>().ToConstant(_imageContext);
|
||||
Bind<ImageContext>().ToConstant(_imageContext);
|
||||
Bind<ITiffHelper>().To<StubTiffHelper>();
|
||||
Rebind<IScanDriverFactory>().ToConstant(_scanDriverFactory);
|
||||
Rebind<IScanBridgeFactory>().To<InProcScanBridgeFactory>();
|
||||
Rebind<ConsoleOutput>().ToSelf()
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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))
|
||||
|
@ -6,7 +6,7 @@ using NAPS2.Images.Gdi;
|
||||
|
||||
namespace NAPS2.ImportExport.Images;
|
||||
|
||||
public class TiffHelper
|
||||
public class TiffHelper : ITiffHelper
|
||||
{
|
||||
public bool SaveMultipage(IList<ProcessedImage> images, string location, TiffCompression compression, ProgressHandler progressCallback, CancellationToken cancelToken)
|
||||
{
|
15
NAPS2.Lib.WinForms/Modules/GdiModule.cs
Normal file
15
NAPS2.Lib.WinForms/Modules/GdiModule.cs
Normal file
@ -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<ITiffHelper>().To<TiffHelper>();
|
||||
Bind<ImageContext>().To<GdiImageContext>();
|
||||
Bind<GdiImageContext>().ToSelf();
|
||||
}
|
||||
}
|
@ -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<IDesktopScanController>().To<DesktopScanController>();
|
||||
Bind<IDesktopSubFormController>().To<DesktopSubFormController>();
|
||||
Bind<DesktopFormProvider>().ToSelf().InSingletonScope();
|
||||
Bind<ImageContext>().To<GdiImageContext>();
|
||||
Bind<GdiImageContext>().ToSelf();
|
||||
|
||||
Bind<DesktopForm>().To<WinFormsDesktopForm>();
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
<Import Project="..\NAPS2.Setup\LibUsers.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NTwain" Version="3.7.1" />
|
||||
<ProjectReference Include="..\NAPS2.Lib\NAPS2.Lib.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
|
||||
<PackageReference Include="Eto.Forms" Version="2.7.1" />
|
||||
<PackageReference Include="Eto.Platform.Windows" Version="2.7.1" />
|
||||
</ItemGroup>
|
||||
@ -362,7 +362,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ImportExport\Images" />
|
||||
<Folder Include="Scan\Internal" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAPS2.Images.Gdi;
|
||||
|
||||
namespace NAPS2.Scan.Twain.Legacy;
|
||||
|
||||
|
@ -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)
|
||||
});
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using NAPS2.EtoForms;
|
||||
using NAPS2.Images.Gdi;
|
||||
|
||||
namespace NAPS2.Images;
|
||||
|
||||
|
@ -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;
|
||||
|
9
NAPS2.Lib/ImportExport/Images/ITiffHelper.cs
Normal file
9
NAPS2.Lib/ImportExport/Images/ITiffHelper.cs
Normal file
@ -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<ProcessedImage> images, string location, TiffCompression compression, ProgressHandler progressCallback, CancellationToken cancelToken);
|
||||
}
|
@ -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;
|
||||
|
12
NAPS2.Lib/ImportExport/Images/StubTiffHelper.cs
Normal file
12
NAPS2.Lib/ImportExport/Images/StubTiffHelper.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace NAPS2.ImportExport.Images;
|
||||
|
||||
public class StubTiffHelper : ITiffHelper
|
||||
{
|
||||
public bool SaveMultipage(IList<ProcessedImage> images, string location, TiffCompression compression, ProgressHandler progressCallback,
|
||||
CancellationToken cancelToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -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<ConsoleOutput>().ToSelf().WithConstructorArgument("writer", Console.Out);
|
||||
Bind<ISaveNotify>().To<SaveNotifyStub>();
|
||||
Bind<IDevicePrompt>().To<ConsoleDevicePrompt>();
|
||||
Bind<ImageContext>().To<GdiImageContext>();
|
||||
}
|
||||
}
|
@ -8,7 +8,8 @@
|
||||
<Import Project="..\NAPS2.Setup\SdkUsers.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NAPS2.Sdk\NAPS2.Sdk.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Sdk\NAPS2.Sdk.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -19,6 +19,7 @@
|
||||
</Reference>
|
||||
|
||||
<ProjectReference Include="..\NAPS2.Sdk\NAPS2.Sdk.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Mac\NAPS2.Images.Mac.csproj" Condition="$(TargetFramework) == 'net6'" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Gtk\NAPS2.Images.Gtk.csproj" Condition="$(TargetFramework) == 'net6'" />
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using NAPS2.Images.Gdi;
|
||||
|
||||
namespace NAPS2.Images;
|
||||
|
||||
|
@ -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<string>();
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -49,9 +49,6 @@
|
||||
<!-- TODO: Does this actually work if we build a net6 framework-dependent app and try to use Twain? -->
|
||||
<PackageReference Include="NTwain" Version="3.7.1" NoWarn="NU1701" Condition="'$(TargetFramework)' == 'net462'" />
|
||||
<PackageReference Include="Nullable" Version="1.2.0" />
|
||||
<!-- We're deliberately using an older version of System.Drawing.Common to include cross-platform support. -->
|
||||
<!-- TODO: Eventually we will get rid of this dependency on non-windows and will be able to upgrade. -->
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
|
||||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="6.0.0" />
|
||||
@ -89,7 +86,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NAPS2.Escl.Client\NAPS2.Escl.Client.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Escl.Server\NAPS2.Escl.Server.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images.Gdi\NAPS2.Images.Gdi.csproj" />
|
||||
<ProjectReference Include="..\NAPS2.Images\NAPS2.Images.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user