Skip to content

Commit

Permalink
general: fixed progress window count up timer
Browse files Browse the repository at this point in the history
  • Loading branch information
stojy committed Nov 7, 2022
1 parent 912c69c commit d20a924
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ClrVpin/Shared/Progress.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<StackPanel Margin="10" Width="600" >
<ProgressBar Value="{Binding Percentage}" Height="20" />
<DockPanel Margin="0, 10, 0, 0" LastChildFill="True">
<TextBlock DockPanel.Dock="Right" Text="{Binding DisplayDurationTotalSeconds, StringFormat={}{0:f0}s}"/>
<TextBlock DockPanel.Dock="Right" Text="{Binding DisplayDurationInSeconds, StringFormat={}{0:f0}s}"/>
<TextBlock Text="{Binding Status}" />
</DockPanel>
<TextBlock HorizontalAlignment="Left" Text="{Binding Detail}" TextTrimming="CharacterEllipsis"/>
Expand Down
5 changes: 2 additions & 3 deletions ClrVpin/Shared/ProgressViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ProgressViewModel()
}

public TimeSpan Duration => _durationStopwatch.Elapsed;
public double DisplayDurationTotalSeconds => _displayDuration.TotalSeconds;
public double DisplayDurationInSeconds { get; private set; }
public string Status { get; private set; }
public string Detail { get; private set; }
public int Percentage { get; set; }
Expand Down Expand Up @@ -54,7 +54,7 @@ public void Show(Window parentWindow)
_window.Show();

_durationStopwatch = Stopwatch.StartNew();
_timer = new Timer(_ => _displayDuration = _durationStopwatch.Elapsed);
_timer = new Timer(_ => DisplayDurationInSeconds = _durationStopwatch.Elapsed.TotalSeconds);

_timer.Change(1000, 1000);
}
Expand All @@ -78,7 +78,6 @@ public void Update(string status, float? ratioComplete = null, string detail = n
}

private readonly CancellationTokenSource _cancellationTokenSource;
private TimeSpan _displayDuration;

private Timer _timer;

Expand Down

0 comments on commit d20a924

Please sign in to comment.