Browse Source

Add tree foreground classes + model re-filter hook for the migration

Groundwork for migrating the assembly tree onto SharpTreeView: the shared item theme now binds the autoloaded / non-public foreground classes (dimmed unless the row is selected), and ILSpyTreeNode gains RefreshRealizedFilter to re-apply the API-level filter to realised nodes in place when ShowApiLevel toggles -- the TreeFlattener then drops anything newly hidden, replacing ProDataGrid's ChildrenSelector filter.
pull/3755/head
Siegfried Pammer 1 month ago
parent
commit
27770dfbfd
  1. 14
      ILSpy/Controls/TreeView/SharpTreeView.axaml
  2. 16
      ILSpy/TreeNodes/ILSpyTreeNode.cs

14
ILSpy/Controls/TreeView/SharpTreeView.axaml

@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
<Setter Property="Padding" Value="2,0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="ContentTemplate">
<DataTemplate x:DataType="ilspyx:SharpTreeNode">
<DataTemplate x:CompileBindings="False">
<StackPanel Orientation="Horizontal" Background="Transparent"
ToolTip.Tip="{Binding ToolTip}">
<!-- Indent spacer = Level * step. -->
@ -49,10 +49,20 @@ @@ -49,10 +49,20 @@
<Border Width="13" IsVisible="{Binding !ShowExpander}" />
<Image Source="{Binding Icon}" Width="16" Height="16"
Margin="0,0,4,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" />
<TextBlock Text="{Binding Text}" VerticalAlignment="Center"
Classes.autoloaded="{Binding IsAutoLoaded}"
Classes.nonPublicAPI="{Binding IsNonPublicAPI}" />
</StackPanel>
</DataTemplate>
</Setter>
<!-- Dim auto-loaded assemblies / non-public API, but never let the dim colour bleed
through a selected row's highlight (mirrors the old DataGridRow:not(:selected) rule). -->
<Style Selector="^:not(:selected) TextBlock.autoloaded">
<Setter Property="Foreground" Value="{DynamicResource ILSpy.TreeAutoloadedForeground}" />
</Style>
<Style Selector="^:not(:selected) TextBlock.nonPublicAPI">
<Setter Property="Foreground" Value="{DynamicResource ILSpy.TreeNonPublicForeground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

16
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -240,5 +240,21 @@ namespace ILSpy.TreeNodes @@ -240,5 +240,21 @@ namespace ILSpy.TreeNodes
foreach (var child in Children.OfType<ILSpyTreeNode>())
ApplyFilterToChild(child);
}
/// <summary>
/// Re-applies the filter to already-realised children (without forcing lazy children to
/// load) and recurses into realised subtrees. Called when ShowApiLevel changes so the
/// visible tree updates in place -- a <c>TreeFlattener</c> then drops anything newly hidden.
/// </summary>
internal void RefreshRealizedFilter()
{
if (LazyLoading)
return;
foreach (var child in Children.OfType<ILSpyTreeNode>())
{
ApplyFilterToChild(child);
child.RefreshRealizedFilter();
}
}
}
}

Loading…
Cancel
Save