From b51341609857cb912716dfbb746295ef5b1c9244 Mon Sep 17 00:00:00 2001 From: yanlinlin Date: Tue, 4 Jul 2023 09:35:28 +0000 Subject: [PATCH] Add event trigger time in DevTools. #11338 --- .../Diagnostics/ViewModels/EventTreeNode.cs | 3 ++- .../Diagnostics/ViewModels/FiredEvent.cs | 5 ++++- .../Diagnostics/Views/EventsPageView.xaml | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs index 785fd49983e..0002107ee0d 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/EventTreeNode.cs @@ -72,12 +72,13 @@ private void HandleEvent(object? sender, RoutedEventArgs e) var s = sender!; var handled = e.Handled; var route = e.Route; + var triggerTime = DateTime.Now; void handler() { if (_currentEvent == null || !_currentEvent.IsPartOfSameEventChain(e)) { - _currentEvent = new FiredEvent(e, new EventChainLink(s, handled, route)); + _currentEvent = new FiredEvent(e, new EventChainLink(s, handled, route), triggerTime); _parentViewModel.RecordedEvents.Add(_currentEvent); diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs index a9f3182bef8..1eab9afe8a2 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/FiredEvent.cs @@ -10,11 +10,12 @@ internal class FiredEvent : ViewModelBase private readonly RoutedEventArgs _eventArgs; private EventChainLink? _handledBy; - public FiredEvent(RoutedEventArgs eventArgs, EventChainLink originator) + public FiredEvent(RoutedEventArgs eventArgs, EventChainLink originator, DateTime triggerTime) { _eventArgs = eventArgs ?? throw new ArgumentNullException(nameof(eventArgs)); Originator = originator ?? throw new ArgumentNullException(nameof(originator)); AddToChain(originator); + TriggerTime = triggerTime; } public bool IsPartOfSameEventChain(RoutedEventArgs e) @@ -22,6 +23,8 @@ public bool IsPartOfSameEventChain(RoutedEventArgs e) return e == _eventArgs; } + public DateTime TriggerTime { get; } + public RoutedEvent Event => _eventArgs.RoutedEvent!; public bool IsHandled => HandledBy?.Handled == true; diff --git a/src/Avalonia.Diagnostics/Diagnostics/Views/EventsPageView.xaml b/src/Avalonia.Diagnostics/Diagnostics/Views/EventsPageView.xaml index 54c2f067098..c18b8cf003e 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Views/EventsPageView.xaml +++ b/src/Avalonia.Diagnostics/Diagnostics/Views/EventsPageView.xaml @@ -77,21 +77,23 @@ - + - + + + - + - +