-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GUI as well as general code improvements and structural cha…
…nges (#22)
- Loading branch information
Showing
32 changed files
with
588 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ jobs: | |
env: | ||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} | ||
|
||
- name: Run QDNET Scan | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json | ||
|
||
build: | ||
name: Build and Upload Artifacts | ||
runs-on: ubuntu-latest | ||
|
@@ -36,30 +41,47 @@ jobs: | |
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Restore Dependencies | ||
run: dotnet restore | ||
|
||
- name: Get Commit Hash | ||
id: hash | ||
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Publish for Windows x64 | ||
run: dotnet publish -c Release -r win-x64 --self-contained | ||
- name: Publish for Linux x64 | ||
run: dotnet publish -c Release -r linux-x64 --self-contained | ||
- name: Publish CLI for Windows x64 | ||
run: dotnet publish -c Release -r win-x64 --self-contained PLRPC | ||
- name: Publish CLI for Linux x64 | ||
run: dotnet publish -c Release -r linux-x64 --self-contained PLRPC | ||
- name: Publish GUI for Windows x64 | ||
run: dotnet publish -c Release -r win-x64 --self-contained PLRPC.GUI.Windows | ||
- name: Publish GUI for Linux x64 | ||
run: dotnet publish -c Release -r linux-x64 --self-contained PLRPC.GUI.Linux | ||
|
||
- name: Upload Windows x64 build | ||
- name: Upload Windows x64 CLI build | ||
uses: actions/[email protected] | ||
with: | ||
name: PLRPC Windows x64 [${{ steps.hash.outputs.hash }}] | ||
name: PLRPC CLI Windows x64 [${{ steps.hash.outputs.hash }}] | ||
path: "/home/runner/work/PLRPC/PLRPC/PLRPC/bin/Release/net7.0/win-x64/publish/" | ||
if-no-files-found: error | ||
retention-days: 3 | ||
- name: Upload Linux x64 build | ||
- name: Upload Linux x64 CLI build | ||
uses: actions/[email protected] | ||
with: | ||
name: PLRPC Linux x64 [${{ steps.hash.outputs.hash }}] | ||
name: PLRPC CLI Linux x64 [${{ steps.hash.outputs.hash }}] | ||
path: "/home/runner/work/PLRPC/PLRPC/PLRPC/bin/Release/net7.0/linux-x64/publish/" | ||
if-no-files-found: error | ||
retention-days: 3 | ||
- name: Upload Windows x64 GUI build | ||
uses: actions/[email protected] | ||
with: | ||
name: PLRPC GUI Windows x64 [${{ steps.hash.outputs.hash }}] | ||
path: "/home/runner/work/PLRPC/PLRPC/PLRPC.GUI.Windows/bin/Release/net7.0-windows/win-x64/publish/" | ||
if-no-files-found: error | ||
retention-days: 3 | ||
- name: Upload Linux x64 GUI build | ||
uses: actions/[email protected] | ||
with: | ||
name: PLRPC GUI Linux x64 [${{ steps.hash.outputs.hash }}] | ||
path: "/home/runner/work/PLRPC/PLRPC/PLRPC.GUI.Linux/bin/Release/net7.0/linux-x64/publish/" | ||
if-no-files-found: error | ||
retention-days: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>LBPUnion.PLRPC.GUI</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<SelfContained>true</SelfContained> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Eto.Platform.Gtk" Version="2.7.5"/> | ||
<ProjectReference Include="..\PLRPC.GUI\PLRPC.GUI.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace LBPUnion.PLRPC.GUI; | ||
|
||
public static class Program | ||
{ | ||
[STAThread] | ||
public static void Main() | ||
{ | ||
Gui.Initialize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>LBPUnion.PLRPC.GUI</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<SelfContained>true</SelfContained> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Eto.Platform.Windows" Version="2.7.5"/> | ||
<ProjectReference Include="..\PLRPC.GUI\PLRPC.GUI.csproj"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App.WindowsForms" IsWindowsOnly="false"/> | ||
<KnownFrameworkReference Update="Microsoft.WindowsDesktop.App" IsWindowsOnly="false"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace LBPUnion.PLRPC.GUI; | ||
|
||
public static class Program | ||
{ | ||
[STAThread] | ||
public static void Main() | ||
{ | ||
Gui.Initialize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
using System.Text; | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
using LBPUnion.PLRPC.Helpers; | ||
using LBPUnion.PLRPC.Types.Logging; | ||
using Serilog; | ||
|
||
namespace LBPUnion.PLRPC.GUI.Forms; | ||
|
||
public class MainForm : Form | ||
{ | ||
private static readonly TextBox username; | ||
private static readonly TextBox serverUrl; | ||
private static readonly TextBox applicationId; | ||
|
||
public MainForm() | ||
{ | ||
this.Title = "PLRPC"; | ||
this.ClientSize = new Size(400, -1); | ||
this.Resizable = false; | ||
|
||
this.Content = this.tableLayout; | ||
|
||
Log.Logger = Program.Logger; | ||
} | ||
|
||
private static readonly GroupBox configurationEntries = new() | ||
{ | ||
Text = Strings.MainForm.Configuration, | ||
Content = new TableLayout | ||
{ | ||
Padding = new Padding(3, 3, 3, 3), | ||
Spacing = new Size(3, 3), | ||
Rows = | ||
{ | ||
new TableRow(new List<TableCell> | ||
{ | ||
new(new Label | ||
{ | ||
Text = Strings.MainForm.Username, | ||
}), | ||
new(username = new TextBox()), | ||
}), | ||
new TableRow(new List<TableCell> | ||
{ | ||
new(new Label | ||
{ | ||
Text = Strings.MainForm.ServerUrl, | ||
}), | ||
new(serverUrl = new TextBox | ||
{ | ||
Text = "https://lighthouse.lbpunion.com/", | ||
Enabled = false, | ||
}), | ||
}), | ||
new TableRow(new List<TableCell> | ||
{ | ||
new(new Label | ||
{ | ||
Text = Strings.MainForm.ApplicationId, | ||
}), | ||
new(applicationId = new TextBox | ||
{ | ||
Text = "1060973475151495288", | ||
Enabled = false, | ||
}), | ||
}), | ||
}, | ||
}, | ||
}; | ||
|
||
private static readonly Button connectButton = new(InitializeClientHandler) | ||
{ | ||
Text = Strings.MainForm.Connect, | ||
}; | ||
|
||
private static readonly Button unlockDefaultsButton = new(UnlockDefaultsHandler) | ||
{ | ||
Text = Strings.MainForm.UnlockDefaults, | ||
}; | ||
|
||
private readonly TableLayout tableLayout = new() | ||
{ | ||
Padding = new Padding(10, 10, 10, 10), | ||
Spacing = new Size(5, 5), | ||
Rows = | ||
{ | ||
new TableRow(configurationEntries), | ||
new TableRow(connectButton), | ||
new TableRow(unlockDefaultsButton), | ||
}, | ||
}; | ||
|
||
private static async void InitializeClientHandler(object sender, EventArgs eventArgs) | ||
{ | ||
List<TextBox> arguments = new() | ||
{ | ||
serverUrl, | ||
username, | ||
applicationId, | ||
}; | ||
|
||
switch (arguments) | ||
{ | ||
case not null when arguments.Any(a => string.IsNullOrWhiteSpace(a.Text)): | ||
{ | ||
MessageBox.Show(Strings.MainForm.BlankFieldsError, MessageBoxButtons.OK, MessageBoxType.Error); | ||
return; | ||
} | ||
case not null when !ValidationHelper.IsValidUsername(username.Text): | ||
{ | ||
MessageBox.Show(Strings.MainForm.InvalidUsernameError, MessageBoxButtons.OK, MessageBoxType.Error); | ||
return; | ||
} | ||
case not null when !ValidationHelper.IsValidUrl(serverUrl.Text): | ||
{ | ||
MessageBox.Show(Strings.MainForm.InvalidUrlError, MessageBoxButtons.OK, MessageBoxType.Error); | ||
return; | ||
} | ||
} | ||
|
||
try | ||
{ | ||
// Text changes | ||
connectButton.Text = Strings.MainForm.Connected; | ||
|
||
// Button states | ||
connectButton.Enabled = false; | ||
unlockDefaultsButton.Enabled = false; | ||
|
||
// Field states | ||
serverUrl.Enabled = false; | ||
username.Enabled = false; | ||
applicationId.Enabled = false; | ||
|
||
await Program.InitializeLighthouseClient(serverUrl.Text.Trim('/'), username.Text, applicationId.Text); | ||
} | ||
catch (Exception exception) | ||
{ | ||
StringBuilder exceptionBuilder = new(); | ||
|
||
exceptionBuilder.AppendLine($"{Strings.MainForm.InitializationError}\n"); | ||
exceptionBuilder.AppendLine($"{exception.Message}\n"); | ||
exceptionBuilder.AppendLine($"{exception.Source}"); | ||
|
||
Log.Error(exception, "{@Area}: Failed to initialize the client", | ||
LogArea.LighthouseClient); | ||
|
||
MessageBox.Show(exceptionBuilder.ToString(), MessageBoxButtons.OK, MessageBoxType.Error); | ||
} | ||
} | ||
|
||
private static void UnlockDefaultsHandler(object sender, EventArgs eventArgs) | ||
{ | ||
// Text changes | ||
unlockDefaultsButton.Text = Strings.MainForm.UnlockedDefaults; | ||
|
||
// Button states | ||
unlockDefaultsButton.Enabled = false; | ||
|
||
// Field states | ||
serverUrl.Enabled = true; | ||
applicationId.Enabled = true; | ||
|
||
MessageBox.Show(Strings.MainForm.UnlockedDefaultsWarning, | ||
"Warning", | ||
MessageBoxButtons.OK, | ||
MessageBoxType.Warning); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Eto.Forms; | ||
using LBPUnion.PLRPC.GUI.Forms; | ||
|
||
namespace LBPUnion.PLRPC.GUI; | ||
|
||
public static class Gui | ||
{ | ||
public static void Initialize() | ||
{ | ||
new Application().Run(new MainForm()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<SelfContained>true</SelfContained> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>LBPUnion.PLRPC.GUI</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>disable</Nullable> | ||
<SelfContained>true</SelfContained> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog" Version="3.0.1"/> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/> | ||
<PackageReference Include="Eto.Forms" Version="2.7.5"/> | ||
<ProjectReference Include="..\PLRPC\PLRPC.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace LBPUnion.PLRPC.GUI.Strings; | ||
|
||
public static class MainForm | ||
{ | ||
public const string Configuration = "Configuration"; | ||
public const string Username = "Username"; | ||
public const string ServerUrl = "Server URL"; | ||
public const string ApplicationId = "Application ID"; | ||
public const string Connect = "Connect"; | ||
public const string Connected = "Connected"; | ||
public const string UnlockDefaults = "Unlock Defaults"; | ||
public const string UnlockedDefaults = "Unlocked Defaults"; | ||
public const string BlankFieldsError = "Please fill in all fields and try again."; | ||
public const string InitializationError = "An error occurred while initializing the PLRPC client."; | ||
public const string InvalidUrlError = "The URL specified is in an invalid format. Please try again."; | ||
public const string InvalidUsernameError = "The username specified is invalid. Please try again."; | ||
public const string UnlockedDefaultsWarning = "You have just unlocked defaults. Support will not be provided whilst using modified defaults. Continue at your own risk."; | ||
} |
Oops, something went wrong.