simplify event handlers + simplify pickerMessage

Co-Authored-By: Jim Hobbs <106978449+General-Ridley@users.noreply.github.com>
pull/9/head
Miepee 4 years ago
parent 422b70df3b
commit 138d5a32ea

@ -2,6 +2,7 @@ using Eto.Forms;
using Eto.Drawing; using Eto.Drawing;
using AM2RModPackerLib.XML; using AM2RModPackerLib.XML;
using System.IO; using System.IO;
using AM2RModPackerLib;
namespace AM2RModPacker; namespace AM2RModPacker;
@ -83,15 +84,15 @@ public partial class ModPacker : Form
// Assign events // Assign events
originalZipButton.Click += OriginalZipButton_Click; originalZipButton.Click += OriginalZipButton_Click;
createButton.Click += CreateButton_Click; createButton.Click += CreateButton_Click;
windowsCheckBox.CheckedChanged += WindowsCheckBox_CheckedChanged; windowsCheckBox.CheckedChanged += (_, _) => OSCheckboxChanged(ProfileOperatingSystems.Windows);
windowsButton.Click += WindowsButton_Click; windowsButton.Click += (_, _) => OSButtonClicked(ProfileOperatingSystems.Windows);
apkButton.Click += ApkButton_Click; apkCheckBox.CheckedChanged += (_, _) => OSCheckboxChanged(ProfileOperatingSystems.Android);
apkCheckBox.CheckedChanged += ApkCheckBoxCheckedChanged; apkButton.Click += (_, _) => OSButtonClicked(ProfileOperatingSystems.Android);
customSaveCheckBox.CheckedChanged += CustomSaveCheckBoxChecked_Changed; linuxCheckBox.CheckedChanged += (_, _) => OSCheckboxChanged(ProfileOperatingSystems.Linux);
linuxCheckBox.CheckedChanged += LinuxCheckBox_CheckedChanged; linuxButton.Click += (_, _) => OSButtonClicked(ProfileOperatingSystems.Linux);
linuxButton.Click += LinuxButton_Click;
macCheckBox.CheckedChanged += macCheckBox_CheckedChanged; macCheckBox.CheckedChanged += macCheckBox_CheckedChanged;
macButton.Click += macButton_Click; macButton.Click += (_, _) => OSButtonClicked(ProfileOperatingSystems.Mac);
customSaveCheckBox.CheckedChanged += CustomSaveCheckBoxChecked_Changed;
customSaveButton.Click += CustomSaveDataButton_Click; customSaveButton.Click += CustomSaveDataButton_Click;
yycCheckBox.CheckedChanged += YYCCheckBox_CheckedChanged; yycCheckBox.CheckedChanged += YYCCheckBox_CheckedChanged;
} }

@ -98,20 +98,6 @@ public partial class ModPacker : Form
modInfo.MacModPath = null; modInfo.MacModPath = null;
} }
private void WindowsCheckBox_CheckedChanged(object sender, EventArgs e) => OSCheckboxChanged(ProfileOperatingSystems.Windows);
private void WindowsButton_Click(object sender, EventArgs e) => OSButtonClicked(ProfileOperatingSystems.Windows);
private void ApkCheckBoxCheckedChanged(object sender, EventArgs e) => OSCheckboxChanged(ProfileOperatingSystems.Android);
private void ApkButton_Click(object sender, EventArgs e) => OSButtonClicked(ProfileOperatingSystems.Android);
private void LinuxCheckBox_CheckedChanged(object sender, EventArgs e) => OSCheckboxChanged(ProfileOperatingSystems.Linux);
private void LinuxButton_Click(object sender, EventArgs e) => OSButtonClicked(ProfileOperatingSystems.Linux);
private void macCheckBox_CheckedChanged(object sender, EventArgs e) private void macCheckBox_CheckedChanged(object sender, EventArgs e)
{ {
if (!yycCheckBox.Checked.Value) if (!yycCheckBox.Checked.Value)
@ -123,8 +109,6 @@ public partial class ModPacker : Form
} }
} }
private void macButton_Click(object sender, EventArgs e) => OSButtonClicked(ProfileOperatingSystems.Mac);
private void OriginalZipButton_Click(object sender, EventArgs e) private void OriginalZipButton_Click(object sender, EventArgs e)
{ {
// Open window to select AM2R 1.1 // Open window to select AM2R 1.1
@ -360,7 +344,7 @@ public partial class ModPacker : Form
private void OSButtonClicked(ProfileOperatingSystems os) private void OSButtonClicked(ProfileOperatingSystems os)
{ {
string pickerMessage = null; string pickerMessage = $"Please select your custom {os.ToString()} AM2R .{(os == ProfileOperatingSystems.Android ? "apk" : "zip")}";
Label osLabel = null; Label osLabel = null;
FieldInfo osModPathPropertyField = null; FieldInfo osModPathPropertyField = null;
PropertyInfo isOsModLoaded = null; PropertyInfo isOsModLoaded = null;
@ -368,25 +352,21 @@ public partial class ModPacker : Form
switch (os) switch (os)
{ {
case ProfileOperatingSystems.Windows: case ProfileOperatingSystems.Windows:
pickerMessage = "Please select your custom Windows AM2R .zip";
osLabel = windowsLabel; osLabel = windowsLabel;
osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.WindowsModPath)); osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.WindowsModPath));
isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsWindowsModLoaded)); isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsWindowsModLoaded));
break; break;
case ProfileOperatingSystems.Linux: case ProfileOperatingSystems.Linux:
pickerMessage = "Please select your custom Linux AM2R .zip";
osLabel = linuxLabel; osLabel = linuxLabel;
osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.LinuxModPath)); osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.LinuxModPath));
isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsLinuxModLoaded)); isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsLinuxModLoaded));
break; break;
case ProfileOperatingSystems.Mac: case ProfileOperatingSystems.Mac:
pickerMessage = "Please select your custom Mac AM2R .zip";
osLabel = macLabel; osLabel = macLabel;
osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.MacModPath)); osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.MacModPath));
isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsMacModLoaded)); isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsMacModLoaded));
break; break;
case ProfileOperatingSystems.Android: case ProfileOperatingSystems.Android:
pickerMessage = "Please select your custom AM2R .apk";
osLabel = apkLabel; osLabel = apkLabel;
osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.ApkModPath)); osModPathPropertyField = modInfo.GetType().GetField(nameof(modInfo.ApkModPath));
isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsApkModLoaded)); isOsModLoaded = modInfo.GetType().GetProperty(nameof(modInfo.IsApkModLoaded));

Loading…
Cancel
Save