Browse Source

Fix #1800: Modernize Assembly Lists

pull/1866/head
Siegfried Pammer 6 years ago
parent
commit
38dec5cf5e
  1. 9
      ILSpy/AssemblyList.cs
  2. 9
      ILSpy/AssemblyListManager.cs
  3. 41
      ILSpy/Commands/DelegateCommand.cs
  4. 1
      ILSpy/Commands/ILSpyCommands.cs
  5. 9
      ILSpy/Commands/ManageAssemblyListsCommand.cs
  6. 27
      ILSpy/ILSpy.csproj
  7. 3
      ILSpy/MainWindow.xaml
  8. 16
      ILSpy/MainWindow.xaml.cs
  9. 99
      ILSpy/Properties/Resources.Designer.cs
  10. 27
      ILSpy/Properties/Resources.resx
  11. 174
      ILSpy/ViewModels/ManageAssemblyListsViewModel.cs
  12. 20
      ILSpy/ViewModels/ViewModelBase.cs
  13. 35
      ILSpy/Views/ManageAssemblyLIstsDialog.xaml.cs
  14. 39
      ILSpy/Views/ManageAssemblyListsDialog.xaml
  15. 46
      ILSpy/Views/OpenListDialog.xaml

9
ILSpy/AssemblyList.cs

@ -70,6 +70,15 @@ namespace ICSharpCode.ILSpy @@ -70,6 +70,15 @@ namespace ICSharpCode.ILSpy
}
this.dirty = false; // OpenAssembly() sets dirty, so reset it afterwards
}
/// <summary>
/// Creates a copy of an assembly list.
/// </summary>
public AssemblyList(AssemblyList list, string newName)
: this(newName)
{
this.assemblies.AddRange(list.assemblies);
}
/// <summary>
/// Gets the loaded assemblies. This method is thread-safe.

9
ILSpy/AssemblyListManager.cs

@ -71,7 +71,14 @@ namespace ICSharpCode.ILSpy @@ -71,7 +71,14 @@ namespace ICSharpCode.ILSpy
else
return new AssemblyList(listName ?? DefaultListName);
}
public bool CloneList(string selectedAssemblyList, string newListName)
{
var list = DoLoadList(spySettings, selectedAssemblyList);
var newList = new AssemblyList(list, newListName);
return CreateList(newList);
}
public const string DefaultListName = "(Default)";
/// <summary>

41
ILSpy/Commands/DelegateCommand.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace ICSharpCode.ILSpy.Commands
{
public class DelegateCommand<T> : ICommand
{
private readonly Action<T> action;
private readonly Func<T, bool> canExecute;
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public DelegateCommand(Action<T> action)
: this(action, _ => true)
{
}
public DelegateCommand(Action<T> action, Func<T, bool> canExecute)
{
this.action = action;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute((T)parameter);
}
public void Execute(object parameter)
{
action((T)parameter);
}
}
}

1
ILSpy/Commands/ILSpyCommands.cs

@ -29,5 +29,6 @@ namespace ICSharpCode.ILSpy @@ -29,5 +29,6 @@ namespace ICSharpCode.ILSpy
static class ILSpyCommands
{
public static readonly AnalyzeCommand Analyze = new AnalyzeCommand();
public static readonly ManageAssemblyListsCommand ManageAssemblyListsCommand = new ManageAssemblyListsCommand();
}
}

9
ILSpy/Commands/OpenListCommand.cs → ILSpy/Commands/ManageAssemblyListsCommand.cs

