Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event trigger time in DevTools. #11338 #12036

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ 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)
{
return e == _eventArgs;
}

public DateTime TriggerTime { get; }

public RoutedEvent Event => _eventArgs.RoutedEvent!;

public bool IsHandled => HandledBy?.Handled == true;
Expand Down
10 changes: 6 additions & 4 deletions src/Avalonia.Diagnostics/Diagnostics/Views/EventsPageView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,23 @@
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Classes.handled="{Binding IsHandled}">
<Grid ColumnDefinitions="Auto,Auto,*,Auto">
<Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto">

<StackPanel Grid.Column="0" Spacing="2" Orientation="Horizontal" >
<TextBlock Grid.Column="0" Text="{Binding TriggerTime, StringFormat={}{0:HH:mm:ss.fff}}"/>

<StackPanel Margin="10,0,0,0" Grid.Column="1" Spacing="2" Orientation="Horizontal" >
<TextBlock Tag="{Binding Event}" DoubleTapped="NavigateTo" Text="{Binding Event.Name}" FontWeight="Bold" Classes="nav" />
<TextBlock Text="on" />
<TextBlock Tag="{Binding Originator}" DoubleTapped="NavigateTo" Text="{Binding Originator.HandlerName}" Classes="nav" />
</StackPanel>

<StackPanel Margin="2,0,0,0" Grid.Column="1" Spacing="2" Orientation="Horizontal" IsVisible="{Binding IsHandled}" >
<StackPanel Margin="2,0,0,0" Grid.Column="2" Spacing="2" Orientation="Horizontal" IsVisible="{Binding IsHandled}" >
<TextBlock Text="::" />
<TextBlock Text="Handled by" />
<TextBlock Tag="{Binding HandledBy}" DoubleTapped="NavigateTo" Text="{Binding HandledBy.HandlerName}" Classes="nav" />
</StackPanel>

<StackPanel Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="Routing (" />
<TextBlock Text="{Binding Event.RoutingStrategies}"/>
<TextBlock Text=")"/>
Expand Down