Protection scan output to Avalonia

This commit is contained in:
Matt Nadareski
2020-08-06 22:09:28 -07:00
parent f61b84d058
commit 470e641a8c
2 changed files with 25 additions and 5 deletions

View File

@@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.12" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.12" />
<PackageReference Include="BurnOutSharp" Version="1.3.9.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
</ItemGroup>

View File

@@ -9,6 +9,7 @@ using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using BurnOutSharp;
using DICUI.Data;
using DICUI.Utilities;
using DICUI.Web;
@@ -399,6 +400,8 @@ namespace DICUI.Avalonia
this.Find<Button>("MediaScanButton").IsEnabled = false;
this.Find<Button>("CopyProtectScanButton").IsEnabled = false;
var progress = new Progress<FileProtection>();
progress.ProgressChanged += ProgressUpdated;
string protections = await Validators.RunProtectionScanOnPath(Env.Drive.Letter + ":\\");
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only
@@ -518,9 +521,14 @@ namespace DICUI.Avalonia
this.Find<TextBlock>("StatusLabel").Text = "Beginning dumping process";
ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process..");
var progress = new Progress<Result>();
progress.ProgressChanged += ProgressUpdated;
Result result = await Env.Run(progress);
// Get progress indicators
var resultProgress = new Progress<Result>();
resultProgress.ProgressChanged += ProgressUpdated;
var protectionProgress = new Progress<FileProtection>();
protectionProgress.ProgressChanged += ProgressUpdated;
// Run the program with the parameters
Result result = await Env.Run(resultProgress);
// If we didn't execute a dumping command we cannot get submission output
if (!Env.Parameters.IsDumpingCommand())
@@ -535,7 +543,8 @@ namespace DICUI.Avalonia
if (result)
{
// Verify dump output and save it
result = await Env.VerifyAndSaveDumpOutput(progress,
result = await Env.VerifyAndSaveDumpOutput(resultProgress,
protectionProgress,
this.Find<CheckBox>("EjectWhenDoneCheckBox").IsChecked,
UIOptions.ResetDriveAfterDump,
(si) =>
@@ -763,7 +772,7 @@ namespace DICUI.Avalonia
}
/// <summary>
/// Handler for Progress ProgressChanged event
/// Handler for Result ProgressChanged event
/// </summary>
private void ProgressUpdated(object sender, Result value)
{
@@ -771,6 +780,16 @@ namespace DICUI.Avalonia
ViewModels.LoggerViewModel.VerboseLogLn(value.Message);
}
/// <summary>
/// Handler for FileProtection ProgressChanged event
/// </summary>
private void ProgressUpdated(object sender, FileProtection value)
{
string message = $"{value.Percentage}% - {value.Filename}: {value.Protection}";
this.Find<TextBlock>("StatusLabel").Text = message;
ViewModels.LoggerViewModel.VerboseLogLn(message);
}
/// <summary>
/// Handler for StartStopButton Click event
/// </summary>