Refactor classes into eto namespaces

This commit is contained in:
Ben Olden-Cooligan 2022-10-10 18:44:13 -07:00
parent c1f946df5f
commit c50c3381ec
69 changed files with 220 additions and 170 deletions

View File

@ -1,8 +1,8 @@
using Eto;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Ui;
using NAPS2.Modules;
using NAPS2.WinForms;
using Ninject;
using UnhandledExceptionEventArgs = Eto.UnhandledExceptionEventArgs;

View File

@ -3,9 +3,9 @@ using Eto.GtkSharp;
using Eto.GtkSharp.Forms.ToolBar;
using Gdk;
using Gtk;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.Gtk;
using NAPS2.ImportExport.Images;
using NAPS2.WinForms;
using Command = Eto.Forms.Command;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,4 +1,5 @@
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.Gtk;
using NAPS2.EtoForms.Ui;
using NAPS2.Images.Gtk;
@ -6,7 +7,6 @@ using NAPS2.ImportExport;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.Update;
using NAPS2.WinForms;
using Ninject;
using Ninject.Modules;
@ -19,9 +19,9 @@ public class GtkModule : NinjectModule
// Bind<IBatchScanPerformer>().To<BatchScanPerformer>();
Bind<IPdfPasswordProvider>().To<StubPdfPasswordProvider>();
Bind<ErrorOutput>().To<MessageBoxErrorOutput>();
Bind<IOverwritePrompt>().To<WinFormsOverwritePrompt>();
Bind<IOverwritePrompt>().To<EtoOverwritePrompt>();
Bind<OperationProgress>().To<EtoOperationProgress>().InSingletonScope();
Bind<DialogHelper>().To<WinFormsDialogHelper>();
Bind<DialogHelper>().To<EtoDialogHelper>();
Bind<IDevicePrompt>().To<EtoDevicePrompt>();
Bind<INotificationManager>().To<StubNotificationManager>().InSingletonScope();
Bind<ISaveNotify>().ToMethod(ctx => ctx.Kernel.Get<INotificationManager>());
@ -29,7 +29,7 @@ public class GtkModule : NinjectModule
Bind<DesktopController>().ToSelf().InSingletonScope();
Bind<IDesktopScanController>().To<DesktopScanController>();
Bind<IUpdateChecker>().To<UpdateChecker>();
Bind<IWinFormsExportHelper>().To<WinFormsExportHelper>();
Bind<IExportController>().To<ExportController>();
Bind<IDesktopSubFormController>().To<StubDesktopSubFormController>();
Bind<DesktopFormProvider>().ToSelf().InSingletonScope();
Bind<ImageContext>().To<GtkImageContext>();

View File

@ -1,8 +1,8 @@
using Eto;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Ui;
using NAPS2.Modules;
using NAPS2.WinForms;
using Ninject;
using UnhandledExceptionEventArgs = Eto.UnhandledExceptionEventArgs;

View File

@ -2,9 +2,9 @@ using System.Threading;
using Eto.Drawing;
using Eto.Forms;
using Eto.Mac;
using NAPS2.EtoForms.Desktop;
using NAPS2.ImportExport.Images;
using NAPS2.Scan;
using NAPS2.WinForms;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,4 +1,5 @@
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.Mac;
using NAPS2.EtoForms.Ui;
using NAPS2.Images.Mac;
@ -6,7 +7,6 @@ using NAPS2.ImportExport;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.Update;
using NAPS2.WinForms;
using Ninject;
using Ninject.Modules;
@ -19,9 +19,9 @@ public class MacModule : NinjectModule
// Bind<IBatchScanPerformer>().To<BatchScanPerformer>();
Bind<IPdfPasswordProvider>().To<StubPdfPasswordProvider>();
Bind<ErrorOutput>().To<MessageBoxErrorOutput>();
Bind<IOverwritePrompt>().To<WinFormsOverwritePrompt>();
Bind<IOverwritePrompt>().To<EtoOverwritePrompt>();
Bind<OperationProgress>().To<EtoOperationProgress>().InSingletonScope();
Bind<DialogHelper>().To<WinFormsDialogHelper>();
Bind<DialogHelper>().To<EtoDialogHelper>();
Bind<IDevicePrompt>().To<EtoDevicePrompt>();
Bind<INotificationManager>().To<StubNotificationManager>().InSingletonScope();
Bind<ISaveNotify>().ToMethod(ctx => ctx.Kernel.Get<INotificationManager>());
@ -29,7 +29,7 @@ public class MacModule : NinjectModule
Bind<DesktopController>().ToSelf().InSingletonScope();
Bind<IDesktopScanController>().To<DesktopScanController>();
Bind<IUpdateChecker>().To<UpdateChecker>();
Bind<IWinFormsExportHelper>().To<WinFormsExportHelper>();
Bind<IExportController>().To<ExportController>();
Bind<IDesktopSubFormController>().To<StubDesktopSubFormController>();
Bind<DesktopFormProvider>().ToSelf().InSingletonScope();
Bind<ImageContext>().To<MacImageContext>();

