Use selected drive in UI for copy protect scan (fixes #235)

This commit is contained in:
Matt Nadareski
2020-10-11 20:31:27 -07:00
parent 27391ed31b
commit 69d61ad185
2 changed files with 15 additions and 8 deletions

View File

@@ -387,12 +387,15 @@ namespace DICUI.Avalonia
/// </summary>
private async void ScanAndShowProtection()
{
// Determine current environment, just in case
if (Env == null)
Env = DetermineEnvironment();
if (Env.Drive.Letter != default(char))
// Pull the drive letter from the UI directly, just in case
var drive = this.Find<ComboBox>("DriveLetterComboBox").SelectedItem as Drive;
if (drive.Letter != default(char))
{
ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", Env.Drive.Letter);
ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", drive.Letter);
var tempContent = this.Find<TextBlock>("StatusLabel").Text;
this.Find<TextBlock>("StatusLabel").Text = "Scanning for copy protection... this might take a while!";
@@ -402,7 +405,7 @@ namespace DICUI.Avalonia
var progress = new Progress<FileProtection>();
progress.ProgressChanged += ProgressUpdated;
string protections = await Validators.RunProtectionScanOnPath(Env.Drive.Letter + ":\\");
string protections = await Validators.RunProtectionScanOnPath(drive.Letter + ":\\");
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only
if (Env.InternalProgram == InternalProgram.DiscImageCreator && protections.Contains("SmartE"))
@@ -422,7 +425,7 @@ namespace DICUI.Avalonia
}.ShowDialog(this);
}
ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", Env.Drive.Letter, protections);
ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", drive.Letter, protections);
this.Find<TextBlock>("StatusLabel").Text = tempContent;
this.Find<Button>("StartStopButton").IsEnabled = true;

View File

@@ -376,12 +376,15 @@ namespace DICUI.Windows
/// </summary>
private async void ScanAndShowProtection()
{
// Determine current environment, just in case
if (Env == null)
Env = DetermineEnvironment();
if (Env.Drive.Letter != default(char))
// Pull the drive letter from the UI directly, just in case
var drive = DriveLetterComboBox.SelectedItem as Drive;
if (drive.Letter != default(char))
{
ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", Env.Drive.Letter);
ViewModels.LoggerViewModel.VerboseLogLn("Scanning for copy protection in {0}", drive.Letter);
var tempContent = StatusLabel.Content;
StatusLabel.Content = "Scanning for copy protection... this might take a while!";
@@ -391,7 +394,7 @@ namespace DICUI.Windows
var progress = new Progress<FileProtection>();
progress.ProgressChanged += ProgressUpdated;
string protections = await Validators.RunProtectionScanOnPath(Env.Drive.Letter + ":\\", progress);
string protections = await Validators.RunProtectionScanOnPath(drive.Letter + ":\\", progress);
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only
if (Env.InternalProgram == InternalProgram.DiscImageCreator && protections.Contains("SmartE"))
@@ -402,7 +405,8 @@ namespace DICUI.Windows
if (!ViewModels.LoggerViewModel.WindowVisible)
MessageBox.Show(protections, "Detected Protection", MessageBoxButton.OK, MessageBoxImage.Information);
ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", Env.Drive.Letter, protections);
ViewModels.LoggerViewModel.VerboseLog("Detected the following protections in {0}:\r\n\r\n{1}", drive.Letter, protections);
StatusLabel.Content = tempContent;
StartStopButton.IsEnabled = true;