Use file scoped namespaces

pull/5/head
Miepee 4 years ago
parent 2a08ff2946
commit 9ad9935fff

@ -1,9 +1,6 @@
using System; using System;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.IO; using System.IO;
using System.Threading;
using AM2RPortHelperLib; using AM2RPortHelperLib;
namespace AM2RPortHelper; namespace AM2RPortHelper;

@ -1,14 +1,13 @@
using System; using System;
using Eto.Forms; using Eto.Forms;
namespace AM2RPortHelperGUI.Gtk namespace AM2RPortHelperGUI.Gtk;
class Program
{ {
class Program [STAThread]
public static void Main(string[] args)
{ {
[STAThread] new Application(Eto.Platforms.Gtk).Run(new MainForm());
public static void Main(string[] args)
{
new Application(Eto.Platforms.Gtk).Run(new MainForm());
}
} }
} }

@ -1,14 +1,13 @@
using System; using System;
using Eto.Forms; using Eto.Forms;
namespace AM2RPortHelperGUI.Mac namespace AM2RPortHelperGUI.Mac;
class Program
{ {
class Program [STAThread]
public static void Main(string[] args)
{ {
[STAThread] new Application(Eto.Platforms.Mac64).Run(new MainForm());
public static void Main(string[] args)
{
new Application(Eto.Platforms.Mac64).Run(new MainForm());
}
} }
} }