View File

@ -1,10 +1,10 @@
using Moq;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.Sdk.Tests;
using NAPS2.Sdk.Tests.Asserts;
using NAPS2.WinForms;
using Xunit;
namespace NAPS2.Lib.Tests.Scan;

View File

@ -1,4 +1,6 @@
using Moq;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Images;
using NAPS2.Platform.Windows;
@ -6,7 +8,6 @@ using NAPS2.Recovery;
using NAPS2.Sdk.Tests;
using NAPS2.Sdk.Tests.Asserts;
using NAPS2.Update;
using NAPS2.WinForms;
using Xunit;
namespace NAPS2.Lib.Tests.WinForms;
@ -28,7 +29,7 @@ public class DesktopControllerTests : ContextualTests
private readonly Mock<INotificationManager> _notifcationManager;
private readonly ImageTransfer _imageTransfer;
private readonly ImageClipboard _imageClipboard;
private readonly Mock<IWinFormsExportHelper> _exportHelper;
private readonly Mock<IExportController> _exportHelper;
private readonly Mock<DialogHelper> _dialogHelper;
private readonly DesktopImagesController _desktopImagesController;
private readonly Mock<IDesktopScanController> _desktopScanController;
@ -51,7 +52,7 @@ public class DesktopControllerTests : ContextualTests
_notifcationManager = new Mock<INotificationManager>();
_imageTransfer = new ImageTransfer();
_imageClipboard = new ImageClipboard();
_exportHelper = new Mock<IWinFormsExportHelper>();
_exportHelper = new Mock<IExportController>();
_dialogHelper = new Mock<DialogHelper>();
_desktopImagesController = new DesktopImagesController(_imageList);
_desktopScanController = new Mock<IDesktopScanController>();

View File

@ -1,4 +1,5 @@
using Moq;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.Scan;
using NAPS2.Scan.Batch;

View File

@ -1,5 +1,6 @@
using System.Threading;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Ui;
using NAPS2.EtoForms.WinForms;
using NAPS2.Modules;

View File

