GUI: Add Select all/none buttons to namespace tree selector

This commit is contained in:
Katy Coe
2020-09-09 17:10:08 +02:00
parent b327fdf341
commit deba3035fc
2 changed files with 24 additions and 1 deletions

View File

@@ -231,6 +231,12 @@
<DockPanel DockPanel.Dock="Right" Width="230">
<Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Namespaces</Label>
<TextBlock DockPanel.Dock="Top" TextWrapping="WrapWithOverflow" Margin="10,0,5,5">This only applies to C# prototypes output</TextBlock>
<StackPanel DockPanel.Dock="Top" Margin="10,0,5,5" Orientation="Horizontal">
<Button Margin="2,0,5,0" Width="103" Click="SelectAllNamespaces_Click">Select all</Button>
<Button Width="103" Click="SelectNoneNamespaces_Click">Select none</Button>
</StackPanel>
<TreeView DockPanel.Dock="Bottom" Name="trvNamespaces" ItemTemplate="{StaticResource NamespaceTreeItemTemplate}" Width="210" Margin="10,5,5,5"></TreeView>
</DockPanel>

View File

@@ -22,7 +22,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using Il2CppInspector;
using Il2CppInspector;
using Il2CppInspector.Cpp;
using Il2CppInspector.GUI;
using Il2CppInspector.Model;
@@ -573,6 +573,23 @@ namespace Il2CppInspectorGUI
await LoadBinaryAsync(files[0]);
}
}
private void SelectAllNamespaces_Click(object sender, RoutedEventArgs e) {
var tree = (IEnumerable<CheckboxNode>) trvNamespaces.ItemsSource;
// Breadth-first selection
for (var level = tree; level.Any(); level = level.Where(node => node.Children != null).SelectMany(node => node.Children))
foreach (var item in level)
item.IsChecked = true;
}
private void SelectNoneNamespaces_Click(object sender, RoutedEventArgs e) {
var tree = (IEnumerable<CheckboxNode>) trvNamespaces.ItemsSource;
// Only need to clear the top level because this will clear all the children automatically
foreach (var topLevelItem in tree)
topLevelItem.IsChecked = false;
}
}
// Replacement for TreeViewItem that includes checkbox state