Skip to content

Commit d5a7c37

Browse files
committed
2 parents 95f9d03 + 4ccb573 commit d5a7c37

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/ViewModels/SimulateViewModel.cs

Lines changed: 20 additions & 8 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,23 +92,33 @@ 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);
9799
var result = await _sim.RunAsync(Config, progress);
98100
if (result.Success)
99101
{
100102
Status = _loc.T("Sim.Completed", result.Elapsed.TotalSeconds);
101-
L($"Result: {(result.Success ? "PASS" : "FAIL")}");
102-
foreach (var note in result.Notes) L($" Note: {note}");
103-
var reportPath = await _report.GenerateAsync(Config, result, Config.OutputDirectory);
104-
L(_loc.T("Sim.Report", reportPath));
105103
}
106-
else { Status = _loc.T("Sim.Failed", result.ErrorMessage ?? "unknown"); }
104+
else
105+
{
106+
Status = _loc.T("Sim.Failed", result.ErrorMessage ?? "unknown");
107+
}
108+
L($"Result: {(result.Success ? "PASS" : "FAIL")}");
109+
foreach (var note in result.Notes) L($" Note: {note}");
110+
var reportPath = await _report.GenerateAsync(Config, result, Config.OutputDirectory);
111+
L(_loc.T("Sim.Report", reportPath));
112+
}
113+
catch (Exception ex)
114+
{
115+
Status = $"Error: {ex.Message}";
116+
L($"FATAL: {ex}");
117+
var failResult = new SimulationResult { Success = false, ErrorMessage = ex.Message };
118+
var reportPath = await _report.GenerateAsync(Config, failResult, Config.OutputDirectory);
119+
L(_loc.T("Sim.Report", reportPath));
107120
}
108-
catch (Exception ex) { Status = $"Error: {ex.Message}"; L($"FATAL: {ex}"); }
109-
finally { IsRunning = false; }
121+
finally { IsRunning = false; StartButtonText = _loc["Sim.Start"]; }
110122
}
111123

112124
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)