@ -1,7 +1,9 @@
using NAPS2.EtoForms.Ui;
using NAPS2.Images;
using NAPS2.Ocr;
using NAPS2.WinForms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public class DesktopSubFormController : IDesktopSubFormController
{

View File

@ -2,6 +2,7 @@ using System.Drawing;
using Eto.Forms;
using Eto.WinForms;
using Eto.WinForms.Forms.ToolBar;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.WinForms;
using NAPS2.ImportExport.Images;
using NAPS2.WinForms;

View File

@ -1,4 +1,5 @@
using System.Windows.Forms;
using NAPS2.EtoForms;
using NAPS2.WinForms;
namespace NAPS2.ImportExport.Pdf;

View File

@ -1,4 +1,5 @@
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.Ui;
using NAPS2.EtoForms.WinForms;
using NAPS2.ImportExport;
@ -19,16 +20,16 @@ public class WinFormsModule : NinjectModule
Bind<IBatchScanPerformer>().To<BatchScanPerformer>();
Bind<IPdfPasswordProvider>().To<WinFormsPdfPasswordProvider>();
Bind<ErrorOutput>().To<MessageBoxErrorOutput>();
Bind<IOverwritePrompt>().To<WinFormsOverwritePrompt>();
Bind<IOverwritePrompt>().To<EtoOverwritePrompt>();
Bind<OperationProgress>().To<EtoOperationProgress>().InSingletonScope();
Bind<DialogHelper>().To<WinFormsDialogHelper>();
Bind<DialogHelper>().To<EtoDialogHelper>();
Bind<IDevicePrompt>().To<EtoDevicePrompt>();
Bind<INotificationManager>().To<NotificationManager>().InSingletonScope();
Bind<ISaveNotify>().ToMethod(ctx => ctx.Kernel.Get<INotificationManager>());
Bind<IScannedImagePrinter>().To<PrintDocumentPrinter>();
Bind<DesktopController>().ToSelf().InSingletonScope();
Bind<IUpdateChecker>().To<UpdateChecker>();
Bind<IWinFormsExportHelper>().To<WinFormsExportHelper>();
Bind<IExportController>().To<ExportController>();
Bind<IDesktopScanController>().To<DesktopScanController>();
Bind<IDesktopSubFormController>().To<DesktopSubFormController>();
Bind<DesktopFormProvider>().ToSelf().InSingletonScope();

View File

@ -1,4 +1,5 @@
using System.Windows.Forms;
using NAPS2.EtoForms;
using NAPS2.WinForms;
namespace NAPS2.Recovery;

View File

@ -1,9 +1,13 @@
using System.Threading;
using System.Windows.Forms;
using NAPS2.Config;
using NAPS2.EtoForms;
using NAPS2.Images;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Images;
using NAPS2.ImportExport.Pdf;
using NAPS2.Ocr;
using NAPS2.Operation;
using NAPS2.Platform.Windows;
using NAPS2.WinForms;

View File

@ -1,4 +1,5 @@
using System.Windows.Forms;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.Scan;

View File

@ -2,6 +2,7 @@ using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using NAPS2.Config.Model;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.Scan;
using NAPS2.Scan.Batch;

View File

@ -2,6 +2,7 @@ using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.EtoForms.WinForms;
using NAPS2.ImportExport;
using NAPS2.Ocr;

View File

@ -1,6 +1,7 @@
using System.Globalization;
using System.Windows.Forms;
using NAPS2.Config.Model;
using NAPS2.EtoForms;
using NAPS2.ImportExport.Images;
namespace NAPS2.WinForms;

View File

@ -1,5 +1,6 @@
using System.Windows.Forms;
using NAPS2.Config.Model;
using NAPS2.EtoForms;
using NAPS2.ImportExport.Pdf;
namespace NAPS2.WinForms;

View File

@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows.Forms;
using NAPS2.EtoForms;
using NAPS2.Images.Gdi;
using MessageBoxIcon = System.Windows.Forms.MessageBoxIcon;
@ -31,7 +32,7 @@ public class FViewer : FormBase
private ToolStripSeparator _toolStripSeparator2;
private ToolStripButton _tsSaveImage;
private readonly IOperationFactory _operationFactory;
private readonly IWinFormsExportHelper _exportHelper;
private readonly IExportController _exportController;
private ToolStripButton _tsHueSaturation;
private ToolStripButton _tsBlackWhite;
private ToolStripButton _tsSharpen;
@ -43,12 +44,12 @@ public class FViewer : FormBase
private UiImage? _currentImage;
public FViewer(IOperationFactory operationFactory, IWinFormsExportHelper exportHelper,
public FViewer(IOperationFactory operationFactory, IExportController exportController,
KeyboardShortcutManager ksm, OperationProgress operationProgress,
UiImageList imageList, INotificationManager notificationManager, ThumbnailController thumbnailController)
{
_operationFactory = operationFactory;
_exportHelper = exportHelper;
_exportController = exportController;
_ksm = ksm;
_operationProgress = operationProgress;
_imageList = imageList;
@ -543,7 +544,7 @@ public class FViewer : FormBase
private async void tsSavePDF_Click(object sender, EventArgs e)
{
using var imageToSave = CurrentImage.GetClonedImage();
if (await _exportHelper.SavePDF(new List<ProcessedImage> { imageToSave }, _notificationManager))
if (await _exportController.SavePDF(new List<ProcessedImage> { imageToSave }, _notificationManager))
{
if (Config.Get(c => c.DeleteAfterSaving))
{
@ -555,7 +556,7 @@ public class FViewer : FormBase
private async void tsSaveImage_Click(object sender, EventArgs e)
{
using var imageToSave = CurrentImage.GetClonedImage();
if (await _exportHelper.SaveImages(new List<ProcessedImage> { imageToSave }, _notificationManager))
if (await _exportController.SaveImages(new List<ProcessedImage> { imageToSave }, _notificationManager))
{
if (Config.Get(c => c.DeleteAfterSaving))
{

View File

@ -1,5 +1,7 @@
using System.Drawing;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.EtoForms.Desktop;
using NAPS2.Update;
using wf = System.Windows.Forms;

View File

@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Windows.Forms;
using NAPS2.EtoForms;
namespace NAPS2.WinForms;

View File

@ -1,4 +1,5 @@
using System.Threading;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Email;
using NAPS2.ImportExport.Images;
@ -8,7 +9,6 @@ using NAPS2.Ocr;
using NAPS2.Recovery;
using NAPS2.Scan;
using NAPS2.Serialization;
using NAPS2.WinForms;
namespace NAPS2.Automation;

View File

@ -1,4 +1,4 @@
using NAPS2.WinForms;
using NAPS2.EtoForms;
namespace NAPS2.Automation;

View File

@ -1,6 +1,5 @@
using System.Threading;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Images;
using NAPS2.Platform.Windows;
@ -9,7 +8,7 @@ using NAPS2.Remoting;
using NAPS2.Scan;
using NAPS2.Update;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
// TODO: We undoubtedly want to decompose this file even further.
// We almost certainly want a DesktopScanController for the scanning-related logic.
@ -32,7 +31,7 @@ public class DesktopController
private readonly ImageTransfer _imageTransfer;
private readonly ImageClipboard _imageClipboard;
private readonly ImageListActions _imageListActions;
private readonly IWinFormsExportHelper _exportHelper;
private readonly IExportController _exportController;
private readonly DialogHelper _dialogHelper;
private readonly DesktopImagesController _desktopImagesController;
private readonly IDesktopScanController _desktopScanController;
@ -46,7 +45,7 @@ public class DesktopController
OperationProgress operationProgress, Naps2Config config, IOperationFactory operationFactory,
StillImage stillImage,
IUpdateChecker updateChecker, INotificationManager notify, ImageTransfer imageTransfer,
ImageClipboard imageClipboard, ImageListActions imageListActions, IWinFormsExportHelper exportHelper,
ImageClipboard imageClipboard, ImageListActions imageListActions, IExportController exportController,
DialogHelper dialogHelper,
DesktopImagesController desktopImagesController, IDesktopScanController desktopScanController,
DesktopFormProvider desktopFormProvider, IScannedImagePrinter scannedImagePrinter)
@ -64,7 +63,7 @@ public class DesktopController
_imageTransfer = imageTransfer;
_imageClipboard = imageClipboard;
_imageListActions = imageListActions;
_exportHelper = exportHelper;
_exportController = exportController;
_dialogHelper = dialogHelper;
_desktopImagesController = desktopImagesController;
_desktopScanController = desktopScanController;
@ -453,7 +452,7 @@ public class DesktopController
public async Task SavePDF(ICollection<UiImage> images)
{
using var imagesToSave = images.Select(x => x.GetClonedImage()).ToDisposableList();
if (await _exportHelper.SavePDF(imagesToSave.InnerList, _notify))
if (await _exportController.SavePDF(imagesToSave.InnerList, _notify))
{
if (_config.Get(c => c.DeleteAfterSaving))
{
@ -465,7 +464,7 @@ public class DesktopController
public async Task SaveImages(ICollection<UiImage> images)
{
using var imagesToSave = images.Select(x => x.GetClonedImage()).ToDisposableList();
if (await _exportHelper.SaveImages(imagesToSave.InnerList, _notify))
if (await _exportController.SaveImages(imagesToSave.InnerList, _notify))
{
if (_config.Get(c => c.DeleteAfterSaving))
{
@ -477,7 +476,7 @@ public class DesktopController
public async Task EmailPDF(ICollection<UiImage> images)
{
using var imagesToEmail = images.Select(x => x.GetClonedImage()).ToDisposableList();
await _exportHelper.EmailPDF(imagesToEmail.InnerList);
await _exportController.EmailPDF(imagesToEmail.InnerList);
}
public async Task Print()

View File

@ -1,6 +1,4 @@
using NAPS2.EtoForms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public class DesktopFormProvider
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public class DesktopImagesController
{

View File

@ -4,7 +4,7 @@ using NAPS2.Scan;
using NAPS2.Wia;
#endif
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public class DesktopScanController : IDesktopScanController
{

View File

@ -1,6 +1,6 @@
using NAPS2.Scan;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public interface IDesktopScanController
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms.Desktop;
public interface IDesktopSubFormController
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public abstract class DialogHelper
{

View File

@ -1,6 +1,5 @@
using NAPS2.EtoForms.Ui;
using NAPS2.Scan;
using NAPS2.WinForms;
namespace NAPS2.EtoForms;

View File

@ -1,5 +1,4 @@
using Eto.Forms;
using NAPS2.WinForms;
namespace NAPS2.EtoForms;

View File

@ -1,14 +1,13 @@
using Eto.Forms;
using NAPS2.EtoForms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class WinFormsDialogHelper : DialogHelper
public class EtoDialogHelper : DialogHelper
{
private readonly Naps2Config _config;
private readonly FileFilters _fileFilters;
public WinFormsDialogHelper(Naps2Config config, FileFilters fileFilters)
public EtoDialogHelper(Naps2Config config, FileFilters fileFilters)
{
_config = config;
_fileFilters = fileFilters;

View File

@ -5,27 +5,6 @@ namespace NAPS2.EtoForms;
public static class EtoExtensions
{
public static DynamicRow AddSeparateRow(this DynamicLayout layout, params ControlWithLayoutAttributes[] controls)
{
layout.BeginVertical();
var row = layout.BeginHorizontal();
layout.AddAll(controls);
layout.EndHorizontal();
layout.EndVertical();
return row;
}
public static void AddAll(this DynamicLayout layout, params ControlWithLayoutAttributes[] controls)
{
foreach (var control in controls)
{
layout.Add(control);
}
}
public static void Add(this DynamicLayout layout, ControlWithLayoutAttributes control) =>
control.AddTo(layout);
public static Icon ToEtoIcon(this byte[] bytes) => new(new MemoryStream(bytes));
public static Bitmap ToEtoImage(this byte[] bytes) => new(bytes);
@ -52,70 +31,6 @@ public static class EtoExtensions
};
}
public static ControlWithLayoutAttributes Width(this Control control, int width) =>
new ControlWithLayoutAttributes(control, width: width);
public static ControlWithLayoutAttributes Height(this Control control, int height) =>
new ControlWithLayoutAttributes(control, height: height);
public static ControlWithLayoutAttributes Size(this Control control, int width, int height) =>
new ControlWithLayoutAttributes(control, width: width, height: height);
public static ControlWithLayoutAttributes Center(this Control control) =>
new ControlWithLayoutAttributes(control, center: true);
public static ControlWithLayoutAttributes XScale(this Control control) =>
new ControlWithLayoutAttributes(control, xScale: true);
public static ControlWithLayoutAttributes YScale(this Control control) =>
new ControlWithLayoutAttributes(control, yScale: true);
public static ControlWithLayoutAttributes AutoSize(this Control control) =>
new ControlWithLayoutAttributes(control, autoSize: true);
public static ControlWithLayoutAttributes Padding(this Control control, Padding padding) =>
new ControlWithLayoutAttributes(control, padding: padding);
public static ControlWithLayoutAttributes Padding(this Control control, int all) =>
new ControlWithLayoutAttributes(control, padding: new Padding(all));
public static ControlWithLayoutAttributes Padding(this Control control, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new ControlWithLayoutAttributes(control, padding: new Padding(left, top, right, bottom));
public static ControlWithLayoutAttributes Spacing(this Control control, Size spacing) =>
new ControlWithLayoutAttributes(control, spacing: spacing);
public static ControlWithLayoutAttributes Width(this ControlWithLayoutAttributes control, int width) =>
new ControlWithLayoutAttributes(control, width: width);
public static ControlWithLayoutAttributes Height(this ControlWithLayoutAttributes control, int height) =>
new ControlWithLayoutAttributes(control, height: height);
public static ControlWithLayoutAttributes Center(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, center: true);
public static ControlWithLayoutAttributes XScale(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, xScale: true);
public static ControlWithLayoutAttributes YScale(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, yScale: true);
public static ControlWithLayoutAttributes AutoSize(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, autoSize: true);
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, Padding padding) =>
new ControlWithLayoutAttributes(control, padding: padding);
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, int all) =>
new ControlWithLayoutAttributes(control, padding: new Padding(all));
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new ControlWithLayoutAttributes(control, padding: new Padding(left, top, right, bottom));
public static ControlWithLayoutAttributes Spacing(this ControlWithLayoutAttributes control, Size spacing) =>
new ControlWithLayoutAttributes(control, spacing: spacing);
public static LayoutColumn Padding(this LayoutColumn column, Padding padding) =>
new LayoutColumn(column, padding: padding);
public static LayoutColumn Padding(this LayoutColumn column, int all) =>
new LayoutColumn(column, padding: new Padding(all));
public static LayoutColumn Padding(this LayoutColumn column, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new LayoutColumn(column, padding: new Padding(left, top, right, bottom));
public static LayoutColumn Spacing(this LayoutColumn column, Size spacing) =>
new LayoutColumn(column, spacing: spacing);
public static LayoutColumn Spacing(this LayoutColumn column, int xSpacing, int ySpacing) =>
new LayoutColumn(column, spacing: new Size(xSpacing, ySpacing));
public static LayoutColumn XScale(this LayoutColumn column) =>
new LayoutColumn(column, xScale: true);
public static LayoutColumn YScale(this LayoutColumn column) =>
new LayoutColumn(column, yScale: true);
public static LayoutRow YScale(this LayoutRow row) =>
new LayoutRow(row, yScale: true);
public static LayoutRow Aligned(this LayoutRow row) =>
new LayoutRow(row, aligned: true);
public static void AddItems(this ContextMenu contextMenu, params MenuItem[] menuItems)
{
contextMenu.Items.AddRange(menuItems);

View File

@ -1,5 +1,4 @@
using Eto.Forms;
using NAPS2.WinForms;
namespace NAPS2.EtoForms;

View File

@ -1,6 +1,5 @@
using Eto.Forms;
using NAPS2.EtoForms.Ui;
using NAPS2.WinForms;
namespace NAPS2.EtoForms;

View File

@ -1,8 +1,8 @@
using Eto.Forms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class WinFormsOverwritePrompt : IOverwritePrompt
public class EtoOverwritePrompt : IOverwritePrompt
{
public OverwriteResponse ConfirmOverwrite(string path)
{

View File

@ -3,10 +3,9 @@ using NAPS2.ImportExport.Email;
using NAPS2.ImportExport.Images;
using NAPS2.ImportExport.Pdf;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
// TODO: Rename this ImageExportController or something
public class WinFormsExportHelper : IWinFormsExportHelper
public class ExportController : IExportController
{
private readonly DialogHelper _dialogHelper;
private readonly IOperationFactory _operationFactory;
@ -15,7 +14,7 @@ public class WinFormsExportHelper : IWinFormsExportHelper
private readonly Naps2Config _config;
private readonly UiImageList _uiImageList;
public WinFormsExportHelper(DialogHelper dialogHelper, IOperationFactory operationFactory, IFormFactory formFactory, OperationProgress operationProgress, Naps2Config config, UiImageList uiImageList)
public ExportController(DialogHelper dialogHelper, IOperationFactory operationFactory, IFormFactory formFactory, OperationProgress operationProgress, Naps2Config config, UiImageList uiImageList)
{
_dialogHelper = dialogHelper;
_operationFactory = operationFactory;

View File

@ -1,8 +1,8 @@
using NAPS2.ImportExport.Email;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public interface IWinFormsExportHelper
public interface IExportController
{
Task<bool> SavePDF(IList<ProcessedImage> images, ISaveNotify notify);
Task<bool> ExportPDF(string filename, IList<ProcessedImage> images, bool email, EmailMessage emailMessage);

View File

@ -1,5 +1,3 @@
using NAPS2.WinForms;
namespace NAPS2.EtoForms;
public interface IFormBase

View File

@ -1,6 +1,4 @@
using NAPS2.EtoForms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public interface IFormFactory
{

View File

@ -1,6 +1,6 @@
using NAPS2.Update;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public interface INotificationManager : ISaveNotify
{

View File

@ -1,9 +1,8 @@
using System.Text;
using Eto.Forms;
using NAPS2.EtoForms;
using NAPS2.ImportExport.Images;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class ImageClipboard
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class ImageListActions
{

View File

@ -3,7 +3,7 @@ using Eto.Drawing;
using Eto.Forms;
using NAPS2.Scan;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public static class C
{

View File

@ -1,7 +1,7 @@
using Eto.Drawing;
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public class ControlWithLayoutAttributes : LayoutElement
{

View File

@ -0,0 +1,123 @@
using Eto.Drawing;
using Eto.Forms;
namespace NAPS2.EtoForms.Layout;
public static class EtoLayoutExtensions
{
public static DynamicRow AddSeparateRow(this DynamicLayout layout, params ControlWithLayoutAttributes[] controls)
{
layout.BeginVertical();
var row = layout.BeginHorizontal();
layout.AddAll(controls);
layout.EndHorizontal();
layout.EndVertical();
return row;
}
public static void AddAll(this DynamicLayout layout, params ControlWithLayoutAttributes[] controls)
{
foreach (var control in controls)
{
layout.Add(control);
}
}
public static void Add(this DynamicLayout layout, ControlWithLayoutAttributes control) =>
control.AddTo(layout);
public static Icon ToEtoIcon(this byte[] bytes) => new(new MemoryStream(bytes));
public static Bitmap ToEtoImage(this byte[] bytes) => new(bytes);
public static Bitmap ToEtoImage(this IMemoryImage image) => EtoPlatform.Current.ToBitmap(image);
public static MessageBoxType ToEto(this MessageBoxIcon icon)
{
return icon switch
{
MessageBoxIcon.Information => MessageBoxType.Information,
MessageBoxIcon.Warning => MessageBoxType.Warning,
_ => MessageBoxType.Information // TODO: Default type with no icon?
};
}
public static DockPosition ToEto(this DockStyle dock)
{
return dock switch
{
DockStyle.Bottom => DockPosition.Bottom,
DockStyle.Left => DockPosition.Left,
DockStyle.Right => DockPosition.Right,
_ => DockPosition.Top
};
}
public static ControlWithLayoutAttributes Width(this Control control, int width) =>
new ControlWithLayoutAttributes(control, width: width);
public static ControlWithLayoutAttributes Height(this Control control, int height) =>
new ControlWithLayoutAttributes(control, height: height);
public static ControlWithLayoutAttributes Size(this Control control, int width, int height) =>
new ControlWithLayoutAttributes(control, width: width, height: height);
public static ControlWithLayoutAttributes Center(this Control control) =>
new ControlWithLayoutAttributes(control, center: true);
public static ControlWithLayoutAttributes XScale(this Control control) =>
new ControlWithLayoutAttributes(control, xScale: true);
public static ControlWithLayoutAttributes YScale(this Control control) =>
new ControlWithLayoutAttributes(control, yScale: true);
public static ControlWithLayoutAttributes AutoSize(this Control control) =>
new ControlWithLayoutAttributes(control, autoSize: true);
public static ControlWithLayoutAttributes Padding(this Control control, Padding padding) =>
new ControlWithLayoutAttributes(control, padding: padding);
public static ControlWithLayoutAttributes Padding(this Control control, int all) =>
new ControlWithLayoutAttributes(control, padding: new Padding(all));
public static ControlWithLayoutAttributes Padding(this Control control, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new ControlWithLayoutAttributes(control, padding: new Padding(left, top, right, bottom));
public static ControlWithLayoutAttributes Spacing(this Control control, Size spacing) =>
new ControlWithLayoutAttributes(control, spacing: spacing);
public static ControlWithLayoutAttributes Width(this ControlWithLayoutAttributes control, int width) =>
new ControlWithLayoutAttributes(control, width: width);
public static ControlWithLayoutAttributes Height(this ControlWithLayoutAttributes control, int height) =>
new ControlWithLayoutAttributes(control, height: height);
public static ControlWithLayoutAttributes Center(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, center: true);
public static ControlWithLayoutAttributes XScale(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, xScale: true);
public static ControlWithLayoutAttributes YScale(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, yScale: true);
public static ControlWithLayoutAttributes AutoSize(this ControlWithLayoutAttributes control) =>
new ControlWithLayoutAttributes(control, autoSize: true);
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, Padding padding) =>
new ControlWithLayoutAttributes(control, padding: padding);
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, int all) =>
new ControlWithLayoutAttributes(control, padding: new Padding(all));
public static ControlWithLayoutAttributes Padding(this ControlWithLayoutAttributes control, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new ControlWithLayoutAttributes(control, padding: new Padding(left, top, right, bottom));
public static ControlWithLayoutAttributes Spacing(this ControlWithLayoutAttributes control, Size spacing) =>
new ControlWithLayoutAttributes(control, spacing: spacing);
public static LayoutColumn Padding(this LayoutColumn column, Padding padding) =>
new LayoutColumn(column, padding: padding);
public static LayoutColumn Padding(this LayoutColumn column, int all) =>
new LayoutColumn(column, padding: new Padding(all));
public static LayoutColumn Padding(this LayoutColumn column, int left = 0, int top = 0, int right = 0, int bottom = 0) =>
new LayoutColumn(column, padding: new Padding(left, top, right, bottom));
public static LayoutColumn Spacing(this LayoutColumn column, Size spacing) =>
new LayoutColumn(column, spacing: spacing);
public static LayoutColumn Spacing(this LayoutColumn column, int xSpacing, int ySpacing) =>
new LayoutColumn(column, spacing: new Size(xSpacing, ySpacing));
public static LayoutColumn XScale(this LayoutColumn column) =>
new LayoutColumn(column, xScale: true);
public static LayoutColumn YScale(this LayoutColumn column) =>
new LayoutColumn(column, yScale: true);
public static LayoutRow YScale(this LayoutRow row) =>
new LayoutRow(row, yScale: true);
public static LayoutRow Aligned(this LayoutRow row) =>
new LayoutRow(row, aligned: true);
public static void AddItems(this ContextMenu contextMenu, params MenuItem[] menuItems)
{
contextMenu.Items.AddRange(menuItems);
}
}

View File

@ -1,7 +1,7 @@
using Eto.Drawing;
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public static class L
{

View File

@ -1,7 +1,7 @@
using Eto.Drawing;
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public class LayoutColumn : LayoutElement
{

View File

@ -1,6 +1,6 @@
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public abstract class LayoutElement
{

View File

@ -1,7 +1,7 @@
using Eto.Drawing;
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public class LayoutRoot : LayoutElement
{

View File

@ -1,6 +1,6 @@
using Eto.Forms;
namespace NAPS2.EtoForms;
namespace NAPS2.EtoForms.Layout;
public class LayoutRow : LayoutElement
{

View File

@ -1,6 +1,6 @@
using Eto.Forms;
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class MessageBoxErrorOutput : ErrorOutput
{

View File

@ -1,4 +1,4 @@
namespace NAPS2.WinForms;
namespace NAPS2.EtoForms;
public class StubDialogHelper : DialogHelper
{

View File

@ -1,5 +1,6 @@
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
using NAPS2.Update;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,5 +1,5 @@
using Eto.Forms;
using NAPS2.WinForms;
using NAPS2.EtoForms.Desktop;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,9 +1,9 @@
using System.Collections.Immutable;
using System.Threading;
using Eto.Forms;
using NAPS2.EtoForms.Desktop;
using NAPS2.ImportExport.Images;
using NAPS2.Scan;
using NAPS2.WinForms;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,5 +1,6 @@
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
using NAPS2.Scan;
using NAPS2.Scan.Exceptions;
using NAPS2.Scan.Internal;

View File

@ -1,5 +1,6 @@
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
using NAPS2.ImportExport.Profiles;
using NAPS2.Scan;
using NAPS2.Serialization;

View File

@ -1,6 +1,7 @@
using System.ComponentModel;
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,5 +1,6 @@
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
using NAPS2.Scan;
namespace NAPS2.EtoForms.Ui;

View File

@ -1,7 +1,7 @@
using NAPS2.EtoForms;
using NAPS2.ImportExport.Images;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.WinForms;
namespace NAPS2.ImportExport;

View File

@ -1,4 +1,5 @@
using NAPS2.ImportExport;
using NAPS2.EtoForms;
using NAPS2.ImportExport;
using NAPS2.ImportExport.Email;
using NAPS2.ImportExport.Email.Mapi;
using NAPS2.ImportExport.Images;
@ -10,7 +11,6 @@ using NAPS2.Remoting.Worker;
using NAPS2.Scan;
using NAPS2.Scan.Internal;
using NAPS2.Unmanaged;
using NAPS2.WinForms;
using Ninject;
using Ninject.Modules;
using ILogger = NAPS2.Logging.ILogger;

View File

@ -1,7 +1,7 @@
using NAPS2.Automation;
using NAPS2.EtoForms;
using NAPS2.ImportExport.Pdf;
using NAPS2.Scan;
using NAPS2.WinForms;
using Ninject.Modules;
namespace NAPS2.Modules;

View File

@ -1,5 +1,4 @@
using NAPS2.EtoForms;
using NAPS2.WinForms;
using Ninject;
namespace NAPS2;

View File

@ -4,7 +4,7 @@ using System.Net;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using NAPS2.WinForms;
using NAPS2.EtoForms.Desktop;
namespace NAPS2.Update;