mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-11 02:45:19 +03:00
Give OperationProgress a static default
This commit is contained in:
parent
0d8f393bc1
commit
83147b716f
@ -7,6 +7,7 @@ using NAPS2.ImportExport.Pdf;
|
|||||||
using NAPS2.Operation;
|
using NAPS2.Operation;
|
||||||
using NAPS2.Images;
|
using NAPS2.Images;
|
||||||
using NAPS2.Util;
|
using NAPS2.Util;
|
||||||
|
using Ninject;
|
||||||
using Ninject.Modules;
|
using Ninject.Modules;
|
||||||
|
|
||||||
namespace NAPS2.DI.Modules
|
namespace NAPS2.DI.Modules
|
||||||
@ -18,8 +19,10 @@ namespace NAPS2.DI.Modules
|
|||||||
Bind<IPdfPasswordProvider>().To<ConsolePdfPasswordProvider>();
|
Bind<IPdfPasswordProvider>().To<ConsolePdfPasswordProvider>();
|
||||||
Bind<IErrorOutput>().To<ConsoleErrorOutput>();
|
Bind<IErrorOutput>().To<ConsoleErrorOutput>();
|
||||||
Bind<IOverwritePrompt>().To<ConsoleOverwritePrompt>();
|
Bind<IOverwritePrompt>().To<ConsoleOverwritePrompt>();
|
||||||
Bind<IOperationProgress>().To<ConsoleOperationProgress>();
|
Bind<OperationProgress>().To<ConsoleOperationProgress>();
|
||||||
Bind<IComponentInstallPrompt>().To<ConsoleComponentInstallPrompt>();
|
Bind<IComponentInstallPrompt>().To<ConsoleComponentInstallPrompt>();
|
||||||
|
|
||||||
|
OperationProgress.Default = Kernel.Get<OperationProgress>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using NAPS2.ImportExport.Pdf;
|
|||||||
using NAPS2.Operation;
|
using NAPS2.Operation;
|
||||||
using NAPS2.Util;
|
using NAPS2.Util;
|
||||||
using NAPS2.WinForms;
|
using NAPS2.WinForms;
|
||||||
|
using Ninject;
|
||||||
using Ninject.Modules;
|
using Ninject.Modules;
|
||||||
|
|
||||||
namespace NAPS2.DI.Modules
|
namespace NAPS2.DI.Modules
|
||||||
@ -17,8 +18,10 @@ namespace NAPS2.DI.Modules
|
|||||||
Bind<IPdfPasswordProvider>().To<WinFormsPdfPasswordProvider>();
|
Bind<IPdfPasswordProvider>().To<WinFormsPdfPasswordProvider>();
|
||||||
Bind<IErrorOutput>().To<MessageBoxErrorOutput>();
|
Bind<IErrorOutput>().To<MessageBoxErrorOutput>();
|
||||||
Bind<IOverwritePrompt>().To<WinFormsOverwritePrompt>();
|
Bind<IOverwritePrompt>().To<WinFormsOverwritePrompt>();
|
||||||
Bind<IOperationProgress>().To<WinFormsOperationProgress>().InSingletonScope();
|
Bind<OperationProgress>().To<WinFormsOperationProgress>().InSingletonScope();
|
||||||
Bind<IComponentInstallPrompt>().To<WinFormsComponentInstallPrompt>();
|
Bind<IComponentInstallPrompt>().To<WinFormsComponentInstallPrompt>();
|
||||||
|
|
||||||
|
OperationProgress.Default = Kernel.Get<OperationProgress>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,26 +6,26 @@ using NAPS2.Operation;
|
|||||||
|
|
||||||
namespace NAPS2.Automation
|
namespace NAPS2.Automation
|
||||||
{
|
{
|
||||||
public class ConsoleOperationProgress : IOperationProgress
|
public class ConsoleOperationProgress : OperationProgress
|
||||||
{
|
{
|
||||||
public void Attach(IOperation op)
|
public override void Attach(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowProgress(IOperation op)
|
public override void ShowProgress(IOperation op)
|
||||||
{
|
{
|
||||||
op.Wait();
|
op.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowModalProgress(IOperation op)
|
public override void ShowModalProgress(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBackgroundProgress(IOperation op) {
|
public override void ShowBackgroundProgress(IOperation op) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar) => throw new NotSupportedException();
|
public override void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar) => throw new NotSupportedException();
|
||||||
|
|
||||||
public List<IOperation> ActiveOperations => throw new NotSupportedException();
|
public override List<IOperation> ActiveOperations => throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,25 +103,18 @@ namespace NAPS2.Images
|
|||||||
return tempFilePath;
|
return tempFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
private readonly OcrRequestQueue ocrRequestQueue;
|
private readonly OcrRequestQueue ocrRequestQueue;
|
||||||
private readonly BlankDetector blankDetector;
|
private readonly BlankDetector blankDetector;
|
||||||
|
|
||||||
public ScannedImageHelper() : this(new StubOperationProgress())
|
public ScannedImageHelper()
|
||||||
{
|
{
|
||||||
}
|
operationProgress = OperationProgress.Default;
|
||||||
|
ocrRequestQueue = OcrRequestQueue.Default;
|
||||||
public ScannedImageHelper(IOperationProgress operationProgress)
|
|
||||||
{
|
|
||||||
this.operationProgress = operationProgress;
|
|
||||||
if (OcrManager.HasDefault)
|
|
||||||
{
|
|
||||||
ocrRequestQueue = new OcrRequestQueue(OcrManager.Default, operationProgress);
|
|
||||||
}
|
|
||||||
blankDetector = BlankDetector.Default;
|
blankDetector = BlankDetector.Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScannedImageHelper(IOperationProgress operationProgress, OcrRequestQueue ocrRequestQueue, BlankDetector blankDetector)
|
public ScannedImageHelper(OperationProgress operationProgress, OcrRequestQueue ocrRequestQueue, BlankDetector blankDetector)
|
||||||
{
|
{
|
||||||
this.operationProgress = operationProgress;
|
this.operationProgress = operationProgress;
|
||||||
this.ocrRequestQueue = ocrRequestQueue;
|
this.ocrRequestQueue = ocrRequestQueue;
|
||||||
|
@ -24,9 +24,9 @@ namespace NAPS2.ImportExport
|
|||||||
private readonly OcrManager ocrManager;
|
private readonly OcrManager ocrManager;
|
||||||
private readonly IErrorOutput errorOutput;
|
private readonly IErrorOutput errorOutput;
|
||||||
private readonly DialogHelper dialogHelper;
|
private readonly DialogHelper dialogHelper;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
public AutoSave(IOperationFactory operationFactory, PdfSettingsContainer pdfSettingsContainer, OcrManager ocrManager, IErrorOutput errorOutput, DialogHelper dialogHelper, IOperationProgress operationProgress)
|
public AutoSave(IOperationFactory operationFactory, PdfSettingsContainer pdfSettingsContainer, OcrManager ocrManager, IErrorOutput errorOutput, DialogHelper dialogHelper, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.operationFactory = operationFactory;
|
this.operationFactory = operationFactory;
|
||||||
this.pdfSettingsContainer = pdfSettingsContainer;
|
this.pdfSettingsContainer = pdfSettingsContainer;
|
||||||
|
@ -349,7 +349,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Dependencies\PlatformSupport.cs" />
|
<Compile Include="Dependencies\PlatformSupport.cs" />
|
||||||
<Compile Include="Images\AutoDeskew.cs" />
|
<Compile Include="Images\AutoDeskew.cs" />
|
||||||
<Compile Include="Operation\IOperationProgress.cs" />
|
<Compile Include="Operation\OperationProgress.cs" />
|
||||||
<Compile Include="Images\ScannedImageRenderer.cs" />
|
<Compile Include="Images\ScannedImageRenderer.cs" />
|
||||||
<Compile Include="Dependencies\DownloadFormat.cs" />
|
<Compile Include="Dependencies\DownloadFormat.cs" />
|
||||||
<Compile Include="Dependencies\DownloadInfo.cs" />
|
<Compile Include="Dependencies\DownloadInfo.cs" />
|
||||||
|
@ -13,17 +13,29 @@ namespace NAPS2.Ocr
|
|||||||
{
|
{
|
||||||
public class OcrRequestQueue
|
public class OcrRequestQueue
|
||||||
{
|
{
|
||||||
|
private static OcrRequestQueue _default;
|
||||||
|
|
||||||
|
public static OcrRequestQueue Default
|
||||||
|
{
|
||||||
|
get => _default ?? (_default = new OcrRequestQueue());
|
||||||
|
set => _default = value ?? throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Dictionary<OcrRequestParams, OcrRequest> requestCache = new Dictionary<OcrRequestParams, OcrRequest>();
|
private readonly Dictionary<OcrRequestParams, OcrRequest> requestCache = new Dictionary<OcrRequestParams, OcrRequest>();
|
||||||
private readonly Semaphore queueWaitHandle = new Semaphore(0, Int32.MaxValue);
|
private readonly Semaphore queueWaitHandle = new Semaphore(0, int.MaxValue);
|
||||||
private List<Task> workerTasks = new List<Task>();
|
private List<Task> workerTasks = new List<Task>();
|
||||||
private CancellationTokenSource workerCts = new CancellationTokenSource();
|
private CancellationTokenSource workerCts = new CancellationTokenSource();
|
||||||
|
|
||||||
private readonly OcrManager ocrManager;
|
private readonly OcrManager ocrManager;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
private OcrOperation currentOp;
|
private OcrOperation currentOp;
|
||||||
|
|
||||||
public OcrRequestQueue(OcrManager ocrManager, IOperationProgress operationProgress)
|
public OcrRequestQueue() : this(OcrManager.Default, OperationProgress.Default)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OcrRequestQueue(OcrManager ocrManager, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.ocrManager = ocrManager;
|
this.ocrManager = ocrManager;
|
||||||
this.operationProgress = operationProgress;
|
this.operationProgress = operationProgress;
|
||||||
@ -219,7 +231,7 @@ namespace NAPS2.Ocr
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Wait for a queued ocr request to become available
|
// Wait for a queued ocr request to become available
|
||||||
WaitHandle.WaitAny(new[] {queueWaitHandle, cts.Token.WaitHandle});
|
WaitHandle.WaitAny(new[] { queueWaitHandle, cts.Token.WaitHandle });
|
||||||
if (cts.IsCancellationRequested)
|
if (cts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace NAPS2.Operation
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A base interface for objects capabable of displaying progress for an operation.
|
|
||||||
///
|
|
||||||
/// Implementors: WinFormsOperationProgress, ConsoleOperationProgress
|
|
||||||
/// </summary>
|
|
||||||
public interface IOperationProgress
|
|
||||||
{
|
|
||||||
void Attach(IOperation op);
|
|
||||||
|
|
||||||
void ShowProgress(IOperation op);
|
|
||||||
|
|
||||||
void ShowModalProgress(IOperation op);
|
|
||||||
|
|
||||||
void ShowBackgroundProgress(IOperation op);
|
|
||||||
|
|
||||||
void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar);
|
|
||||||
|
|
||||||
List<IOperation> ActiveOperations { get; }
|
|
||||||
}
|
|
||||||
}
|
|
33
NAPS2.Sdk/Operation/OperationProgress.cs
Normal file
33
NAPS2.Sdk/Operation/OperationProgress.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace NAPS2.Operation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A base class for objects capabable of displaying progress for an operation.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class OperationProgress
|
||||||
|
{
|
||||||
|
private static OperationProgress _default = new StubOperationProgress();
|
||||||
|
|
||||||
|
public static OperationProgress Default
|
||||||
|
{
|
||||||
|
get => _default;
|
||||||
|
set => _default = value ?? throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Attach(IOperation op);
|
||||||
|
|
||||||
|
public abstract void ShowProgress(IOperation op);
|
||||||
|
|
||||||
|
public abstract void ShowModalProgress(IOperation op);
|
||||||
|
|
||||||
|
public abstract void ShowBackgroundProgress(IOperation op);
|
||||||
|
|
||||||
|
public abstract void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar);
|
||||||
|
|
||||||
|
public abstract List<IOperation> ActiveOperations { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -5,26 +5,26 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace NAPS2.Operation
|
namespace NAPS2.Operation
|
||||||
{
|
{
|
||||||
public class StubOperationProgress : IOperationProgress
|
public class StubOperationProgress : OperationProgress
|
||||||
{
|
{
|
||||||
public void Attach(IOperation op)
|
public override void Attach(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowProgress(IOperation op)
|
public override void ShowProgress(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowModalProgress(IOperation op)
|
public override void ShowModalProgress(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBackgroundProgress(IOperation op)
|
public override void ShowBackgroundProgress(IOperation op)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar) => throw new NotSupportedException();
|
public override void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar) => throw new NotSupportedException();
|
||||||
|
|
||||||
public List<IOperation> ActiveOperations => throw new NotSupportedException();
|
public override List<IOperation> ActiveOperations => throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,9 +20,9 @@ namespace NAPS2.Recovery
|
|||||||
{
|
{
|
||||||
private readonly IFormFactory formFactory;
|
private readonly IFormFactory formFactory;
|
||||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
public RecoveryManager(IFormFactory formFactory, ScannedImageRenderer scannedImageRenderer, IOperationProgress operationProgress)
|
public RecoveryManager(IFormFactory formFactory, ScannedImageRenderer scannedImageRenderer, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.formFactory = formFactory;
|
this.formFactory = formFactory;
|
||||||
this.scannedImageRenderer = scannedImageRenderer;
|
this.scannedImageRenderer = scannedImageRenderer;
|
||||||
|
@ -15,18 +15,16 @@ namespace NAPS2.Scan.Wia
|
|||||||
{
|
{
|
||||||
public const string DRIVER_NAME = "wia";
|
public const string DRIVER_NAME = "wia";
|
||||||
|
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
private readonly ScannedImageHelper scannedImageHelper;
|
private readonly ScannedImageHelper scannedImageHelper;
|
||||||
|
|
||||||
public WiaScanDriver() : this(new StubOperationProgress())
|
public WiaScanDriver()
|
||||||
{
|
{
|
||||||
|
operationProgress = OperationProgress.Default;
|
||||||
|
scannedImageHelper = new ScannedImageHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WiaScanDriver(IOperationProgress operationProgress) : this(operationProgress, new ScannedImageHelper(operationProgress))
|
public WiaScanDriver(OperationProgress operationProgress, ScannedImageHelper scannedImageHelper)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public WiaScanDriver(IOperationProgress operationProgress, ScannedImageHelper scannedImageHelper)
|
|
||||||
{
|
{
|
||||||
this.operationProgress = operationProgress;
|
this.operationProgress = operationProgress;
|
||||||
this.scannedImageHelper = scannedImageHelper;
|
this.scannedImageHelper = scannedImageHelper;
|
||||||
|
@ -21,9 +21,9 @@ namespace NAPS2.Update
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private readonly IOperationFactory operationFactory;
|
private readonly IOperationFactory operationFactory;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
public UpdateChecker(IOperationFactory operationFactory, IOperationProgress operationProgress)
|
public UpdateChecker(IOperationFactory operationFactory, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.operationFactory = operationFactory;
|
this.operationFactory = operationFactory;
|
||||||
this.operationProgress = operationProgress;
|
this.operationProgress = operationProgress;
|
||||||
|
@ -57,7 +57,7 @@ namespace NAPS2.WinForms
|
|||||||
private readonly NotificationManager notify;
|
private readonly NotificationManager notify;
|
||||||
private readonly CultureInitializer cultureInitializer;
|
private readonly CultureInitializer cultureInitializer;
|
||||||
private readonly IWorkerServiceFactory workerServiceFactory;
|
private readonly IWorkerServiceFactory workerServiceFactory;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
private readonly UpdateChecker updateChecker;
|
private readonly UpdateChecker updateChecker;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -74,7 +74,7 @@ namespace NAPS2.WinForms
|
|||||||
|
|
||||||
#region Initialization and Culture
|
#region Initialization and Culture
|
||||||
|
|
||||||
public FDesktop(StringWrapper stringWrapper, RecoveryManager recoveryManager, OcrManager ocrManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, StillImage stillImage, IOperationFactory operationFactory, KeyboardShortcutManager ksm, ThumbnailRenderer thumbnailRenderer, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, NotificationManager notify, CultureInitializer cultureInitializer, IWorkerServiceFactory workerServiceFactory, IOperationProgress operationProgress, UpdateChecker updateChecker)
|
public FDesktop(StringWrapper stringWrapper, RecoveryManager recoveryManager, OcrManager ocrManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, StillImage stillImage, IOperationFactory operationFactory, KeyboardShortcutManager ksm, ThumbnailRenderer thumbnailRenderer, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, NotificationManager notify, CultureInitializer cultureInitializer, IWorkerServiceFactory workerServiceFactory, OperationProgress operationProgress, UpdateChecker updateChecker)
|
||||||
{
|
{
|
||||||
this.stringWrapper = stringWrapper;
|
this.stringWrapper = stringWrapper;
|
||||||
this.recoveryManager = recoveryManager;
|
this.recoveryManager = recoveryManager;
|
||||||
|
@ -11,13 +11,13 @@ namespace NAPS2.WinForms
|
|||||||
public partial class FProgress : FormBase
|
public partial class FProgress : FormBase
|
||||||
{
|
{
|
||||||
private readonly IErrorOutput errorOutput;
|
private readonly IErrorOutput errorOutput;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
private volatile bool loaded;
|
private volatile bool loaded;
|
||||||
private volatile bool background;
|
private volatile bool background;
|
||||||
private IOperation operation;
|
private IOperation operation;
|
||||||
|
|
||||||
public FProgress(IErrorOutput errorOutput, IOperationProgress operationProgress)
|
public FProgress(IErrorOutput errorOutput, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.errorOutput = errorOutput;
|
this.errorOutput = errorOutput;
|
||||||
this.operationProgress = operationProgress;
|
this.operationProgress = operationProgress;
|
||||||
|
@ -48,9 +48,9 @@ namespace NAPS2.WinForms
|
|||||||
private ToolStripButton tsSharpen;
|
private ToolStripButton tsSharpen;
|
||||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||||
private readonly KeyboardShortcutManager ksm;
|
private readonly KeyboardShortcutManager ksm;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
public FViewer(ChangeTracker changeTracker, IOperationFactory operationFactory, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, KeyboardShortcutManager ksm, IOperationProgress operationProgress)
|
public FViewer(ChangeTracker changeTracker, IOperationFactory operationFactory, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, KeyboardShortcutManager ksm, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.changeTracker = changeTracker;
|
this.changeTracker = changeTracker;
|
||||||
this.operationFactory = operationFactory;
|
this.operationFactory = operationFactory;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
|
||||||
using NAPS2.Config;
|
using NAPS2.Config;
|
||||||
using NAPS2.Operation;
|
using NAPS2.Operation;
|
||||||
using NAPS2.Update;
|
using NAPS2.Update;
|
||||||
@ -50,7 +49,7 @@ namespace NAPS2.WinForms
|
|||||||
Show(new DonatePromptNotifyWidget());
|
Show(new DonatePromptNotifyWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OperationProgress(IOperationProgress opModalProgress, IOperation op)
|
public void OperationProgress(OperationProgress opModalProgress, IOperation op)
|
||||||
{
|
{
|
||||||
Show(new OperationProgressNotifyWidget(opModalProgress, op));
|
Show(new OperationProgressNotifyWidget(opModalProgress, op));
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ namespace NAPS2.WinForms
|
|||||||
{
|
{
|
||||||
public partial class OperationProgressNotifyWidget : NotifyWidgetBase
|
public partial class OperationProgressNotifyWidget : NotifyWidgetBase
|
||||||
{
|
{
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
private readonly IOperation op;
|
private readonly IOperation op;
|
||||||
|
|
||||||
public OperationProgressNotifyWidget(IOperationProgress operationProgress, IOperation op)
|
public OperationProgressNotifyWidget(OperationProgress operationProgress, IOperation op)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ namespace NAPS2.WinForms
|
|||||||
private readonly IOperationFactory operationFactory;
|
private readonly IOperationFactory operationFactory;
|
||||||
private readonly IFormFactory formFactory;
|
private readonly IFormFactory formFactory;
|
||||||
private readonly OcrManager ocrManager;
|
private readonly OcrManager ocrManager;
|
||||||
private readonly IOperationProgress operationProgress;
|
private readonly OperationProgress operationProgress;
|
||||||
|
|
||||||
public WinFormsExportHelper(PdfSettingsContainer pdfSettingsContainer, ImageSettingsContainer imageSettingsContainer, EmailSettingsContainer emailSettingsContainer, DialogHelper dialogHelper, ChangeTracker changeTracker, IOperationFactory operationFactory, IFormFactory formFactory, OcrManager ocrManager, IOperationProgress operationProgress)
|
public WinFormsExportHelper(PdfSettingsContainer pdfSettingsContainer, ImageSettingsContainer imageSettingsContainer, EmailSettingsContainer emailSettingsContainer, DialogHelper dialogHelper, ChangeTracker changeTracker, IOperationFactory operationFactory, IFormFactory formFactory, OcrManager ocrManager, OperationProgress operationProgress)
|
||||||
{
|
{
|
||||||
this.pdfSettingsContainer = pdfSettingsContainer;
|
this.pdfSettingsContainer = pdfSettingsContainer;
|
||||||
this.imageSettingsContainer = imageSettingsContainer;
|
this.imageSettingsContainer = imageSettingsContainer;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using NAPS2.Config;
|
using NAPS2.Config;
|
||||||
using NAPS2.Lang.Resources;
|
using NAPS2.Lang.Resources;
|
||||||
@ -9,7 +8,7 @@ using NAPS2.Operation;
|
|||||||
|
|
||||||
namespace NAPS2.WinForms
|
namespace NAPS2.WinForms
|
||||||
{
|
{
|
||||||
public class WinFormsOperationProgress : IOperationProgress
|
public class WinFormsOperationProgress : OperationProgress
|
||||||
{
|
{
|
||||||
private readonly IFormFactory formFactory;
|
private readonly IFormFactory formFactory;
|
||||||
private readonly NotificationManager notificationManager;
|
private readonly NotificationManager notificationManager;
|
||||||
@ -22,7 +21,7 @@ namespace NAPS2.WinForms
|
|||||||
this.notificationManager = notificationManager;
|
this.notificationManager = notificationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attach(IOperation op)
|
public override void Attach(IOperation op)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ namespace NAPS2.WinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowProgress(IOperation op)
|
public override void ShowProgress(IOperation op)
|
||||||
{
|
{
|
||||||
if (UserConfig.Current.BackgroundOperations.Contains(op.GetType().Name))
|
if (UserConfig.Current.BackgroundOperations.Contains(op.GetType().Name))
|
||||||
{
|
{
|
||||||
@ -47,7 +46,7 @@ namespace NAPS2.WinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowModalProgress(IOperation op)
|
public override void ShowModalProgress(IOperation op)
|
||||||
{
|
{
|
||||||
Attach(op);
|
Attach(op);
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ namespace NAPS2.WinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBackgroundProgress(IOperation op)
|
public override void ShowBackgroundProgress(IOperation op)
|
||||||
{
|
{
|
||||||
Attach(op);
|
Attach(op);
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ namespace NAPS2.WinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar)
|
public override void RenderStatus(IOperation op, Label textLabel, Label numberLabel, ProgressBar progressBar)
|
||||||
{
|
{
|
||||||
var status = op.Status ?? new OperationStatus();
|
var status = op.Status ?? new OperationStatus();
|
||||||
textLabel.Text = status.StatusText;
|
textLabel.Text = status.StatusText;
|
||||||
@ -119,7 +118,7 @@ namespace NAPS2.WinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IOperation> ActiveOperations
|
public override List<IOperation> ActiveOperations
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user