@ -1,14 +1,13 @@
using System; using System;
using Eto.Forms; using Eto.Forms;
namespace AM2RPortHelperGUI.Wpf namespace AM2RPortHelperGUI.Wpf;
class Program
{ {
class Program [STAThread]
public static void Main(string[] args)
{ {
[STAThread] new Application(Eto.Platforms.Wpf).Run(new MainForm());
public static void Main(string[] args)
{
new Application(Eto.Platforms.Wpf).Run(new MainForm());
}
} }
} }

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -7,165 +7,164 @@ using AM2RPortHelperLib;
using Eto.Forms; using Eto.Forms;
using Eto.Drawing; using Eto.Drawing;
namespace AM2RPortHelperGUI namespace AM2RPortHelperGUI;
public partial class MainForm : Form
{ {
public partial class MainForm : Form public MainForm()
{ {
public MainForm() Title = "AM2RPortHelper";
{ MinimumSize = new Size(200, 200);
Title = "AM2RPortHelper";
MinimumSize = new Size(200, 200);
var mainLayout = new DynamicLayout(); var mainLayout = new DynamicLayout();
mainLayout.BeginVertical(); mainLayout.BeginVertical();
mainLayout.AddRange(labelSelectMod, mainLayout.AddRange(labelSelectMod,
new Label { Height = 5 }, new Label { Height = 5 },
filePicker, filePicker,
labelProgress, labelProgress,
new Label { Height = 10 }); new Label { Height = 10 });
mainLayout.EndVertical(); mainLayout.EndVertical();
mainLayout.BeginCentered(); mainLayout.BeginCentered();
mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac); mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac);
mainLayout.AddSpace(); mainLayout.AddSpace();
mainLayout.EndCentered(); mainLayout.EndCentered();
mainLayout.BeginVertical(); mainLayout.BeginVertical();
mainLayout.AddRange(new Label { Height = 10}, buttonPort, null); mainLayout.AddRange(new Label { Height = 10}, buttonPort, null);
mainLayout.EndVertical(); mainLayout.EndVertical();
var mainPage = new TabPage var mainPage = new TabPage
{
Text = "Raw Mods",
Content = mainLayout
};
var am2rModLayout = new DynamicLayout();
var am2rModPage = new TabPage
{
Text = "AM2RLauncher Mods",
Content = am2rModLayout
};
Content = new TabControl
{
Pages =
{
mainPage,
am2rModPage
}
};
// events
checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick;
}
private async void ButtonPortOnClick(object sender, EventArgs e)
{ {
DisableAllElements(); Text = "Raw Mods",
Content = mainLayout
PortHelper.OutputHandlerDelegate handler = output => Application.Instance.Invoke(() => labelProgress.Text = $"Info: {output}"); };
string modZipPath = filePicker.FilePath;
string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); var am2rModLayout = new DynamicLayout();
string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip"; var am2rModPage = new TabPage
string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk"; {
string macPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_MACOS.zip"; Text = "AM2RLauncher Mods",
Content = am2rModLayout
if (File.Exists(linuxPath)) };
File.Delete(linuxPath);
if (File.Exists(androidPath))
File.Delete(androidPath); Content = new TabControl
if (File.Exists(macPath)) {
File.Delete(macPath); Pages =
if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, handler));
if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, handler));
if (checkboxMac.Checked.Value)
{ {
string modName = "foo";//MessageBox.Show() mainPage,
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, handler)); am2rModPage
} }
};
// events
checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick;
}
private async void ButtonPortOnClick(object sender, EventArgs e)
{
DisableAllElements();
labelProgress.Text = "Done!"; PortHelper.OutputHandlerDelegate handler = output => Application.Instance.Invoke(() => labelProgress.Text = $"Info: {output}");
OpenFolder(currentDir); string modZipPath = filePicker.FilePath;
string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
EnableAllElements(); string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip";
} string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk";
string macPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_MACOS.zip";
public static void OpenFolder(string path) if (File.Exists(linuxPath))
{ File.Delete(linuxPath);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (File.Exists(androidPath))
Process.Start("explorer.exe", $"\"{path}\""); File.Delete(androidPath);
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) if (File.Exists(macPath))
Process.Start("xdg-open", $"\"{path}\""); File.Delete(macPath);
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Process.Start("open", $"\"{path}\"");
}
private void ShouldButtonPortBeEnabled(object sender, EventArgs e) if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, handler));
if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, handler));
if (checkboxMac.Checked.Value)
{ {
// any checkbox + selected mod string modName = "foo";//MessageBox.Show()
if ((checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value) await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, handler));
&& !String.IsNullOrWhiteSpace(filePicker.FilePath))
buttonPort.Enabled = true;
else
buttonPort.Enabled = false;
} }
private void DisableAllElements() labelProgress.Text = "Done!";
{ OpenFolder(currentDir);
checkboxAndroid.Enabled = false;
checkboxLinux.Enabled = false;
checkboxMac.Enabled = false;
filePicker.Enabled = false;
buttonPort.Enabled = false;
}
private void EnableAllElements() EnableAllElements();
{ }
checkboxAndroid.Enabled = true;
checkboxLinux.Enabled = true; public static void OpenFolder(string path)
checkboxMac.Enabled = true; {
filePicker.Enabled = true; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Process.Start("explorer.exe", $"\"{path}\"");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Process.Start("xdg-open", $"\"{path}\"");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Process.Start("open", $"\"{path}\"");
}
private void ShouldButtonPortBeEnabled(object sender, EventArgs e)
{
// any checkbox + selected mod
if ((checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value)
&& !String.IsNullOrWhiteSpace(filePicker.FilePath))
buttonPort.Enabled = true; buttonPort.Enabled = true;
} else
buttonPort.Enabled = false;
}
private Label labelSelectMod = new Label private void DisableAllElements()
{ {
Text = "Select Mod:" checkboxAndroid.Enabled = false;
}; checkboxLinux.Enabled = false;
private FilePicker filePicker = new FilePicker() checkboxMac.Enabled = false;
{ filePicker.Enabled = false;
Filters = { new FileFilter("Zip file", "*.zip") } buttonPort.Enabled = false;
}; }
private void EnableAllElements()
{
checkboxAndroid.Enabled = true;
checkboxLinux.Enabled = true;
checkboxMac.Enabled = true;
filePicker.Enabled = true;
buttonPort.Enabled = true;
}
private CheckBox checkboxLinux = new CheckBox() private Label labelSelectMod = new Label
{ {
Text = "Linux" Text = "Select Mod:"
}; };
private CheckBox checkboxAndroid = new CheckBox() private FilePicker filePicker = new FilePicker()
{ {
Text = "Android" Filters = { new FileFilter("Zip file", "*.zip") }
}; };
private CheckBox checkboxMac = new CheckBox()
{
Text = "Mac"
};
private Button buttonPort = new Button() private CheckBox checkboxLinux = new CheckBox()
{ {
Text = "Port!", Text = "Linux"
Enabled = false };
}; private CheckBox checkboxAndroid = new CheckBox()
{
Text = "Android"
};
private CheckBox checkboxMac = new CheckBox()
{
Text = "Mac"
};
private Label labelProgress = new Label() private Button buttonPort = new Button()
{ {
Text = "Info: " Text = "Port!",
}; Enabled = false
} };
private Label labelProgress = new Label()
{
Text = "Info: "
};
} }
Loading…
Cancel
Save