Skip to content

Commit

Permalink
Fine tuning DependencyTreeControl
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Oct 20, 2023
1 parent 8e964d1 commit b458871
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/NuGetMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="NuGet.Protocol" Version="6.7.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="Throttle.Fody" Version="1.7.0" PrivateAssets="all" />
<PackageReference Include="TomsToolbox.Wpf.Styles" Version="2.9.0" />
<PackageReference Include="TomsToolbox.Wpf.Styles" Version="2.9.1" />
<PackageReference Include="VSIX-SdkProjectAdapter" Version="3.0.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
Expand Down
94 changes: 48 additions & 46 deletions src/View/DependencyTree/DependencyTreeControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@
<ResourceDictionary Source="/NuGetMonitor;component/Resources/VSColorScheme.xaml" />
</ResourceDictionary.MergedDictionaries>
<Thickness x:Key="NodeMargin">4</Thickness>
<Style x:Key="ExpandedNodeStyle" TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
<Style x:Key="CollapsedNodeStyle" TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="False" />
</Style>
<HierarchicalDataTemplate x:Key="NodeTemplate"
DataType="{x:Type local:ChildNode}"
ItemContainerStyle="{StaticResource ExpandedNodeStyle}"
ItemsSource="{Binding Children}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<StackPanel Orientation="Horizontal" Margin="{StaticResource NodeMargin}">
<TextBlock x:Name="Identity" Text="{Binding PackageIdentity}" />
<TextBlock Text="{Binding Issues}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
<StackPanel Orientation="Horizontal"
Margin="{StaticResource NodeMargin}">
<TextBlock x:Name="Identity"
Text="{Binding PackageIdentity}" />
<TextBlock Text="{Binding Issues}"
Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding HasChildren}" Value="False">
Expand All @@ -40,20 +45,43 @@
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="FirstLevelNodeTemplate"
DataType="{x:Type local:ChildNode}"
ItemContainerStyle="{StaticResource ExpandedNodeStyle}"
ItemsSource="{Binding Children}"
ItemTemplate="{StaticResource NodeTemplate}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<StackPanel Orientation="Horizontal" Margin="{StaticResource NodeMargin}">
<toms:HighlightingTextBlock x:Name="Identity"
Text="{Binding PackageIdentity}"
SearchText="{Binding ElementName=SearchText, Path=Text}"
HighLightBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<TextBlock Text="{Binding Issues}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
<Grid>
<TextBlock x:Name="Plain"
Visibility="Hidden"
Text="{Binding PackageIdentity}" />
<toms:HighlightingTextBlock x:Name="Highlighted"
Text="{Binding PackageIdentity}"
SearchText="{Binding ElementName=SearchText, Path=Text}"
HighLightBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
</Grid>
<TextBlock Text="{Binding Issues}"
Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=TreeViewItem}}" Value="True">
<Setter TargetName="Plain" Property="Visibility" Value="Visible" />
<Setter TargetName="Highlighted" Property="Visibility" Value="Hidden" />
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:RootNode}"
ItemContainerStyle="{StaticResource CollapsedNodeStyle}"
ItemsSource="{Binding Children}"
ItemTemplate="{StaticResource FirstLevelNodeTemplate}">
<TextBlock Margin="{StaticResource NodeMargin}" FontWeight="Bold">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} [{1}]">
<MultiBinding.Bindings>
<Binding Path="ProjectName" />
<Binding Path="TargetFramework" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</HierarchicalDataTemplate>
</ResourceDictionary>
</UserControl.Resources>
Expand All @@ -73,35 +101,9 @@
<TreeView x:Name="TreeView"
BorderThickness="0 1 0 0"
ItemsSource="{Binding TransitivePackages}"
ItemContainerStyle="{StaticResource ExpandedNodeStyle}"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:RootNode}"
ItemsSource="{Binding Children}"
ItemTemplate="{StaticResource FirstLevelNodeTemplate}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="False" />
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<TextBlock Margin="{StaticResource NodeMargin}" FontWeight="Bold">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} [{1}]">
<MultiBinding.Bindings>
<Binding Path="ProjectName" />
<Binding Path="TargetFramework" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
VirtualizingStackPanel.VirtualizationMode="Recycling" />
</DockPanel>
<toms:LoadingIndicator IsActive="{Binding IsLoading}" Header="Loading..." d:IsHidden="True" />
</Grid>
Expand Down

0 comments on commit b458871

Please sign in to comment.