Post-merge cleanup

This commit is contained in:
Matt Nadareski
2018-07-05 13:18:01 -07:00
parent 9dbd30adba
commit 39ce56d579
7 changed files with 52 additions and 44 deletions

View File

@@ -1,12 +1,6 @@
using DICUI.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace DICUI.Test.Utilities
{
public class DriveTest

View File

@@ -9,6 +9,9 @@ namespace DICUI.Data
/// <summary>
/// Variables for UI elements
/// </summary>
/// <remarks>
/// TODO: Pull out anything not a const string from this class
/// </remarks>
public static class UIElements
{
public const string StartDumping = "Start Dumping";

View File

@@ -3,7 +3,6 @@
/// <summary>
/// Known systems
/// </summary>
/// <remarks>Ensure that Utilities methods are updated as well</remarks>
public enum KnownSystem
{
NONE = 0,
@@ -137,7 +136,7 @@
#endregion
Custom = 0x0EADBEEF
Custom,
}
/// <summary>

View File

@@ -9,7 +9,6 @@ using System.Windows.Controls;
using WinForms = System.Windows.Forms;
using DICUI.Data;
using DICUI.Utilities;
using static DICUI.Data.UIElements;
namespace DICUI
{
@@ -81,7 +80,7 @@ namespace DICUI
private void cmb_SystemType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// If we're on a separator, go to the next item and return
if ((cmb_SystemType.SelectedItem as KnownSystemComboBoxItem).IsHeader())
if ((cmb_SystemType.SelectedItem as UIElements.KnownSystemComboBoxItem).IsHeader())
{
cmb_SystemType.SelectedIndex++;
return;
@@ -158,7 +157,7 @@ namespace DICUI
/// </summary>
private void PopulateMediaTypeAccordingToChosenSystem()
{
KnownSystem? currentSystem = cmb_SystemType.SelectedItem as KnownSystemComboBoxItem;
KnownSystem? currentSystem = cmb_SystemType.SelectedItem as UIElements.KnownSystemComboBoxItem;
if (currentSystem != null)
{
@@ -192,12 +191,12 @@ namespace DICUI
.ToList()
);
List<KnownSystemComboBoxItem> comboBoxItems = new List<KnownSystemComboBoxItem>();
List<UIElements.KnownSystemComboBoxItem> comboBoxItems = new List<UIElements.KnownSystemComboBoxItem>();
foreach (var group in mapping)
{
comboBoxItems.Add(new KnownSystemComboBoxItem(group.Key));
group.Value.ForEach(system => comboBoxItems.Add(new KnownSystemComboBoxItem(system)));
comboBoxItems.Add(new UIElements.KnownSystemComboBoxItem(group.Key));
group.Value.ForEach(system => comboBoxItems.Add(new UIElements.KnownSystemComboBoxItem(system)));
}
cmb_SystemType.ItemsSource = comboBoxItems;
@@ -266,7 +265,7 @@ namespace DICUI
DICParameters = txt_Parameters.Text,
System = (KnownSystem?)(cmb_SystemType.SelectedItem as KnownSystemComboBoxItem),
System = (KnownSystem?)(cmb_SystemType.SelectedItem as UIElements.KnownSystemComboBoxItem),
Type = cmb_MediaType.SelectedItem as MediaType?
};
}
@@ -297,7 +296,7 @@ namespace DICUI
private void EnsureDiscInformation()
{
// Get the selected system info
KnownSystem? selectedSystem = (KnownSystem?)(cmb_SystemType.SelectedItem as KnownSystemComboBoxItem) ?? KnownSystem.NONE;
KnownSystem? selectedSystem = (KnownSystem?)(cmb_SystemType.SelectedItem as UIElements.KnownSystemComboBoxItem) ?? KnownSystem.NONE;
MediaType? selectedMediaType = cmb_MediaType.SelectedItem as MediaType? ?? MediaType.NONE;
Result result = GetSupportStatus(selectedSystem, selectedMediaType);
@@ -427,7 +426,7 @@ namespace DICUI
private void GetOutputNames()
{
Drive drive = cmb_DriveLetter.SelectedItem as Drive;
KnownSystem? systemType = (KnownSystem?)(cmb_SystemType.SelectedItem as KnownSystemComboBoxItem);
KnownSystem? systemType = (KnownSystem?)(cmb_SystemType.SelectedItem as UIElements.KnownSystemComboBoxItem);
MediaType? mediaType = cmb_MediaType.SelectedItem as MediaType?;
if (drive != null
@@ -452,7 +451,7 @@ namespace DICUI
private async void ScanAndShowProtection()
{
var env = DetermineEnvironment();
if (env.DriveLetter != default(char))
if (env.Drive.Letter != default(char))
{
var tempContent = lbl_Status.Content;
lbl_Status.Content = "Scanning for copy protection... this might take a while!";
@@ -460,7 +459,7 @@ namespace DICUI
btn_Search.IsEnabled = false;
btn_Scan.IsEnabled = false;
string protections = await Tasks.RunProtectionScan(env.DriveLetter + ":\\");
string protections = await Tasks.RunProtectionScan(env.Drive.Letter + ":\\");
MessageBox.Show(protections, "Detected Protection", MessageBoxButton.OK, MessageBoxImage.Information);
lbl_Status.Content = tempContent;

View File

@@ -4,8 +4,8 @@ using System.Globalization;
using System.Windows.Data;
using IMAPI2;
using DICUI.Data;
using static DICUI.Data.UIElements;
// TODO: Consider making the *Extensions classes into its own file
namespace DICUI.Utilities
{
/// <summary>
@@ -52,9 +52,15 @@ namespace DICUI.Utilities
public static bool DoesSupportDriveSpeed(this KnownSystem? system)
{
return system != KnownSystem.MicrosoftXBOX
&& system != KnownSystem.MicrosoftXBOX360XDG2
&& system != KnownSystem.MicrosoftXBOX360XDG3;
switch (system)
{
case KnownSystem.MicrosoftXBOX:
case KnownSystem.MicrosoftXBOX360XDG2:
case KnownSystem.MicrosoftXBOX360XDG3:
return false;
default:
return true;
}
}
public static KnownSystemCategory Category(this KnownSystem? system)
@@ -98,12 +104,18 @@ namespace DICUI.Utilities
{
switch (category)
{
case KnownSystemCategory.Arcade: return "Arcade";
case KnownSystemCategory.Computer: return "Computers";
case KnownSystemCategory.Console: return "Consoles";
case KnownSystemCategory.Other: return "Other";
case KnownSystemCategory.Custom: return "Custom";
default: return "";
case KnownSystemCategory.Arcade:
return "Arcade";
case KnownSystemCategory.Computer:
return "Computers";
case KnownSystemCategory.Console:
return "Consoles";
case KnownSystemCategory.Other:
return "Other";
case KnownSystemCategory.Custom:
return "Custom";
default:
return "";
}
}
}
@@ -117,6 +129,8 @@ namespace DICUI.Utilities
{
if (value is MediaType?)
return ((MediaType?)value).Name();
else if (value is KnownSystem?)
return ((KnownSystem?)value).Name();
else
return "";
}

View File

@@ -54,7 +54,10 @@ namespace DICUI.Utilities
if (System == KnownSystem.Custom)
{
Validators.DetermineFlags(DICParameters, out Type, out System, out string letter, out string path);
Drive = Drive.Optical(String.IsNullOrWhiteSpace(letter) ? new char() : letter[0], "");
if (Type == MediaType.Floppy)
Drive = Drive.Floppy(String.IsNullOrWhiteSpace(letter) ? new char() : letter[0]);
else
Drive = Drive.Optical(String.IsNullOrWhiteSpace(letter) ? new char() : letter[0], "");
OutputDirectory = Path.GetDirectoryName(path);
OutputFilename = Path.GetFileName(path);
}
@@ -257,7 +260,7 @@ namespace DICUI.Utilities
}
break;
case KnownSystem.SonyPlayStation:
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(DriveLetter) ?? "";
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(Drive.Letter) ?? "";
mappings[Template.PlayStationEDCField] = GetMissingEDCCount(combinedBase + ".img_eccEdc.txt") > 0 ? "No" : "Yes"; // TODO: This needs to be verified
mappings[Template.PlayStationAntiModchipField] = GetAntiModchipDetected(combinedBase + "_disc.txt") ? "Yes" : "No";
mappings[Template.PlayStationLibCryptField] = "No";
@@ -273,8 +276,8 @@ namespace DICUI.Utilities
break;
case KnownSystem.SonyPlayStation2:
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(DriveLetter) ?? "";
mappings[Template.VersionField] = GetPlayStation2Version(DriveLetter) ?? "";
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(Drive.Letter) ?? "";
mappings[Template.VersionField] = GetPlayStation2Version(Drive.Letter) ?? "";
break;
}
@@ -355,8 +358,8 @@ namespace DICUI.Utilities
}
break;
case KnownSystem.SonyPlayStation2:
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(DriveLetter) ?? "";
mappings[Template.VersionField] = GetPlayStation2Version(DriveLetter) ?? "";
mappings[Template.PlaystationEXEDateField] = GetPlayStationEXEDate(Drive.Letter) ?? "";
mappings[Template.VersionField] = GetPlayStation2Version(Drive.Letter) ?? "";
break;
}
break;
@@ -730,7 +733,7 @@ namespace DICUI.Utilities
return "(CHECK WITH PROTECTIONID)";
}
return Task.Run(() => Tasks.RunProtectionScan(DriveLetter + ":\\")).Result;
return Task.Run(() => Tasks.RunProtectionScan(Drive.Letter + ":\\")).Result;
}
/// <summary>

View File

@@ -7,11 +7,11 @@ using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using IMAPI2;
using DICUI.Data;
using DICUI.External;
using static DICUI.Data.UIElements;
namespace DICUI.Utilities
{
// TODO: Consider putting this in its own file, or with DumpEnvironment
// TODO: Investigate whether or not this could be a struct
public class Drive
{
public char Letter { get; private set; }
@@ -389,13 +389,9 @@ namespace DICUI.Utilities
}
/// <summary>
/// Create a list of systems matched to their respective enums
/// Create a list of systems
/// </summary>
/// <returns>Systems matched to enums, if possible</returns>
/// <remarks>
/// If something has a "string, null" value, it should be assumed that it is a separator
/// </remarks>
/// TODO: Figure out a way that the sections can be generated more automatically
/// <returns>KnownSystems, if possible</returns>
public static List<KnownSystem?> CreateListOfSystems()
{
return Enum.GetValues(typeof(KnownSystem))