From 671a3a4b287ffc8402d117d5726ac860e9a59752 Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Thu, 29 Dec 2022 21:50:10 -0800 Subject: [PATCH] Clean up todos --- NAPS2.Images.Gdi/GdiConverters.cs | 44 ------------------- NAPS2.Images.Gtk/LibTiff.cs | 3 -- NAPS2.Images.Gtk/LibTiffIo.cs | 1 - NAPS2.Images.Mac/MacImage.cs | 1 - NAPS2.Images.Mac/MacImageContext.cs | 1 - NAPS2.Lib.Gtk/EntryPoints/GtkEntryPoint.cs | 2 - NAPS2.Lib.Gtk/EtoForms/Gtk/GtkListView.cs | 5 --- NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs | 1 - .../Scan/Twain/Legacy/TwainApi.cs | 1 - .../Automation/ConsoleOperationProgress.cs | 9 +--- NAPS2.Lib/Config/CommonConfig.cs | 2 - .../EtoForms/Desktop/DesktopController.cs | 9 +--- .../Desktop/DesktopKeyboardShortcuts.cs | 1 - NAPS2.Lib/EtoForms/IFormBase.cs | 1 - NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs | 1 - NAPS2.Lib/EtoForms/Ui/DesktopForm.cs | 1 - NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs | 2 - .../Images/SaveImagesOperation.cs | 1 - NAPS2.Lib/Scan/Batch/BatchScanPerformer.cs | 2 - 19 files changed, 2 insertions(+), 86 deletions(-) delete mode 100644 NAPS2.Images.Gdi/GdiConverters.cs diff --git a/NAPS2.Images.Gdi/GdiConverters.cs b/NAPS2.Images.Gdi/GdiConverters.cs deleted file mode 100644 index 5952ce28e..000000000 --- a/NAPS2.Images.Gdi/GdiConverters.cs +++ /dev/null @@ -1,44 +0,0 @@ -// using System.Drawing; -// using System.Drawing.Imaging; -// -// namespace NAPS2.Images.Gdi; -// -// public class GdiConverters -// { -// [StorageConverter] -// public FileStorage ConvertToFile(GdiImage input, StorageConvertParams convertParams) -// { -// if (convertParams.Temporary) -// { -// var path = Path.Combine(Paths.Temp, Path.GetRandomFileName()); -// input.Bitmap.Save(path); -// return new FileStorage(path); -// } -// else -// { -// var tempPath = ScannedImageHelper.SaveSmallestBitmap(input.Bitmap, convertParams.BitDepth, convertParams.Lossless, convertParams.LossyQuality, out ImageFormat fileFormat); -// string ext = Equals(fileFormat, ImageFormat.Png) ? ".png" : ".jpg"; -// var path = _imageContext.FileStorageManager.NextFilePath() + ext; -// File.Move(tempPath, path); -// return new FileStorage(path); -// } -// } -// -// [StorageConverter] -// public GdiImage ConvertToGdi(FileStorage input, StorageConvertParams convertParams) -// { -// // TODO: Allow multiple converters (with priority?) and fall back to the next if it returns null -// // Then we can have a PDF->Image converter that returns null if it's not a pdf file. -// if (IsPdfFile(input)) -// { -// return (GdiImage)_imageContext.PdfRenderer.Render(input.FullPath, 300).Single(); -// } -// else -// { -// return new GdiImage(new Bitmap(input.FullPath)); -// } -// } -// -// private static bool IsPdfFile(FileStorage fileStorage) => Path.GetExtension(fileStorage.FullPath)?.Equals(".pdf", StringComparison.InvariantCultureIgnoreCase) ?? false; -// -// } \ No newline at end of file diff --git a/NAPS2.Images.Gtk/LibTiff.cs b/NAPS2.Images.Gtk/LibTiff.cs index 700e63b5b..8be839e53 100644 --- a/NAPS2.Images.Gtk/LibTiff.cs +++ b/NAPS2.Images.Gtk/LibTiff.cs @@ -89,7 +89,4 @@ internal static class LibTiff [DllImport("libtiff.so.5")] public static extern int TIFFReadRGBAImageOriented( IntPtr tiff, int w, int h, IntPtr raster, int orientation, int stopOnError); - - // TODO: For streams - // https://linux.die.net/man/3/tiffclientopen } \ No newline at end of file diff --git a/NAPS2.Images.Gtk/LibTiffIo.cs b/NAPS2.Images.Gtk/LibTiffIo.cs index a551dd690..6c541781b 100644 --- a/NAPS2.Images.Gtk/LibTiffIo.cs +++ b/NAPS2.Images.Gtk/LibTiffIo.cs @@ -87,7 +87,6 @@ internal class LibTiffIo : ITiffWriter LibTiff.TIFFSetField(tiff, TiffTag.ImageWidth, image.Width); LibTiff.TIFFSetField(tiff, TiffTag.ImageHeight, image.Height); LibTiff.TIFFSetField(tiff, TiffTag.PlanarConfig, 1); - // TODO: Test setting g4 compression when it's not a BW image LibTiff.TIFFSetField(tiff, TiffTag.Compression, (int) (compression switch { TiffCompressionType.Ccitt4 => TiffCompression.G4, diff --git a/NAPS2.Images.Mac/MacImage.cs b/NAPS2.Images.Mac/MacImage.cs index 31f38641e..b30c62102 100644 --- a/NAPS2.Images.Mac/MacImage.cs +++ b/NAPS2.Images.Mac/MacImage.cs @@ -2,7 +2,6 @@ namespace NAPS2.Images.Mac; -// TODO: We might need to dispose things more aggressively public class MacImage : IMemoryImage { public MacImage(ImageContext imageContext, NSImage image) diff --git a/NAPS2.Images.Mac/MacImageContext.cs b/NAPS2.Images.Mac/MacImageContext.cs index e033619ce..a55b785f4 100644 --- a/NAPS2.Images.Mac/MacImageContext.cs +++ b/NAPS2.Images.Mac/MacImageContext.cs @@ -11,7 +11,6 @@ public class MacImageContext : ImageContext public MacImageContext(IPdfRenderer? pdfRenderer = null) : base(typeof(MacImage), pdfRenderer) { - // TODO: Not sure if this is truly thread safe. NSApplication.CheckForIllegalCrossThreadCalls = false; _imageTransformer = new MacImageTransformer(this); } diff --git a/NAPS2.Lib.Gtk/EntryPoints/GtkEntryPoint.cs b/NAPS2.Lib.Gtk/EntryPoints/GtkEntryPoint.cs index 204fb4442..5a2b34311 100644 --- a/NAPS2.Lib.Gtk/EntryPoints/GtkEntryPoint.cs +++ b/NAPS2.Lib.Gtk/EntryPoints/GtkEntryPoint.cs @@ -43,8 +43,6 @@ public static class GtkEntryPoint application.UnhandledException += UnhandledException; var formFactory = container.Resolve(); var desktop = formFactory.Create(); - // TODO: Clean up invoker setting - // Invoker.Current = new WinFormsInvoker(desktop.ToNative()); application.Run(desktop); return 0; } diff --git a/NAPS2.Lib.Gtk/EtoForms/Gtk/GtkListView.cs b/NAPS2.Lib.Gtk/EtoForms/Gtk/GtkListView.cs index c7f98ff52..449f9a7ed 100644 --- a/NAPS2.Lib.Gtk/EtoForms/Gtk/GtkListView.cs +++ b/NAPS2.Lib.Gtk/EtoForms/Gtk/GtkListView.cs @@ -53,11 +53,6 @@ public class GtkListView : IListView where T : notnull public int ImageSize { get; set; } - // TODO: Properties here vs on behavior? - public bool AllowDrag { get; set; } - - public bool AllowDrop { get; set; } - public ScrolledWindow NativeControl => _scrolledWindow; public Control Control => _scrolledWindow.ToEto(); diff --git a/NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs b/NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs index 73c67317a..6fad3c025 100644 --- a/NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs +++ b/NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs @@ -31,7 +31,6 @@ public class MacIconProvider : IIconProvider { "contrast_high", "circle.righthalf.filled" }, { "sharpen", "rhombus" }, { "cross", "trash" }, - // TODO: Probably just use the save icon for these { "file_extension_pdf", "doc.richtext" }, { "pictures", "photo" } }; diff --git a/NAPS2.Lib.WinForms/Scan/Twain/Legacy/TwainApi.cs b/NAPS2.Lib.WinForms/Scan/Twain/Legacy/TwainApi.cs index 0b206c5d8..9bd7db462 100644 --- a/NAPS2.Lib.WinForms/Scan/Twain/Legacy/TwainApi.cs +++ b/NAPS2.Lib.WinForms/Scan/Twain/Legacy/TwainApi.cs @@ -8,7 +8,6 @@ using NAPS2.WinForms; namespace NAPS2.Scan.Twain.Legacy; -// TODO: Either make this usable without a form, or just get rid of it... internal static class TwainApi { public static ScanDevice? SelectDeviceUI() diff --git a/NAPS2.Lib/Automation/ConsoleOperationProgress.cs b/NAPS2.Lib/Automation/ConsoleOperationProgress.cs index 67496979e..f4cd85164 100644 --- a/NAPS2.Lib/Automation/ConsoleOperationProgress.cs +++ b/NAPS2.Lib/Automation/ConsoleOperationProgress.cs @@ -22,15 +22,8 @@ public class ConsoleOperationProgress : OperationProgress public override void ShowModalProgress(IOperation op) { - // TODO: We might want to use an eto-based progress form, or at least show some kind of indicator + // TODO: We might want to show some kind of indicator // Where is this method called from anyway? - - // if (!op.IsFinished) - // { - // var form = _formFactory.Create(); - // form.Operation = op; - // form.ShowDialog(); - // } op.Wait(); } diff --git a/NAPS2.Lib/Config/CommonConfig.cs b/NAPS2.Lib/Config/CommonConfig.cs index 7ee5beea7..46beaba38 100644 --- a/NAPS2.Lib/Config/CommonConfig.cs +++ b/NAPS2.Lib/Config/CommonConfig.cs @@ -9,8 +9,6 @@ using NAPS2.Scan.Batch; namespace NAPS2.Config; -// TODO: Remove all unnecessary nullables -// TODO: Maybe have this serialize with the root node named as AppConfig/UserConfig somehow? [Config] public class CommonConfig { diff --git a/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs b/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs index c4021703e..37cd76154 100644 --- a/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs +++ b/NAPS2.Lib/EtoForms/Desktop/DesktopController.cs @@ -10,12 +10,6 @@ using NAPS2.Update; 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. -// We could have a DesktopPipesController that depends on DesktopScanController. -// Specifically each line in Initialize might make sense as a sub-controller. -// We also need to think about how to pass the Form instance around as needed. (e.g. to Activate it). Maybe this should be something injectable, and could also be used by UpdateOperation instead of searching through open forms. -// i.e. (I)DesktopFormProvider public class DesktopController { private readonly ScanningContext _scanningContext; @@ -165,7 +159,6 @@ public class DesktopController { try { - // TODO: Figure out and fix undisposed processed images _scanningContext.Dispose(); _recoveryStorageManager.Dispose(); } @@ -263,7 +256,7 @@ public class DesktopController { // TODO: xplat var formOnTop = Application.Instance.Windows.Last(); - if (formOnTop.WindowState == WindowState.Minimized) + if (formOnTop.WindowState == WindowState.Minimized && PlatformCompat.System.CanUseWin32) { Win32.ShowWindow(formOnTop.NativeHandle, Win32.ShowWindowCommands.Restore); } diff --git a/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs b/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs index 5c85a823c..4bf3d8c1e 100644 --- a/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs +++ b/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs @@ -103,7 +103,6 @@ public class DesktopKeyboardShortcuts private string? GetProfileShortcut(int i) { - // TODO: Granular var ks = _config.Get(c => c.KeyboardShortcuts); switch (i) { diff --git a/NAPS2.Lib/EtoForms/IFormBase.cs b/NAPS2.Lib/EtoForms/IFormBase.cs index d6d25bd9e..0ab0b1517 100644 --- a/NAPS2.Lib/EtoForms/IFormBase.cs +++ b/NAPS2.Lib/EtoForms/IFormBase.cs @@ -4,7 +4,6 @@ public interface IFormBase { FormStateController FormStateController { get; } - // TODO: Make these constructor injected, Eto requires things to be defined in the constructor so property injection is error-prone IFormFactory FormFactory { get; set; } Naps2Config Config { get; set; } diff --git a/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs b/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs index 47b1b1283..9ee084a70 100644 --- a/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/BatchScanForm.cs @@ -85,7 +85,6 @@ public class BatchScanForm : EtoDialogBase private void UpdateVisibility(object? sender, EventArgs e) { - // TODO: Bundle multiple updates together before invalidating somehow _delayVis.IsVisible = _multipleScansDelay.Checked; _multiVis.IsVisible = _saveToMultipleFiles.Checked; _fileVis.IsVisible = _saveToSingleFile.Checked || _saveToMultipleFiles.Checked; diff --git a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs index 4b9803f51..e7b6eeb86 100644 --- a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs @@ -453,7 +453,6 @@ public abstract class DesktopForm : EtoFormBase private void OnKeyDown(object? sender, KeyEventArgs e) { - // TODO: The custom listview control isn't propagating events back to the parent window e.Handled = _keyboardShortcuts.Perform(e.KeyData); } diff --git a/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs index 04be1bd72..0c6c18598 100644 --- a/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/EditProfileForm.cs @@ -467,8 +467,6 @@ public class EditProfileForm : EtoDialogBase _advanced.Enabled = !locked; - // TODO: Adjust form height? - _suppressChangeEvent = false; } } diff --git a/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs b/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs index 856ed1678..11a103d21 100644 --- a/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs +++ b/NAPS2.Lib/ImportExport/Images/SaveImagesOperation.cs @@ -1,6 +1,5 @@ namespace NAPS2.ImportExport.Images; -// TODO: Cross-platform TIFF public class SaveImagesOperation : OperationBase { private readonly IOverwritePrompt _overwritePrompt; diff --git a/NAPS2.Lib/Scan/Batch/BatchScanPerformer.cs b/NAPS2.Lib/Scan/Batch/BatchScanPerformer.cs index c8c5c1517..4439b0f28 100644 --- a/NAPS2.Lib/Scan/Batch/BatchScanPerformer.cs +++ b/NAPS2.Lib/Scan/Batch/BatchScanPerformer.cs @@ -273,10 +273,8 @@ public class BatchScanPerformer : IBatchScanPerformer { subPath = placeholders.Substitute(subPath, true, 0, 1); } - // TODO: Make copies of images and dispose try { - // TODO: This is broken due to not accessing the child fields directly var exportParams = new PdfExportParams( _config.Get(c => c.PdfSettings.Metadata), _config.Get(c => c.PdfSettings.Encryption),