mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-11 14:10:49 +03:00
Implement SavePdf, SaveImages, Print event logging
This commit is contained in:
parent
6be9519ddd
commit
d2b36814e3
@ -146,6 +146,18 @@ namespace NAPS2.ImportExport.Images
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
Success.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.Result)
|
||||||
|
{
|
||||||
|
Log.Event(EventType.SaveImages, new EventParams
|
||||||
|
{
|
||||||
|
Name = MiscResources.SaveImages,
|
||||||
|
Pages = snapshots.Count,
|
||||||
|
FileFormat = Path.GetExtension(fileName)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using NAPS2.ImportExport.Email;
|
using NAPS2.ImportExport.Email;
|
||||||
using NAPS2.Lang.Resources;
|
using NAPS2.Lang.Resources;
|
||||||
@ -113,6 +114,30 @@ namespace NAPS2.ImportExport.Pdf
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
Success.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.Result)
|
||||||
|
{
|
||||||
|
if (email)
|
||||||
|
{
|
||||||
|
Log.Event(EventType.Email, new EventParams
|
||||||
|
{
|
||||||
|
Name = MiscResources.EmailPdf,
|
||||||
|
Pages = snapshots.Count,
|
||||||
|
FileFormat = ".pdf"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Event(EventType.SavePdf, new EventParams
|
||||||
|
{
|
||||||
|
Name = MiscResources.SavePdf,
|
||||||
|
Pages = snapshots.Count,
|
||||||
|
FileFormat = ".pdf"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ using System.Drawing.Printing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using NAPS2.Lang.Resources;
|
||||||
|
using NAPS2.Logging;
|
||||||
using NAPS2.Scan.Images;
|
using NAPS2.Scan.Images;
|
||||||
using NAPS2.Scan.Images.Transforms;
|
using NAPS2.Scan.Images.Transforms;
|
||||||
using NAPS2.Util;
|
using NAPS2.Util;
|
||||||
@ -105,6 +107,14 @@ namespace NAPS2.ImportExport
|
|||||||
};
|
};
|
||||||
printDocument.PrinterSettings = printerSettings;
|
printDocument.PrinterSettings = printerSettings;
|
||||||
printDocument.Print();
|
printDocument.Print();
|
||||||
|
|
||||||
|
Log.Event(EventType.Print, new EventParams
|
||||||
|
{
|
||||||
|
Name = MiscResources.Print,
|
||||||
|
Pages = snapshots.Count,
|
||||||
|
DeviceName = printDocument.PrinterSettings.PrinterName
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
36
NAPS2.Core/Lang/Resources/MiscResources.Designer.cs
generated
36
NAPS2.Core/Lang/Resources/MiscResources.Designer.cs
generated
@ -474,6 +474,15 @@ namespace NAPS2.Lang.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Email PDF.
|
||||||
|
/// </summary>
|
||||||
|
internal static string EmailPdf {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("EmailPdf", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Email PDF Progress.
|
/// Looks up a localized string similar to Email PDF Progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -933,6 +942,15 @@ namespace NAPS2.Lang.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Print.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Print {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Print", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to {0} / {1}.
|
/// Looks up a localized string similar to {0} / {1}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -987,6 +1005,15 @@ namespace NAPS2.Lang.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Save Images.
|
||||||
|
/// </summary>
|
||||||
|
internal static string SaveImages {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SaveImages", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Save Images Progress.
|
/// Looks up a localized string similar to Save Images Progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -996,6 +1023,15 @@ namespace NAPS2.Lang.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Save PDF.
|
||||||
|
/// </summary>
|
||||||
|
internal static string SavePdf {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SavePdf", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Save PDF Progress.
|
/// Looks up a localized string similar to Save PDF Progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -342,15 +342,24 @@
|
|||||||
<data name="RecoveryProgress" xml:space="preserve">
|
<data name="RecoveryProgress" xml:space="preserve">
|
||||||
<value>Recovery Progress</value>
|
<value>Recovery Progress</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SaveImages" xml:space="preserve">
|
||||||
|
<value>Save Images</value>
|
||||||
|
</data>
|
||||||
<data name="SaveImagesProgress" xml:space="preserve">
|
<data name="SaveImagesProgress" xml:space="preserve">
|
||||||
<value>Save Images Progress</value>
|
<value>Save Images Progress</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SavePdf" xml:space="preserve">
|
||||||
|
<value>Save PDF</value>
|
||||||
|
</data>
|
||||||
<data name="SavePdfProgress" xml:space="preserve">
|
<data name="SavePdfProgress" xml:space="preserve">
|
||||||
<value>Save PDF Progress</value>
|
<value>Save PDF Progress</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SavingFormat" xml:space="preserve">
|
<data name="SavingFormat" xml:space="preserve">
|
||||||
<value>Saving {0}...</value>
|
<value>Saving {0}...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Print" xml:space="preserve">
|
||||||
|
<value>Print</value>
|
||||||
|
</data>
|
||||||
<data name="Copying" xml:space="preserve">
|
<data name="Copying" xml:space="preserve">
|
||||||
<value>Copying...</value>
|
<value>Copying...</value>
|
||||||
</data>
|
</data>
|
||||||
@ -360,6 +369,9 @@
|
|||||||
<data name="Importing" xml:space="preserve">
|
<data name="Importing" xml:space="preserve">
|
||||||
<value>Importing...</value>
|
<value>Importing...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="EmailPdf" xml:space="preserve">
|
||||||
|
<value>Email PDF</value>
|
||||||
|
</data>
|
||||||
<data name="EmailPdfProgress" xml:space="preserve">
|
<data name="EmailPdfProgress" xml:space="preserve">
|
||||||
<value>Email PDF Progress</value>
|
<value>Email PDF Progress</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -19,6 +19,7 @@ namespace NAPS2.Util
|
|||||||
private readonly AppConfigManager appConfigManager;
|
private readonly AppConfigManager appConfigManager;
|
||||||
private readonly WindowsEventLogger windowsEventLogger;
|
private readonly WindowsEventLogger windowsEventLogger;
|
||||||
|
|
||||||
|
private bool shouldCreateEventSource;
|
||||||
private int returnCode;
|
private int returnCode;
|
||||||
|
|
||||||
public Lifecycle(StillImage sti, AppConfigManager appConfigManager, WindowsEventLogger windowsEventLogger)
|
public Lifecycle(StillImage sti, AppConfigManager appConfigManager, WindowsEventLogger windowsEventLogger)
|
||||||
@ -102,7 +103,8 @@ namespace NAPS2.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Any(x => x.Equals("/CreateEventSource", StringComparison.InvariantCultureIgnoreCase)))
|
shouldCreateEventSource = args.Any(x => x.Equals("/CreateEventSource", StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
if (shouldCreateEventSource)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -149,7 +151,7 @@ namespace NAPS2.Util
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ExitIfRedundant()
|
public void ExitIfRedundant()
|
||||||
{
|
{
|
||||||
if (sti.ShouldRegister || sti.ShouldUnregister)
|
if (sti.ShouldRegister || sti.ShouldUnregister || shouldCreateEventSource)
|
||||||
{
|
{
|
||||||
// Was just started by the user to (un)register STI
|
// Was just started by the user to (un)register STI
|
||||||
Environment.Exit(returnCode);
|
Environment.Exit(returnCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user