Browse Source

Step 1 of #1800: Add assembly list dropdown to toolbar.

pull/1866/head
Siegfried Pammer 6 years ago
parent
commit
85f2994aa6
  1. 7
      ILSpy/AssemblyListManager.cs
  2. 5
      ILSpy/MainWindow.xaml
  3. 22
      ILSpy/MainWindow.xaml.cs
  4. 9
      ILSpy/Properties/Resources.Designer.cs
  5. 3
      ILSpy/Properties/Resources.resx
  6. 17
      ILSpy/SessionSettings.cs

7
ILSpy/AssemblyListManager.cs

@ -30,21 +30,24 @@ namespace ICSharpCode.ILSpy @@ -30,21 +30,24 @@ namespace ICSharpCode.ILSpy
/// </summary>
sealed class AssemblyListManager
{
readonly ILSpySettings spySettings;
public AssemblyListManager(ILSpySettings spySettings)
{
this.spySettings = spySettings;
XElement doc = spySettings["AssemblyLists"];
foreach (var list in doc.Elements("List")) {
AssemblyLists.Add((string)list.Attribute("name"));
}
}
public readonly ObservableCollection<string> AssemblyLists = new ObservableCollection<string>();
public ObservableCollection<string> AssemblyLists { get; } = new ObservableCollection<string>();
/// <summary>
/// Loads an assembly list from the ILSpySettings.
/// If no list with the specified name is found, the default list is loaded instead.
/// </summary>
public AssemblyList LoadList(ILSpySettings spySettings, string listName)
public AssemblyList LoadList(string listName)
{
AssemblyList list = DoLoadList(spySettings, listName);
if (!AssemblyLists.Contains(list.ListName))

5
ILSpy/MainWindow.xaml

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
xmlns:local="clr-namespace:ICSharpCode.ILSpy"
xmlns:avalondock="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
xmlns:avalondockproperties="clr-namespace:Xceed.Wpf.AvalonDock.Properties;assembly=Xceed.Wpf.AvalonDock"
xmlns:docking="clr-namespace:ICSharpCode.ILSpy.Docking"
xmlns:textview="clr-namespace:ICSharpCode.ILSpy.TextView"
xmlns:analyzers="clr-namespace:ICSharpCode.ILSpy.Analyzers"
@ -121,6 +120,10 @@ @@ -121,6 +120,10 @@
<Separator />
<!-- 'Open' toolbar category is inserted here -->
<Separator />
<ComboBox Name="assemblyListComboBox" Width="100" MaxDropDownHeight="Auto"
ItemsSource="{Binding AssemblyListManager.AssemblyLists}" ToolTip="{x:Static properties:Resources.SelectAssemblyListDropdownTooltip}"
SelectedItem="{Binding SessionSettings.ActiveAssemblyList}"/>
<Separator />
<CheckBox IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicOnly}" ToolTip="{x:Static properties:Resources.ShowPublicOnlyTypesMembers}">
<Image Width="16" Height="16" Source="{controls:XamlResource Images/ShowPublicOnly}" />
</CheckBox>

22
ILSpy/MainWindow.xaml.cs

@ -24,6 +24,7 @@ using System.Diagnostics; @@ -24,6 +24,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@ -56,6 +57,7 @@ namespace ICSharpCode.ILSpy @@ -56,6 +57,7 @@ namespace ICSharpCode.ILSpy
{
public DockWorkspace Workspace { get; set; }
public SessionSettings SessionSettings { get; set; }
public AssemblyListManager AssemblyListManager { get; set; }
}
/// <summary>
@ -113,13 +115,15 @@ namespace ICSharpCode.ILSpy @@ -113,13 +115,15 @@ namespace ICSharpCode.ILSpy
this.DataContext = new MainWindowDataContext {
Workspace = DockWorkspace.Instance,
SessionSettings = sessionSettings
SessionSettings = sessionSettings,
AssemblyListManager = assemblyListManager
};
DockWorkspace.Instance.LoadSettings(sessionSettings);
InitializeComponent();
DockWorkspace.Instance.InitializeLayout(DockManager);
sessionSettings.FilterSettings.PropertyChanged += filterSettings_PropertyChanged;
sessionSettings.PropertyChanged += SessionSettings_PropertyChanged;
InitMainMenu();
InitToolbar();
@ -128,6 +132,13 @@ namespace ICSharpCode.ILSpy @@ -128,6 +132,13 @@ namespace ICSharpCode.ILSpy
this.Loaded += MainWindow_Loaded;
}
private void SessionSettings_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "ActiveAssemblyList") {
ShowAssemblyList(sessionSettings.ActiveAssemblyList);
}
}
void SetWindowBounds(Rect bounds)
{
this.Left = bounds.Left;
@ -376,7 +387,7 @@ namespace ICSharpCode.ILSpy @@ -376,7 +387,7 @@ namespace ICSharpCode.ILSpy
} else if (spySettings != null) {
SharpTreeNode node = null;
if (activeTreeViewPath?.Length > 0) {
foreach (var asm in assemblyList.GetAssemblies()) {
foreach (var asm in CurrentAssemblyList.GetAssemblies()) {
if (asm.FileName == activeTreeViewPath[0]) {
// FindNodeByPath() blocks the UI if the assembly is not yet loaded,
// so use an async wait instead.
@ -466,7 +477,7 @@ namespace ICSharpCode.ILSpy @@ -466,7 +477,7 @@ namespace ICSharpCode.ILSpy
if (loadPreviousAssemblies) {
// Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff.
// This makes the UI come up a bit faster.
this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList);
this.assemblyList = assemblyListManager.LoadList(sessionSettings.ActiveAssemblyList);
} else {
this.assemblyList = new AssemblyList(AssemblyListManager.DefaultListName);
assemblyListManager.ClearAll();
@ -584,8 +595,7 @@ namespace ICSharpCode.ILSpy @@ -584,8 +595,7 @@ namespace ICSharpCode.ILSpy
public void ShowAssemblyList(string name)
{
ILSpySettings settings = ILSpySettings.Load();
AssemblyList list = this.assemblyListManager.LoadList(settings, name);
AssemblyList list = this.assemblyListManager.LoadList(name);
//Only load a new list when it is a different one
if (list.ListName != CurrentAssemblyList.ListName) {
ShowAssemblyList(list);
@ -906,7 +916,7 @@ namespace ICSharpCode.ILSpy @@ -906,7 +916,7 @@ namespace ICSharpCode.ILSpy
try {
refreshInProgress = true;
var path = GetPathForNode(treeView.SelectedItem as SharpTreeNode);
ShowAssemblyList(assemblyListManager.LoadList(ILSpySettings.Load(), assemblyList.ListName));
ShowAssemblyList(assemblyListManager.LoadList(assemblyList.ListName));
SelectNode(FindNodeByPath(path, true));
} finally {
refreshInProgress = false;

9
ILSpy/Properties/Resources.Designer.cs generated

@ -1710,6 +1710,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1710,6 +1710,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Select a list of assemblies.
/// </summary>
public static string SelectAssemblyListDropdownTooltip {
get {
return ResourceManager.GetString("SelectAssemblyListDropdownTooltip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Select language to decompile to.
/// </summary>

3
ILSpy/Properties/Resources.resx

@ -808,4 +808,7 @@ Are you sure you want to continue?</value> @@ -808,4 +808,7 @@ Are you sure you want to continue?</value>
<data name="ResetToDefaultsConfirmationMessage" xml:space="preserve">
<value>Do you really want to load the default settings for the active page?</value>
</data>
<data name="SelectAssemblyListDropdownTooltip" xml:space="preserve">
<value>Select a list of assemblies</value>
</data>
</root>

17
ILSpy/SessionSettings.cs

@ -20,6 +20,7 @@ using System; @@ -20,6 +20,7 @@ using System;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
@ -63,10 +64,9 @@ namespace ICSharpCode.ILSpy @@ -63,10 +64,9 @@ namespace ICSharpCode.ILSpy
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string propertyName)
void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public FilterSettings FilterSettings { get; private set; }
@ -75,7 +75,15 @@ namespace ICSharpCode.ILSpy @@ -75,7 +75,15 @@ namespace ICSharpCode.ILSpy
public string[] ActiveTreeViewPath;
public string ActiveAutoLoadedAssembly;
public string ActiveAssemblyList;
public string ActiveAssemblyList {
get => activeAssemblyList;
set {
if (value != activeAssemblyList) {
activeAssemblyList = value;
OnPropertyChanged();
}
}
}
public WindowState WindowState = WindowState.Normal;
public Rect WindowBounds;
@ -118,6 +126,7 @@ namespace ICSharpCode.ILSpy @@ -118,6 +126,7 @@ namespace ICSharpCode.ILSpy
}
static Regex regex = new Regex("\\\\x(?<num>[0-9A-f]{4})");
private string activeAssemblyList;
static string Escape(string p)
{

Loading…
Cancel
Save