Make DiscInformationWindow more robust

This commit is contained in:
Matt Nadareski
2020-09-13 20:41:23 -07:00
parent bf8aac6f81
commit f509ac60da
3 changed files with 49 additions and 45 deletions

View File

@@ -454,7 +454,7 @@ namespace DICUI.Avalonia
private void SetSupportedDriveSpeed()
{
// Set the drive speed list that's appropriate
var values = Constants.GetSpeedsForMediaType(CurrentMediaType);
var values = Interface.GetSpeedsForMediaType(CurrentMediaType);
this.Find<ComboBox>("DriveSpeedComboBox").Items = values;
ViewModels.LoggerViewModel.VerboseLogLn("Supported media speeds: {0}", string.Join(",", values));
@@ -464,6 +464,21 @@ namespace DICUI.Avalonia
this.Find<ComboBox>("DriveSpeedComboBox").SelectedItem = speed;
}
/// <summary>
/// Show the disc information window
/// </summary>
/// <param name="submissionInfo">SubmissionInfo object to display and possibly change</param>
/// <returns>Dialog open result</returns>
private bool? ShowDiscInformationWindow(SubmissionInfo submissionInfo)
{
var discInformationWindow = new DiscInformationWindow();
discInformationWindow.SubmissionInfo = submissionInfo;
discInformationWindow.Load();
discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
discInformationWindow.ShowDialog(this).ConfigureAwait(false).GetAwaiter().GetResult();
return true;
}
/// <summary>
/// Begin the dumping process using the given inputs
/// </summary>
@@ -516,7 +531,7 @@ namespace DICUI.Avalonia
}
}
this.Find<Button>("StartStopButton").Content = Constants.StopDumping;
this.Find<Button>("StartStopButton").Content = Interface.StopDumping;
this.Find<Button>("CopyProtectScanButton").IsEnabled = false;
this.Find<TextBlock>("StatusLabel").Text = "Beginning dumping process";
ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process..");
@@ -535,7 +550,7 @@ namespace DICUI.Avalonia
{
ViewModels.LoggerViewModel.VerboseLogLn("No dumping command was run, submission information will not be gathered.");
this.Find<TextBlock>("StatusLabel").Text = "Execution complete!";
this.Find<Button>("StartStopButton").Content = Constants.StartDumping;
this.Find<Button>("StartStopButton").Content = Interface.StartDumping;
this.Find<Button>("CopyProtectScanButton").IsEnabled = true;
return;
}
@@ -547,15 +562,7 @@ namespace DICUI.Avalonia
protectionProgress,
this.Find<CheckBox>("EjectWhenDoneCheckBox").IsChecked,
UIOptions.Options.ResetDriveAfterDump,
(si) =>
{
var discInformationWindow = new DiscInformationWindow();
discInformationWindow.SubmissionInfo = si;
discInformationWindow.Load();
discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
discInformationWindow.ShowDialog(this).ConfigureAwait(false).GetAwaiter().GetResult();
return true;
}
ShowDiscInformationWindow
);
}
}
@@ -565,7 +572,7 @@ namespace DICUI.Avalonia
}
finally
{
this.Find<Button>("StartStopButton").Content = Constants.StartDumping;
this.Find<Button>("StartStopButton").Content = Interface.StartDumping;
this.Find<Button>("CopyProtectScanButton").IsEnabled = true;
}
}
@@ -773,11 +780,11 @@ namespace DICUI.Avalonia
private void StartStopButtonClick(object sender, RoutedEventArgs e)
{
// Dump or stop the dump
if ((string)this.Find<Button>("StartStopButton").Content == Constants.StartDumping)
if ((string)this.Find<Button>("StartStopButton").Content == Interface.StartDumping)
{
StartDumping();
}
else if ((string)this.Find<Button>("StartStopButton").Content == Constants.StopDumping)
else if ((string)this.Find<Button>("StartStopButton").Content == Interface.StopDumping)
{
ViewModels.LoggerViewModel.VerboseLogLn("Canceling dumping process...");
Env.CancelDumping();

View File

@@ -12,6 +12,8 @@ namespace DICUI.Windows
/// </summary>
public partial class DiscInformationWindow : Window
{
#region Fields
/// <summary>
/// List of available disc categories
/// </summary>
@@ -32,10 +34,11 @@ namespace DICUI.Windows
/// </summary>
public List<LanguageComboBoxItem> Languages { get; private set; }
public DiscInformationWindow(SubmissionInfo submissionInfo)
#endregion
public DiscInformationWindow()
{
InitializeComponent();
SubmissionInfo = submissionInfo;
PopulateCategories();
PopulateRegions();

View File

@@ -56,11 +56,6 @@ namespace DICUI.Windows
/// </summary>
private bool alreadyShown;
/// <summary>
/// Current attached DiscInformationWindow
/// </summary>
private DiscInformationWindow discInformationWindow;
/// <summary>
/// Current attached LogWindow
/// </summary>
@@ -444,7 +439,7 @@ namespace DICUI.Windows
private void SetSupportedDriveSpeed()
{
// Set the drive speed list that's appropriate
var values = Constants.GetSpeedsForMediaType(CurrentMediaType);
var values = Interface.GetSpeedsForMediaType(CurrentMediaType);
DriveSpeedComboBox.ItemsSource = values;
ViewModels.LoggerViewModel.VerboseLogLn("Supported media speeds: {0}", string.Join(",", values));
@@ -454,6 +449,21 @@ namespace DICUI.Windows
DriveSpeedComboBox.SelectedValue = speed;
}
/// <summary>
/// Show the disc information window
/// </summary>
/// <param name="submissionInfo">SubmissionInfo object to display and possibly change</param>
/// <returns>Dialog open result</returns>
private bool? ShowDiscInformationWindow(SubmissionInfo submissionInfo)
{
var discInformationWindow = new DiscInformationWindow();
discInformationWindow.SubmissionInfo = submissionInfo;
discInformationWindow.Owner = this;
discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
discInformationWindow.Load();
return discInformationWindow.ShowDialog();
}
/// <summary>
/// Begin the dumping process using the given inputs
/// </summary>
@@ -504,7 +514,7 @@ namespace DICUI.Windows
}
}
StartStopButton.Content = Constants.StopDumping;
StartStopButton.Content = Interface.StopDumping;
CopyProtectScanButton.IsEnabled = false;
StatusLabel.Content = "Beginning dumping process";
ViewModels.LoggerViewModel.VerboseLogLn("Starting dumping process..");
@@ -523,7 +533,7 @@ namespace DICUI.Windows
{
ViewModels.LoggerViewModel.VerboseLogLn("No dumping command was run, submission information will not be gathered.");
StatusLabel.Content = "Execution complete!";
StartStopButton.Content = Constants.StartDumping;
StartStopButton.Content = Interface.StartDumping;
CopyProtectScanButton.IsEnabled = true;
return;
}
@@ -535,23 +545,7 @@ namespace DICUI.Windows
protectionProgress,
EjectWhenDoneCheckBox.IsChecked,
UIOptions.Options.ResetDriveAfterDump,
(si) =>
{
// lazy initialization
if (discInformationWindow == null)
{
discInformationWindow = new DiscInformationWindow(si);
discInformationWindow.Closed += delegate
{
discInformationWindow = null;
};
}
discInformationWindow.Owner = this;
discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
discInformationWindow.Load();
return discInformationWindow.ShowDialog();
}
ShowDiscInformationWindow
);
}
}
@@ -561,7 +555,7 @@ namespace DICUI.Windows
}
finally
{
StartStopButton.Content = Constants.StartDumping;
StartStopButton.Content = Interface.StartDumping;
CopyProtectScanButton.IsEnabled = true;
}
}
@@ -811,11 +805,11 @@ namespace DICUI.Windows
private void StartStopButtonClick(object sender, RoutedEventArgs e)
{
// Dump or stop the dump
if ((string)StartStopButton.Content == Constants.StartDumping)
if ((string)StartStopButton.Content == Interface.StartDumping)
{
StartDumping();
}
else if ((string)StartStopButton.Content == Constants.StopDumping)
else if ((string)StartStopButton.Content == Interface.StopDumping)
{
ViewModels.LoggerViewModel.VerboseLogLn("Canceling dumping process...");
Env.CancelDumping();