From 4885299816d5300107c1b1dfdde24866ca91b93e Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 25 Oct 2017 22:03:37 +0200 Subject: [PATCH] Fix #582: Collapse All button for the assemblies list --- ILSpy/Commands/SortAssemblyListCommand.cs | 24 +++++++++++++++++++++- ILSpy/ILSpy.csproj | 1 + ILSpy/Images/CollapseAll.png | Bin 0 -> 436 bytes 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ILSpy/Images/CollapseAll.png diff --git a/ILSpy/Commands/SortAssemblyListCommand.cs b/ILSpy/Commands/SortAssemblyListCommand.cs index 2020cf21d..3f8bc3920 100644 --- a/ILSpy/Commands/SortAssemblyListCommand.cs +++ b/ILSpy/Commands/SortAssemblyListCommand.cs @@ -18,12 +18,13 @@ using System; using System.Collections.Generic; +using ICSharpCode.TreeView; namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(Menu = "_View", Header = "Sort assembly list by name", MenuIcon = "Images/Sort.png", MenuCategory = "View")] [ExportToolbarCommand(ToolTip = "Sort assembly list by name", ToolbarIcon = "Images/Sort.png", ToolbarCategory = "View")] - class SortAssemblyListCommand : SimpleCommand, IComparer + sealed class SortAssemblyListCommand : SimpleCommand, IComparer { public override void Execute(object parameter) { @@ -36,4 +37,25 @@ namespace ICSharpCode.ILSpy return string.Compare(x.ShortName, y.ShortName, StringComparison.CurrentCulture); } } + + [ExportMainMenuCommand(Menu = "_View", Header = "Collapse all tree nodes", MenuIcon = "Images/CollapseAll.png", MenuCategory = "View")] + [ExportToolbarCommand(ToolTip = "Collapse all tree nodes", ToolbarIcon = "Images/CollapseAll.png", ToolbarCategory = "View")] + sealed class CollapseAllCommand : SimpleCommand + { + public override void Execute(object parameter) + { + using (MainWindow.Instance.treeView.LockUpdates()) + CollapseChildren(MainWindow.Instance.treeView.Root); + + void CollapseChildren(SharpTreeNode node) + { + foreach (var child in node.Children) { + if (!child.IsExpanded) + continue; + CollapseChildren(child); + child.IsExpanded = false; + } + } + } + } } diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 9411c6544..304e82ca8 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -346,6 +346,7 @@ + diff --git a/ILSpy/Images/CollapseAll.png b/ILSpy/Images/CollapseAll.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23dbc8101d5b29ea77efc18dcb648e729250bb GIT binary patch literal 436 zcmV;l0ZaagP)-;1p#7!9TZhash#k@NvuL0%D|VN{Qd0z z^lX1SLI~7xKp4xzi%qPLd%_tfVu>7I&SukIw+pY=L*RJ^8@`XA--k!JN9%i&$w^Zr zlu}K;dlkpn9-r1z=I1rO#~qILX*mDsz>T5^VmQQNv1s+)B?qV;9OGbFpe#!iMS(O; zTLr=}B!SXx6#&6;9E?VzmEtVRQ17t{bo6}?T-QaO=PLrt>pi8i3rHye26&LxBWS)& zpmD%QSb7~3hW`f#onIa3F0eQ-e2akiy8~%Gf@mC6Rb_QxcqP9aygfoN$(O@T*7N~$ zI=2XDUP*!XC*U^L4t!b|&^X{lL2u2UrY*P^@R0{pyhGDm3lMm6og~RIZnmD+e&+e> eOI;&B1sDMOI=@rxNH9SF0000