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

[DYN-7463] Mouse scroll doesn't work in the TuneUp list #60

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
91 changes: 44 additions & 47 deletions TuneUp/TuneUpWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,21 +454,20 @@
Grid.Column="0"
Grid.ColumnSpan="2">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<!-- Latest Run -->
<TextBlock
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Text="Latest run"
Visibility="{Binding LatestRunTableVisibility}" />
<DataGrid
x:Name="LatestRunTable"
AlternatingRowBackground="#434343"
ItemsSource="{Binding Path=ProfiledNodesCollectionLatestRun.View}"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
Sorting="LatestRunTable_Sorting"
Style="{StaticResource DataGridStyleTuneUpCombined}">
<StackPanel >
<!-- Latest Run -->
<TextBlock Text="Latest run"
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Visibility="{Binding LatestRunTableVisibility}"/>
<DataGrid ItemsSource="{Binding Path=ProfiledNodesCollectionLatestRun.View}"
x:Name="LatestRunTable"
Style="{StaticResource DataGridStyleTuneUpCombined}"
AlternatingRowBackground="#434343"
Sorting="LatestRunTable_Sorting"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseWheel="DataGrid_PreviewMouseWheel">
<DataGrid.Columns>
<!-- Execution Order -->
<DataGridTextColumn Width="40" Header="#">
Expand Down Expand Up @@ -514,21 +513,20 @@
Style="{StaticResource CollectionFooterTextBlockStyle}"
Text="{Binding Path=LatestGraphExecutionTime, Mode=OneWay}" />
</StackPanel>
<!-- Previous Run -->
<TextBlock
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Text="Previous run"
Visibility="{Binding PreviousRunTableVisibility}" />
<DataGrid
x:Name="PreviousRunTable"
AlternatingRowBackground="#434343"
HeadersVisibility="None"
ItemsSource="{Binding Path=ProfiledNodesCollectionPreviousRun.View}"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
Sorting="LatestRunTable_Sorting"
Style="{StaticResource DataGridStyleTuneUpCombined}">
<!-- Previous Run -->
<TextBlock Text="Previous run"
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Visibility="{Binding PreviousRunTableVisibility}"/>
<DataGrid ItemsSource="{Binding Path=ProfiledNodesCollectionPreviousRun.View}"
x:Name="PreviousRunTable"
Style="{StaticResource DataGridStyleTuneUpCombined}"
AlternatingRowBackground="#434343"
HeadersVisibility="None"
Sorting="LatestRunTable_Sorting"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseWheel="DataGrid_PreviewMouseWheel">
<DataGrid.Columns>
<!-- Execution Order -->
<DataGridTextColumn Width="40" Binding="{Binding Converter={StaticResource ExecutionOrderNumberConverter}}">
Expand Down Expand Up @@ -570,23 +568,22 @@
Style="{StaticResource CollectionFooterTextBlockStyle}"
Text="{Binding Path=PreviousGraphExecutionTime, Mode=OneWay}" />
</StackPanel>
<!-- Not Executed -->
<TextBlock
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Text="Not executed"
Visibility="{Binding NotExecutedTableVisibility}" />
<DataGrid
x:Name="NotExecutedTable"
AlternatingRowBackground="#434343"
AlternationCount="2"
CanUserSortColumns="False"
HeadersVisibility="None"
ItemsSource="{Binding Path=ProfiledNodesCollectionNotExecuted.View}"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
Sorting="NotExecutedTable_Sorting"
Style="{StaticResource DataGridStyleTuneUpCombined}">
<!-- Not Executed -->
<TextBlock Text="Not executed"
Style="{StaticResource CollectionHeaderTextBlockStyle}"
Visibility="{Binding NotExecutedTableVisibility}"/>
<DataGrid ItemsSource="{Binding Path=ProfiledNodesCollectionNotExecuted.View}"
x:Name="NotExecutedTable"
Style="{StaticResource DataGridStyleTuneUpCombined}"
AlternationCount="2"
AlternatingRowBackground="#434343"
HeadersVisibility="None"
CanUserSortColumns="False"
Sorting="NotExecutedTable_Sorting"
SelectionChanged="NodeAnalysisTable_SelectionChanged"
PreviewMouseDown="NodeAnalysisTable_PreviewMouseDown"
MouseLeave="NodeAnalysisTable_MouseLeave"
PreviewMouseWheel="DataGrid_PreviewMouseWheel">
<DataGrid.Columns>
<!-- Execution Order -->
<DataGridTextColumn Width="40" />
Expand Down
42 changes: 42 additions & 0 deletions TuneUp/TuneUpWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,48 @@ private void NodeAnalysisTable_MouseLeave(object sender, System.Windows.Input.Mo
isUserInitiatedSelection = false;
}

/// <summary>
/// Forwards the mouse wheel scroll event from the DataGrid to the parent ScrollViewer,
/// enabling scrolling when the mouse is over the DataGrid.
/// </summary>
private void DataGrid_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scrollViewer = FindParent<ScrollViewer>((DataGrid)sender);

if (scrollViewer != null)
{
if (e.Delta > 0)
{
scrollViewer.LineUp();
}
else
{
scrollViewer.LineDown();
}

e.Handled = true;
}
}

/// <summary>
/// Recursively searches the visual tree to find the parent of the specified type T for a given child element.
/// </summary>
private T FindParent<T>(DependencyObject child) where T : DependencyObject
{
DependencyObject parentObject = VisualTreeHelper.GetParent(child);
if (parentObject == null) return null;

T parent = parentObject as T;
if (parent != null)
{
return parent;
}
else
{
return FindParent<T>(parentObject);
}
}

private void RecomputeGraph_Click(object sender, RoutedEventArgs e)
{
(LatestRunTable.DataContext as TuneUpWindowViewModel).ResetProfiling();
Expand Down