Skip to content

Commit 4ccb573

Browse files
authored
feat: add indeterminate progress bar and button state during simulation (#64)
- ProgressBar IsIndeterminate visible while IsRunning - Button text changes to 'Running...' during simulation - Button disabled during execution, re-enabled after
1 parent c2502cd commit 4ccb573

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/ViewModels/SimulateViewModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public partial class SimulateViewModel : ViewModelBase
2020

2121
[ObservableProperty] private bool _isRunning;
2222
[ObservableProperty] private string _status;
23+
[ObservableProperty] private string _startButtonText;
2324
[ObservableProperty] private ObservableCollection<string> _log = new();
2425

2526
public ObservableCollection<PlatformItem> Platforms { get; } = new()
@@ -37,6 +38,7 @@ public partial class SimulateViewModel : ViewModelBase
3738
public SimulateViewModel()
3839
{
3940
_status = _loc["Patch.Ready"];
41+
_startButtonText = _loc["Sim.Start"];
4042
}
4143

4244
/// <summary>
@@ -90,7 +92,7 @@ async Task StartSimulation()
9092
if (string.IsNullOrWhiteSpace(Config.PatchFilePath)) { Status = _loc["Sim.ValidateDirs"]; return; }
9193
if (string.IsNullOrWhiteSpace(Config.OutputDirectory)) { Status = _loc["Sim.ValidateDirs"]; return; }
9294

93-
IsRunning = true; Log.Clear(); Status = _loc["Sim.Starting"];
95+
IsRunning = true; StartButtonText = "⏳ Running..."; Log.Clear(); Status = _loc["Sim.Starting"];
9496
try
9597
{
9698
var progress = new Progress<string>(L);
@@ -116,7 +118,7 @@ async Task StartSimulation()
116118
var reportPath = await _report.GenerateAsync(Config, failResult, Config.OutputDirectory);
117119
L(_loc.T("Sim.Report", reportPath));
118120
}
119-
finally { IsRunning = false; }
121+
finally { IsRunning = false; StartButtonText = _loc["Sim.Start"]; }
120122
}
121123

122124
void L(string msg) => Log.Add($"[{DateTime.Now:HH:mm:ss}] {msg}");

src/Views/SimulateView.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@
8282
</Border>
8383

8484
<!-- Run -->
85-
<Button Content="{Binding Source={x:Static svc:LocalizationService.Instance}, Path=[Sim.Start]}"
85+
<Button Content="{Binding StartButtonText}"
8686
Command="{Binding StartSimulationCommand}"
8787
IsEnabled="{Binding !IsRunning}" Height="40" FontSize="14" HorizontalAlignment="Stretch"/>
88+
<ProgressBar IsVisible="{Binding IsRunning}" IsIndeterminate="True" Height="4"/>
8889
<TextBlock Text="{Binding Status}" FontSize="13"/>
8990

9091
<!-- Log -->

0 commit comments

Comments
 (0)