-
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.
- Loading branch information
Showing
3 changed files
with
59 additions
and
6 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
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
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,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 GitHub Actions / Build, Test, and Upload Builds (macos-latest)
Check warning on line 48 in Refresher/UI/PipelineForm.cs GitHub Actions / Build, Test, and Upload Builds (macos-latest)
Check warning on line 48 in Refresher/UI/PipelineForm.cs GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)
Check warning on line 48 in Refresher/UI/PipelineForm.cs GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)
Check warning on line 48 in Refresher/UI/PipelineForm.cs GitHub Actions / Build, Test, and Upload Builds (ubuntu-latest)
|
||
}); | ||
} | ||
} |