Skip to content

Commit

Permalink
Form for pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Sep 19, 2024
1 parent b03e309 commit 7b9c5d8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
5 changes: 0 additions & 5 deletions Refresher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public static void Log(string message, string category = "", BreadcrumbLevel lev
[STAThread]
public static void Main(string[] args)
{
ExamplePipeline pipeline = new ExamplePipeline();
pipeline.Initialize();

pipeline.ExecuteAsync().Wait();
return;
InitializeSentry();

if (args.Length > 0)
Expand Down
9 changes: 8 additions & 1 deletion Refresher/UI/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Eto.Drawing;
using Eto.Forms;
using Refresher.Core.Pipelines;

namespace Refresher.UI;

Expand All @@ -17,10 +18,16 @@ public class MainForm : RefresherForm
new Button((_, _) => this.ShowChild<FilePatchForm>()) { Text = "File Patch (using a .ELF)" },
new Button((_, _) => this.ShowChild<EmulatorPatchForm>()) { Text = "RPCS3 Patch" },
new Button((_, _) => this.ShowChild<ConsolePatchForm>()) { Text = "PS3 Patch" },
new Button((_, _) => this.ShowChild<PSPSetupForm>()) { Text = "PSP Setup" }
new Button((_, _) => this.ShowChild<PSPSetupForm>()) { Text = "PSP Setup" },
this.PipelineButton<ExamplePipeline>()
);

layout.Spacing = 5;
layout.HorizontalContentAlignment = HorizontalAlignment.Stretch;
}

private Button PipelineButton<TPipeline>() where TPipeline : Pipeline, new()
{
return new Button((_, _) => this.ShowChild<PipelineForm<TPipeline>>()) { Text = typeof(TPipeline).Name };
}
}
51 changes: 51 additions & 0 deletions Refresher/UI/PipelineForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Eto.Drawing;
using Eto.Forms;
using Refresher.Core.Pipelines;

namespace Refresher.UI;

public class PipelineForm<TPipeline> : RefresherForm where TPipeline : Pipeline, new()
{
private TPipeline? _pipeline;

private ProgressBar _progressBar;

public PipelineForm() : base(typeof(TPipeline).Name, new Size(700, 1), false)
{
this.InitializePipeline();

this.Content = new StackLayout([
new Button(this.ExecutePipeline),
this._progressBar = new ProgressBar(),
]);

Thread progressThread = new(() =>
{
while (!this.IsDisposed && !Application.Instance.IsDisposed)
{
Application.Instance.Invoke(() =>
{
this._progressBar.Value = (int)((this._pipeline?.Progress ?? 0) * 100);
this._progressBar.Enabled = this._pipeline?.State == PipelineState.Running;
});
Thread.Sleep(100);
}
});

progressThread.Start();
}

private void InitializePipeline()
{
this._pipeline = new TPipeline();
this._pipeline.Initialize();
}

private void ExecutePipeline(object? sender, EventArgs e)
{
Task.Run(async () =>
{
await this._pipeline.ExecuteAsync();

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (macos-latest)

Dereference of a possibly null reference.

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (macos-latest)

Dereference of a possibly null reference.

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 48 in Refresher/UI/PipelineForm.cs

View workflow job for this annotation

GitHub Actions / Build, Test, and Upload Builds (windows-latest)

Dereference of a possibly null reference.
});
}
}

0 comments on commit 7b9c5d8

Please sign in to comment.