@ -21,15 +21,14 @@ using ICSharpCode.ILSpy.Properties; @@ -21,15 +21,14 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources.Open_List), MenuIcon = "Images/AssemblyList", MenuCategory = nameof(Resources.Open), MenuOrder = 1.7)]
sealed class OpenListCommand : SimpleCommand
[ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources.ManageAssemblyLists), MenuIcon = "Images/AssemblyList", MenuCategory = nameof(Resources.Open), MenuOrder = 1.7)]
sealed class ManageAssemblyListsCommand : SimpleCommand
{
public override void Execute(object parameter)
{
OpenListDialog dlg = new OpenListDialog();
ManageAssemblyListsDialog dlg = new ManageAssemblyListsDialog();
dlg.Owner = MainWindow.Instance;
if (dlg.ShowDialog() == true)
MainWindow.Instance.ShowAssemblyList(dlg.SelectedListName);
dlg.ShowDialog();
}
}
}

27
ILSpy/ILSpy.csproj

@ -107,11 +107,12 @@ @@ -107,11 +107,12 @@
<Compile Include="Commands\BrowseBackCommand.cs" />
<Compile Include="Commands\BrowseForwardCommand.cs" />
<Compile Include="CommandLineArguments.cs" />
<Compile Include="Commands\DelegateCommand.cs" />
<Compile Include="Commands\DisassembleAllCommand.cs" />
<Compile Include="Commands\ExitCommand.cs" />
<Compile Include="Commands\CommandWrapper.cs" />
<Compile Include="Commands\ILSpyCommands.cs" />
<Compile Include="Commands\OpenListCommand.cs" />
<Compile Include="Commands\ManageAssemblyListsCommand.cs" />
<Compile Include="Commands\Pdb2XmlCommand.cs" />
<Compile Include="Commands\RemoveAssembliesWithLoadErrors.cs" />
<Compile Include="Commands\ShowCFGContextMenuEntry.cs" />
@ -132,12 +133,14 @@ @@ -132,12 +133,14 @@
<Compile Include="Controls\SearchBox.cs" />
<Compile Include="Controls\SortableGridViewColumn.cs" />
<Compile Include="Controls\XamlResourceExtension.cs" />
<Compile Include="CreateListDialog.xaml.cs">
<Compile Include="ViewModels\ManageAssemblyListsViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\CreateListDialog.xaml.cs">
<DependentUpon>CreateListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="DebugInfo\DebugInfoUtils.cs" />
<Compile Include="DebugInfo\PortableDebugInfoProvider.cs" />
<Compile Include="DebugSteps.xaml.cs">
<Compile Include="Views\DebugSteps.xaml.cs">
<DependentUpon>DebugSteps.xaml</DependentUpon>
</Compile>
<Compile Include="Docking\ActiveDocumentConverter.cs" />
@ -199,18 +202,16 @@ @@ -199,18 +202,16 @@
<Compile Include="NavigationState.cs" />
<Compile Include="Commands\OpenCommand.cs" />
<Compile Include="Commands\OpenFromGacCommand.cs" />
<Compile Include="NugetPackageBrowserDialog.xaml.cs">
<Compile Include="Views\NugetPackageBrowserDialog.xaml.cs">
<DependentUpon>NugetPackageBrowserDialog.xaml</DependentUpon>
</Compile>
<Compile Include="OpenFromGacDialog.xaml.cs">
<Compile Include="Views\OpenFromGacDialog.xaml.cs">
<DependentUpon>OpenFromGacDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ResourceStringTable.xaml.cs">
<DependentUpon>ResourceStringTable.xaml</DependentUpon>
</Compile>
<Compile Include="OpenListDialog.xaml.cs">
<DependentUpon>OpenListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ManageAssemblyListsDialog.xaml.cs" />
<Compile Include="Options\DisplaySettings.cs" />
<Compile Include="Options\DisplaySettingsPanel.xaml.cs">
<DependentUpon>DisplaySettingsPanel.xaml</DependentUpon>
@ -324,8 +325,8 @@ @@ -324,8 +325,8 @@
<Page Include="Controls\ResourceObjectTable.xaml" />
<Page Include="Controls\ResourceStringTable.xaml" />
<Page Include="Controls\SearchBoxStyle.xaml" />
<Page Include="CreateListDialog.xaml" />
<Page Include="DebugSteps.xaml" />
<Page Include="Views\CreateListDialog.xaml" />
<Page Include="Views\DebugSteps.xaml" />
<Page Include="Images\Assembly.xaml" />
<Page Include="Images\AssemblyList.xaml" />
<Page Include="Images\AssemblyListGAC.xaml" />
@ -389,9 +390,9 @@ @@ -389,9 +390,9 @@
<Page Include="Images\VirtualMethod.xaml" />
<Page Include="Images\Warning.xaml" />
<Page Include="MainWindow.xaml" />
<Page Include="OpenFromGacDialog.xaml" />
<Page Include="OpenListDialog.xaml" />
<Page Include="NugetPackageBrowserDialog.xaml" />
<Page Include="Views\OpenFromGacDialog.xaml" />
<Page Include="Views\ManageAssemblyListsDialog.xaml" />
<Page Include="Views\NugetPackageBrowserDialog.xaml" />
<Page Include="Options\DecompilerSettingsPanel.xaml" />
<Page Include="Options\DisplaySettingsPanel.xaml" />
<Page Include="Options\MiscSettingsPanel.xaml" />

