Browse Source

Revert: Add 'Sort Assemblies' command to view menu

revert 359d04b3b6
This implementation caused problems (and occasional crashes 😊) in
selection & history handling
pull/576/head
Ed Harvey 10 years ago
parent
commit
6d5e8ec473
  1. 45
      ILSpy/Commands/SortListCommand.cs
  2. 2
      ILSpy/ILSpy.csproj
  3. 1
      ILSpy/Images/Images.cs
  4. BIN
      ILSpy/Images/Sort.png
  5. 24
      ILSpy/LoadedAssembly.cs

45
ILSpy/Commands/SortListCommand.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(Menu = "_View", Header = "_Sort Assemblies", MenuIcon = "Images/Sort.png", MenuCategory = "List", MenuOrder = 3)]
sealed class SortListCommand : SimpleCommand
{
public override void Execute(object parameter)
{
//cache a (copied) list of the currently selected nodes
var selectedCache = MainWindow.Instance.SelectedNodes.Where(n => n is AssemblyTreeNode).Select(n => ((AssemblyTreeNode)n).LoadedAssembly).ToList();
MainWindow.Instance.CurrentAssemblyList.Sort(new LoadedAssembly.NameComparer());
MainWindow.Instance.treeView.SetSelectedNodes(GetNewSelectedNodes(selectedCache));
}
private IEnumerable<ILSpyTreeNode> GetNewSelectedNodes(IEnumerable<LoadedAssembly> cache)
{
foreach (var assy in cache) {
yield return MainWindow.Instance.AssemblyListTreeNode.FindAssemblyNode(assy);
}
}
}
}

2
ILSpy/ILSpy.csproj

@ -106,7 +106,6 @@ @@ -106,7 +106,6 @@
<Compile Include="CommandLineArguments.cs" />
<Compile Include="Commands\ExitCommand.cs" />
<Compile Include="Commands\CommandWrapper.cs" />
<Compile Include="Commands\SortListCommand.cs" />
<Compile Include="Commands\OpenListCommand.cs" />
<Compile Include="Controls\MarkupExtensions.cs" />
<Compile Include="Controls\ResourceObjectTable.xaml.cs">
@ -365,7 +364,6 @@ @@ -365,7 +364,6 @@
<Resource Include="Images\OverlayStatic.png" />
<Resource Include="Images\VirtualMethod.png" />
<Resource Include="Images\PInvokeMethod.png" />
<Resource Include="Images\Sort.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj">

1
ILSpy/Images/Images.cs

@ -42,7 +42,6 @@ namespace ICSharpCode.ILSpy @@ -42,7 +42,6 @@ namespace ICSharpCode.ILSpy
public static readonly BitmapImage Delete = LoadBitmap("Delete");
public static readonly BitmapImage Search = LoadBitmap("Search");
public static readonly BitmapImage Sort = LoadBitmap("Sort");
public static readonly BitmapImage Assembly = LoadBitmap("Assembly");
public static readonly BitmapImage AssemblyWarning = LoadBitmap("AssemblyWarning");

BIN
ILSpy/Images/Sort.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

24
ILSpy/LoadedAssembly.cs

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Threading;
@ -297,28 +296,5 @@ namespace ICSharpCode.ILSpy @@ -297,28 +296,5 @@ namespace ICSharpCode.ILSpy
assemblyTask.Wait();
}
public class NameComparer : Comparer<LoadedAssembly>
{
public override int Compare(LoadedAssembly x, LoadedAssembly y)
{
// sort order:
// explicitly loaded assemblies
// auto-loaded assemblies
// assemblies with errors
if (x.IsLoaded && y.HasLoadError)
return -1;
if (x.HasLoadError && y.IsLoaded)
return 1;
if (!x.IsAutoLoaded && y.IsAutoLoaded)
return -1;
if (x.IsAutoLoaded && !y.IsAutoLoaded)
return 1;
// within above groups, sort by assembly name
return x.Text.CompareTo(y.Text);
}
}
}
}

Loading…
Cancel
Save