diff --git a/src/Views/CommandLogTime.cs b/src/Views/CommandLogTime.cs index 6dec67b6..0810ba41 100644 --- a/src/Views/CommandLogTime.cs +++ b/src/Views/CommandLogTime.cs @@ -1,7 +1,6 @@ using System; using System.Threading; -using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Threading; @@ -10,15 +9,6 @@ namespace SourceGit.Views { public class CommandLogTime : TextBlock { - public static readonly StyledProperty LogProperty = - AvaloniaProperty.Register(nameof(Log)); - - public ViewModels.CommandLog Log - { - get => GetValue(LogProperty); - set => SetValue(LogProperty, value); - } - protected override Type StyleKeyOverride => typeof(TextBlock); protected override void OnUnloaded(RoutedEventArgs e) @@ -27,19 +17,16 @@ namespace SourceGit.Views StopTimer(); } - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + protected override void OnDataContextChanged(EventArgs e) { - base.OnPropertyChanged(change); + base.OnDataContextChanged(e); - if (change.Property == LogProperty) - { - StopTimer(); + StopTimer(); - if (change.NewValue is ViewModels.CommandLog log) - SetupCommandLog(log); - else - Text = string.Empty; - } + if (DataContext is ViewModels.CommandLog log) + SetupCommandLog(log); + else + Text = string.Empty; } private void SetupCommandLog(ViewModels.CommandLog log) @@ -74,12 +61,12 @@ namespace SourceGit.Views var duration = endTime - log.StartTime; if (duration.TotalMinutes >= 1) - return $"{log.StartTime:T} ({duration.TotalMinutes:G3} minutes)"; + return $"{duration.TotalMinutes:G3} min"; if (duration.TotalSeconds >= 1) - return $"{log.StartTime:T} ({duration.TotalSeconds:G3} s)"; + return $"{duration.TotalSeconds:G3} s"; - return $"{log.StartTime:T} ({duration.TotalMilliseconds:G3} ms)"; + return $"{duration.TotalMilliseconds:G3} ms"; } private Timer _refreshTimer = null; diff --git a/src/Views/ViewLogs.axaml b/src/Views/ViewLogs.axaml index a3b9e240..bba5da8e 100644 --- a/src/Views/ViewLogs.axaml +++ b/src/Views/ViewLogs.axaml @@ -78,8 +78,10 @@ - + + + + + -