3
ILSpy/MainWindow.xaml

@ -123,6 +123,9 @@ @@ -123,6 +123,9 @@
<ComboBox Name="assemblyListComboBox" Width="100" MaxDropDownHeight="Auto"
ItemsSource="{Binding AssemblyListManager.AssemblyLists}" ToolTip="{x:Static properties:Resources.SelectAssemblyListDropdownTooltip}"
SelectedItem="{Binding SessionSettings.ActiveAssemblyList}"/>
<Button Command="{x:Static local:ILSpyCommands.ManageAssemblyListsCommand}" ToolTip="{x:Static properties:Resources.ManageAssemblyLists}">
<Image Width="16" Height="16" Source="{controls:XamlResource Images/AssemblyList}" />
</Button>
<Separator />
<CheckBox IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicOnly}" ToolTip="{x:Static properties:Resources.ShowPublicOnlyTypesMembers}">
<Image Width="16" Height="16" Source="{controls:XamlResource Images/ShowPublicOnly}" />

16
ILSpy/MainWindow.xaml.cs

@ -70,8 +70,6 @@ namespace ICSharpCode.ILSpy @@ -70,8 +70,6 @@ namespace ICSharpCode.ILSpy
readonly NavigationHistory<NavigationState> history = new NavigationHistory<NavigationState>();
ILSpySettings spySettingsForMainWindow_Loaded;
internal SessionSettings sessionSettings;
internal AssemblyListManager assemblyListManager;
AssemblyList assemblyList;
AssemblyListTreeNode assemblyListTreeNode;
@ -85,6 +83,8 @@ namespace ICSharpCode.ILSpy @@ -85,6 +83,8 @@ namespace ICSharpCode.ILSpy
get { return sessionSettings; }
}
internal AssemblyListManager AssemblyListManager { get; }
public SharpTreeView treeView {
get {
return FindResource("TreeView") as SharpTreeView;
@ -109,14 +109,14 @@ namespace ICSharpCode.ILSpy @@ -109,14 +109,14 @@ namespace ICSharpCode.ILSpy
var spySettings = ILSpySettings.Load();
this.spySettingsForMainWindow_Loaded = spySettings;
this.sessionSettings = new SessionSettings(spySettings);
this.assemblyListManager = new AssemblyListManager(spySettings);
this.AssemblyListManager = new AssemblyListManager(spySettings);
this.Icon = new BitmapImage(new Uri("pack://application:,,,/ILSpy;component/images/ILSpy.ico"));
this.DataContext = new MainWindowDataContext {
Workspace = DockWorkspace.Instance,
SessionSettings = sessionSettings,
AssemblyListManager = assemblyListManager
AssemblyListManager = AssemblyListManager
};
DockWorkspace.Instance.LoadSettings(sessionSettings);
@ -477,10 +477,10 @@ namespace ICSharpCode.ILSpy @@ -477,10 +477,10 @@ 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(sessionSettings.ActiveAssemblyList);
this.assemblyList = AssemblyListManager.LoadList(sessionSettings.ActiveAssemblyList);
} else {
this.assemblyList = new AssemblyList(AssemblyListManager.DefaultListName);
assemblyListManager.ClearAll();
AssemblyListManager.ClearAll();
}
HandleCommandLineArguments(App.CommandLineArguments);
@ -595,7 +595,7 @@ namespace ICSharpCode.ILSpy @@ -595,7 +595,7 @@ namespace ICSharpCode.ILSpy
public void ShowAssemblyList(string name)
{
AssemblyList list = this.assemblyListManager.LoadList(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);
@ -916,7 +916,7 @@ namespace ICSharpCode.ILSpy @@ -916,7 +916,7 @@ namespace ICSharpCode.ILSpy
try {
refreshInProgress = true;
var path = GetPathForNode(treeView.SelectedItem as SharpTreeNode);
ShowAssemblyList(assemblyListManager.LoadList(assemblyList.ListName));
ShowAssemblyList(AssemblyListManager.LoadList(assemblyList.ListName));
SelectNode(FindNodeByPath(path, true));
} finally {
refreshInProgress = false;

99
ILSpy/Properties/Resources.Designer.cs generated

@ -96,15 +96,6 @@ namespace ICSharpCode.ILSpy.Properties { @@ -96,15 +96,6 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to _Create.
/// </summary>
public static string _Create {
get {
return ResourceManager.GetString("_Create", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _File.
/// </summary>
@ -132,6 +123,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -132,6 +123,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to _New.
/// </summary>
public static string _New {
get {
return ResourceManager.GetString("_New", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Open....
/// </summary>
@ -376,6 +376,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -376,6 +376,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to C_lone.
/// </summary>
public static string C_lone {
get {
return ResourceManager.GetString("C_lone", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>
@ -421,6 +430,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -421,6 +430,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
public static string Close {
get {
return ResourceManager.GetString("Close", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Collapse all tree nodes.
/// </summary>
@ -1341,6 +1359,33 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1341,6 +1359,33 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure that you want to delete the selected assembly list?.
/// </summary>
public static string ListDeleteConfirmation {
get {
return ResourceManager.GetString("ListDeleteConfirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A list with the same name was found..
/// </summary>
public static string ListExistsAlready {
get {
return ResourceManager.GetString("ListExistsAlready", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure that you want to remove all assembly lists and recreate the default assembly lists?.
/// </summary>
public static string ListsResetConfirmation {
get {
return ResourceManager.GetString("ListsResetConfirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Load assemblies that were loaded in the last instance..
/// </summary>
@ -1368,6 +1413,24 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1368,6 +1413,24 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Manage assembly _lists....
/// </summary>
public static string ManageAssembly_Lists {
get {
return ResourceManager.GetString("ManageAssembly_Lists", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Manage Assembly Lists.
/// </summary>
public static string ManageAssemblyLists {
get {
return ResourceManager.GetString("ManageAssemblyLists", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Misc.
/// </summary>
@ -1422,15 +1485,6 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1422,15 +1485,6 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Open _List....
/// </summary>
public static string Open_List {
get {
return ResourceManager.GetString("Open_List", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open Explorer.
/// </summary>
@ -1458,15 +1512,6 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1458,15 +1512,6 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Open List.
/// </summary>
public static string OpenList {
get {
return ResourceManager.GetString("OpenList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Delete.
/// </summary>

27
ILSpy/Properties/Resources.resx

@ -156,8 +156,8 @@ @@ -156,8 +156,8 @@
<data name="OpenFrom_GAC" xml:space="preserve">
<value>Open from _GAC...</value>
</data>
<data name="Open_List" xml:space="preserve">
<value>Open _List...</value>
<data name="ManageAssembly_Lists" xml:space="preserve">
<value>Manage assembly _lists...</value>
</data>
<data name="ReloadAssemblies" xml:space="preserve">
<value>Reload all assemblies</value>
@ -450,14 +450,14 @@ @@ -450,14 +450,14 @@
<data name="PublicToken" xml:space="preserve">
<value>Public Key Token</value>
</data>
<data name="OpenList" xml:space="preserve">
<value>Open List</value>
<data name="ManageAssemblyLists" xml:space="preserve">
<value>Manage Assembly Lists</value>
</data>
<data name="SelectList" xml:space="preserve">
<value>Select a list:</value>
</data>
<data name="_Create" xml:space="preserve">
<value>_Create</value>
<data name="_New" xml:space="preserve">
<value>_New</value>
</data>
<data name="OpenListDialog__Open" xml:space="preserve">
<value>_Open</value>
@ -811,4 +811,19 @@ Are you sure you want to continue?</value> @@ -811,4 +811,19 @@ Are you sure you want to continue?</value>
<data name="SelectAssemblyListDropdownTooltip" xml:space="preserve">
<value>Select a list of assemblies</value>
</data>
<data name="Close" xml:space="preserve">
<value>Close</value>
</data>
<data name="C_lone" xml:space="preserve">
<value>C_lone</value>
</data>
<data name="ListDeleteConfirmation" xml:space="preserve">
<value>Are you sure that you want to delete the selected assembly list?</value>
</data>
<data name="ListExistsAlready" xml:space="preserve">
<value>A list with the same name was found.</value>
</data>
<data name="ListsResetConfirmation" xml:space="preserve">
<value>Are you sure that you want to remove all assembly lists and recreate the default assembly lists?</value>
</data>
</root>

174
ILSpy/Views/OpenListDialog.xaml.cs → ILSpy/ViewModels/ManageAssemblyListsViewModel.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
// Copyright (c) 2019 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
@ -16,61 +16,117 @@ @@ -16,61 +16,117 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Commands;
namespace ICSharpCode.ILSpy
namespace ICSharpCode.ILSpy.ViewModels
{
/// <summary>
/// Interaction logic for OpenListDialog.xaml
/// </summary>
public partial class OpenListDialog : Window
public class ManageAssemblyListsViewModel : ViewModelBase
{
public const string DotNet4List = ".NET 4 (WPF)";
public const string DotNet35List = ".NET 3.5";
public const string ASPDotNetMVC3List = "ASP.NET (MVC3)";
readonly AssemblyListManager manager;
private readonly AssemblyListManager manager;
public OpenListDialog()
public ManageAssemblyListsViewModel()
{
InitializeComponent();
manager = MainWindow.Instance.assemblyListManager;
this.manager = MainWindow.Instance.AssemblyListManager;
CreateDefaultAssemblyLists();
NewCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteNew);
CloneCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteClone, CanExecuteClone);
ResetCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteReset);
DeleteCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteDelete, CanExecuteDelete);
}
private void listView_Loaded(object sender, RoutedEventArgs e)
{
listView.ItemsSource = manager.AssemblyLists;
CreateDefaultAssemblyLists();
public ObservableCollection<string> AssemblyLists => manager.AssemblyLists;
private string selectedAssemblyList;
public string SelectedAssemblyList {
get => selectedAssemblyList;
set {
if (selectedAssemblyList != value) {
selectedAssemblyList = value;
RaisePropertyChanged();
}
}
}
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
public ICommand NewCommand { get; }
public ICommand CloneCommand { get; }
public ICommand ResetCommand { get; }
public ICommand DeleteCommand { get; }
private void ExecuteNew(ManageAssemblyListsDialog dialog)
{
okButton.IsEnabled = listView.SelectedItem != null;
deleteButton.IsEnabled = listView.SelectedItem != null;
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = dialog;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.NewListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
manager.CreateList(new AssemblyList(dlg.NewListName));
}
}
void OKButton_Click(object sender, RoutedEventArgs e)
private bool CanExecuteClone(ManageAssemblyListsDialog _)
{
this.DialogResult = true;
return selectedAssemblyList != null;
}
public string SelectedListName
private void ExecuteClone(ManageAssemblyListsDialog dialog)
{
get
{
return listView.SelectedItem.ToString();
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = dialog;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.NewListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
manager.CloneList(SelectedAssemblyList, dlg.NewListName);
}
}
private void ExecuteReset(ManageAssemblyListsDialog dialog)
{
if (MessageBox.Show(dialog, Properties.Resources.ListsResetConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.ClearAll();
CreateDefaultAssemblyLists();
MainWindow.Instance.SessionSettings.ActiveAssemblyList = manager.AssemblyLists[0];
}
private void ExecuteDelete(ManageAssemblyListsDialog dialog)
{
if (MessageBox.Show(dialog, Properties.Resources.ListDeleteConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.DeleteList(SelectedAssemblyList);
}
private bool CanExecuteDelete(ManageAssemblyListsDialog _)
{
return selectedAssemblyList != null;
}
private void CreateDefaultAssemblyLists()
{
if (!manager.AssemblyLists.Contains(DotNet4List))
{
if (!manager.AssemblyLists.Contains(DotNet4List)) {
AssemblyList dotnet4 = new AssemblyList(DotNet4List);
AddToList(dotnet4, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
@ -85,14 +141,12 @@ namespace ICSharpCode.ILSpy @@ -85,14 +141,12 @@ namespace ICSharpCode.ILSpy
AddToList(dotnet4, "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet4, "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (dotnet4.assemblies.Count > 0)
{
if (dotnet4.assemblies.Count > 0) {
manager.CreateList(dotnet4);
}
}
if (!manager.AssemblyLists.Contains(DotNet35List))
{
if (!manager.AssemblyLists.Contains(DotNet35List)) {
AssemblyList dotnet35 = new AssemblyList(DotNet35List);
AddToList(dotnet35, "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
@ -105,14 +159,12 @@ namespace ICSharpCode.ILSpy @@ -105,14 +159,12 @@ namespace ICSharpCode.ILSpy
AddToList(dotnet35, "PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet35, "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
if (dotnet35.assemblies.Count > 0)
{
if (dotnet35.assemblies.Count > 0) {
manager.CreateList(dotnet35);
}
}
if (!manager.AssemblyLists.Contains(ASPDotNetMVC3List))
{
if (!manager.AssemblyLists.Contains(ASPDotNetMVC3List)) {
AssemblyList mvc = new AssemblyList(ASPDotNetMVC3List);
AddToList(mvc, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
@ -139,8 +191,7 @@ namespace ICSharpCode.ILSpy @@ -139,8 +191,7 @@ namespace ICSharpCode.ILSpy
AddToList(mvc, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
if (mvc.assemblies.Count > 0)
{
if (mvc.assemblies.Count > 0) {
manager.CreateList(mvc);
}
}
@ -153,52 +204,5 @@ namespace ICSharpCode.ILSpy @@ -153,52 +204,5 @@ namespace ICSharpCode.ILSpy
if (file != null)
list.OpenAssembly(file);
}
private void CreateButton_Click(object sender, RoutedEventArgs e)
{
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = this;
dlg.Closing += (s, args) =>
{
if (dlg.DialogResult == true)
{
if (manager.AssemblyLists.Contains(dlg.NewListName))
{
args.Cancel = true;
MessageBox.Show("A list with the same name was found.", null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true)
{
manager.CreateList(new AssemblyList(dlg.NewListName));
}
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
if (listView.SelectedItem == null)
return;
if (MessageBox.Show(this, "Are you sure that you want to delete the selected assembly list?",
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.DeleteList(listView.SelectedItem.ToString());
}
private void ResetButton_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(this, "Are you sure that you want to remove all assembly lists and recreate the default assembly lists?",
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.ClearAll();
CreateDefaultAssemblyLists();
}
private void listView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left && listView.SelectedItem != null)
this.DialogResult = true;
}
}
}

20
ILSpy/ViewModels/ViewModelBase.cs

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.ILSpy.ViewModels
{
public abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

35
ILSpy/Views/ManageAssemblyLIstsDialog.xaml.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// 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.Windows;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy
{
/// <summary>
/// Interaction logic for ManageAssemblyListsDialog.xaml
/// </summary>
public partial class ManageAssemblyListsDialog : Window
{
public ManageAssemblyListsDialog()
{
InitializeComponent();
DataContext = new ManageAssemblyListsViewModel();
}
}
}

39
ILSpy/Views/ManageAssemblyListsDialog.xaml

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
<Window
x:Class="ICSharpCode.ILSpy.ManageAssemblyListsDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties"
Title="{x:Static properties:Resources.ManageAssemblyLists}"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="CanResizeWithGrip"
MinWidth="480"
MinHeight="250"
Height="350"
Width="480"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ListBox Name="listView" Margin="0 8" Grid.ColumnSpan="4" SelectedItem="{Binding SelectedAssemblyList}"
SelectionMode="Single" ItemsSource="{Binding AssemblyLists}" />
<StackPanel Grid.Column="5" Grid.RowSpan="2" Margin="4, 8">
<Button Margin="2 2 2 10" Command="{Binding NewCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources._New}"/>
<Button Margin="2" Command="{Binding CloneCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources.C_lone}"/>
<Button Margin="2" Command="{Binding ResetCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources._Reset}"/>
<Button Margin="2" Command="{Binding DeleteCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources.OpenListDialog__Delete}"/>
</StackPanel>
<Button IsCancel="True" Grid.Row="2" Margin="2,0" Content="{x:Static properties:Resources.Close}" />
</Grid>
</Window>

46
ILSpy/Views/OpenListDialog.xaml

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
<Window
x:Class="ICSharpCode.ILSpy.OpenListDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties"
Title="{x:Static properties:Resources.OpenList}"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="CanResizeWithGrip"
MinWidth="480"
MinHeight="250"
Height="350"
Width="480"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Label Content="{x:Static properties:Resources.SelectList}"/>
</StackPanel>
<ListView Name="listView" Grid.Row="1" Margin="0, 8" controls:SortableGridViewColumn.SortMode="Automatic" SelectionChanged="ListView_SelectionChanged"
Loaded="listView_Loaded" SelectionMode="Single" MouseDoubleClick="listView_MouseDoubleClick">
<ListView.View>
<GridView>
<controls:SortableGridViewColumn x:Name="nameColumn" Header="{x:Static properties:Resources.Name}" DisplayMemberBinding="{Binding .}" />
</GridView>
</ListView.View>
</ListView>
<DockPanel Grid.Row="2">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right">
<Button IsDefault="True" Margin="2,0" IsEnabled="False" Name="okButton" Click="OKButton_Click" Content="{x:Static properties:Resources.OpenListDialog__Open}"/>
<Button IsCancel="True" Margin="2,0" Content="Cancel"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" HorizontalAlignment="Left">
<Button Margin="2,0" Click="CreateButton_Click" Content="{x:Static properties:Resources._Create}"/>
<Button Margin="2,0" IsEnabled="False" Name="deleteButton" Click="DeleteButton_Click" Content="{x:Static properties:Resources.OpenListDialog__Delete}"/>
<Button Margin="2,0" Click="ResetButton_Click" Content="{x:Static properties:Resources._Reset}"/>
</StackPanel>
</DockPanel>
</Grid>
</Window>
Loading…
Cancel
Save