Browse Source

Add preconfigured assembly list selection and rename command to ManageAssemblyListsDialog

pull/1994/head
Siegfried Pammer 5 years ago
parent
commit
0dfcafdfe8
  1. 2
      ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
  2. 7
      ILSpy/AssemblyListManager.cs
  3. 32
      ILSpy/Commands/DelegateCommand.cs
  4. 45
      ILSpy/Properties/Resources.Designer.cs
  5. 11
      ILSpy/Properties/Resources.resx
  6. 304
      ILSpy/ViewModels/ManageAssemblyListsViewModel.cs
  7. 24
      ILSpy/Views/CreateListDialog.xaml
  8. 16
      ILSpy/Views/CreateListDialog.xaml.cs
  9. 12
      ILSpy/Views/ManageAssemblyLIstsDialog.xaml.cs
  10. 12
      ILSpy/Views/ManageAssemblyListsDialog.xaml

2
ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs

@ -206,7 +206,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -206,7 +206,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
static string FindDotNetExeDirectory()
public static string FindDotNetExeDirectory()
{
string dotnetExeName = (Environment.OSVersion.Platform == PlatformID.Unix) ? "dotnet" : "dotnet.exe";
foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator)) {

7
ILSpy/AssemblyListManager.cs

@ -76,6 +76,13 @@ namespace ICSharpCode.ILSpy @@ -76,6 +76,13 @@ namespace ICSharpCode.ILSpy
return CreateList(newList);
}
public bool RenameList(string selectedAssemblyList, string newListName)
{
var list = DoLoadList(spySettings, selectedAssemblyList);
var newList = new AssemblyList(list, newListName);
return DeleteList(selectedAssemblyList) && CreateList(newList);
}
public const string DefaultListName = "(Default)";
/// <summary>

32
ILSpy/Commands/DelegateCommand.cs

@ -7,6 +7,38 @@ using System.Windows.Input; @@ -7,6 +7,38 @@ using System.Windows.Input;
namespace ICSharpCode.ILSpy.Commands
{
public class DelegateCommand : ICommand
{
private readonly Action action;
private readonly Func<bool> canExecute;
public event EventHandler CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public DelegateCommand(Action action)
: this(action, () => true)
{
}
public DelegateCommand(Action action, Func<bool> canExecute)
{
this.action = action;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute();
}
public void Execute(object parameter)
{
action();
}
}
public class DelegateCommand<T> : ICommand
{
private readonly Action<T> action;

45
ILSpy/Properties/Resources.Designer.cs generated

@ -285,6 +285,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -285,6 +285,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Add preconfigured list....
/// </summary>
public static string AddPreconfiguredList {
get {
return ResourceManager.GetString("AddPreconfiguredList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Add shell integration.
/// </summary>
@ -1388,15 +1397,6 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1388,15 +1397,6 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to New list.
/// </summary>
public static string List {
get {
return ResourceManager.GetString("List", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure that you want to delete the selected assembly list?.
/// </summary>
@ -1506,6 +1506,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1506,6 +1506,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to New list.
/// </summary>
public static string NewList {
get {
return ResourceManager.GetString("NewList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Nuget Package Browser.
/// </summary>
@ -1632,6 +1641,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1632,6 +1641,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to R_ename.
/// </summary>
public static string R_ename {
get {
return ResourceManager.GetString("R_ename", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reference Name.
/// </summary>
@ -1706,6 +1724,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1706,6 +1724,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Rename list.
/// </summary>
public static string RenameList {
get {
return ResourceManager.GetString("RenameList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reset to defaults.
/// </summary>

11
ILSpy/Properties/Resources.resx

@ -426,7 +426,7 @@ @@ -426,7 +426,7 @@
<data name="Create" xml:space="preserve">
<value>Create</value>
</data>
<data name="List" xml:space="preserve">
<data name="NewList" xml:space="preserve">
<value>New list</value>
</data>
<data name="SelectAssembliesOpen" xml:space="preserve">
@ -852,4 +852,13 @@ Do you want to continue?</value> @@ -852,4 +852,13 @@ Do you want to continue?</value>
Do you want to continue?</value>
</data>
<data name="AddPreconfiguredList" xml:space="preserve">
<value>Add preconfigured list...</value>
</data>
<data name="R_ename" xml:space="preserve">
<value>R_ename</value>
</data>
<data name="RenameList" xml:space="preserve">
<value>Rename list</value>
</data>
</root>

304
ILSpy/ViewModels/ManageAssemblyListsViewModel.cs

@ -16,11 +16,16 @@ @@ -16,11 +16,16 @@
// 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.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Commands;
using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy.ViewModels
{
@ -31,20 +36,68 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -31,20 +36,68 @@ namespace ICSharpCode.ILSpy.ViewModels
public const string ASPDotNetMVC3List = "ASP.NET (MVC3)";
private readonly AssemblyListManager manager;
private readonly Window parent;
public ManageAssemblyListsViewModel()
public ManageAssemblyListsViewModel(Window parent)
{
this.manager = MainWindow.Instance.AssemblyListManager;
this.parent = parent;
CreateDefaultAssemblyLists();
NewCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteNew);
CloneCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteClone, CanExecuteClone);
ResetCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteReset);
DeleteCommand = new DelegateCommand<ManageAssemblyListsDialog>(ExecuteDelete, CanExecuteDelete);
NewCommand = new DelegateCommand(ExecuteNew);
CloneCommand = new DelegateCommand(ExecuteClone, CanExecuteClone);
RenameCommand = new DelegateCommand(ExecuteRename, CanExecuteRename);
ResetCommand = new DelegateCommand(ExecuteReset);
DeleteCommand = new DelegateCommand(ExecuteDelete, CanExecuteDelete);
CreatePreconfiguredAssemblyListCommand = new DelegateCommand<PreconfiguredAssemblyList>(ExecuteCreatePreconfiguredAssemblyList);
PreconfiguredAssemblyLists = new List<PreconfiguredAssemblyList>(ResolvePreconfiguredAssemblyLists());
}
IEnumerable<PreconfiguredAssemblyList> ResolvePreconfiguredAssemblyLists()
{
yield return new PreconfiguredAssemblyList(DotNet4List);
yield return new PreconfiguredAssemblyList(DotNet35List);
yield return new PreconfiguredAssemblyList(ASPDotNetMVC3List);
var basePath = DotNetCorePathFinder.FindDotNetExeDirectory();
if (basePath == null)
yield break;
Dictionary<string, string> foundVersions = new Dictionary<string, string>();
Dictionary<string, int> latestRevision = new Dictionary<string, int>();
foreach (var sdkDir in Directory.GetDirectories(Path.Combine(basePath, "shared"))) {
if (sdkDir.EndsWith(".Ref", StringComparison.OrdinalIgnoreCase))
continue;
foreach (var versionDir in Directory.GetDirectories(sdkDir)) {
var match = Regex.Match(versionDir, @"[/\\](?<name>[A-z0-9.]+)[/\\](?<version>\d+\.\d)+(.(?<revision>\d+))?$");
if (!match.Success)
continue;
string name = match.Groups["name"].Value;
int index = name.LastIndexOfAny(new[] { '/', '\\' });
if (index >= 0)
name = name.Substring(index + 1);
string text = name + " " + match.Groups["version"].Value;
if (!latestRevision.TryGetValue(text, out int revision))
revision = -1;
int newRevision = int.Parse(match.Groups["revision"].Value);
if (newRevision > revision) {
latestRevision[text] = newRevision;
foundVersions[text] = versionDir;
}
}
}
foreach (var pair in foundVersions) {
yield return new PreconfiguredAssemblyList(pair.Key + "(." + latestRevision[pair.Key] + ")", pair.Value);
}
}
public ObservableCollection<string> AssemblyLists => manager.AssemblyLists;
public List<PreconfiguredAssemblyList> PreconfiguredAssemblyLists { get; }
private string selectedAssemblyList;
public string SelectedAssemblyList {
@ -60,50 +113,52 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -60,50 +113,52 @@ namespace ICSharpCode.ILSpy.ViewModels
public ICommand NewCommand { get; }
public ICommand CloneCommand { get; }
public ICommand ResetCommand { get; }
public ICommand RenameCommand { get; }
public ICommand DeleteCommand { get; }
public ICommand CreatePreconfiguredAssemblyListCommand { get; }
private void ExecuteNew(ManageAssemblyListsDialog dialog)
private void ExecuteNew()
{
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = dialog;
CreateListDialog dlg = new CreateListDialog(Resources.NewList);
dlg.Owner = parent;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.NewListName)) {
if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
manager.CreateList(new AssemblyList(dlg.NewListName));
manager.CreateList(new AssemblyList(dlg.ListName));
}
}
private bool CanExecuteClone(ManageAssemblyListsDialog _)
private bool CanExecuteClone()
{
return selectedAssemblyList != null;
}
private void ExecuteClone(ManageAssemblyListsDialog dialog)
private void ExecuteClone()
{
CreateListDialog dlg = new CreateListDialog();
dlg.Owner = dialog;
CreateListDialog dlg = new CreateListDialog(Resources.NewList);
dlg.Owner = parent;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.NewListName)) {
if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
manager.CloneList(SelectedAssemblyList, dlg.NewListName);
manager.CloneList(SelectedAssemblyList, dlg.ListName);
}
}
private void ExecuteReset(ManageAssemblyListsDialog dialog)
private void ExecuteReset()
{
if (MessageBox.Show(dialog, Properties.Resources.ListsResetConfirmation,
if (MessageBox.Show(parent, Properties.Resources.ListsResetConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.ClearAll();
@ -111,98 +166,191 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -111,98 +166,191 @@ namespace ICSharpCode.ILSpy.ViewModels
MainWindow.Instance.SessionSettings.ActiveAssemblyList = manager.AssemblyLists[0];
}
private void ExecuteDelete(ManageAssemblyListsDialog dialog)
private void ExecuteDelete()
{
if (MessageBox.Show(dialog, Properties.Resources.ListDeleteConfirmation,
if (MessageBox.Show(parent, Properties.Resources.ListDeleteConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return;
manager.DeleteList(SelectedAssemblyList);
}
private bool CanExecuteDelete(ManageAssemblyListsDialog _)
private bool CanExecuteDelete()
{
return selectedAssemblyList != null;
}
private bool CanExecuteRename()
{
return selectedAssemblyList != null;
}
private void ExecuteRename()
{
CreateListDialog dlg = new CreateListDialog(Resources.RenameList);
dlg.Owner = parent;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
manager.RenameList(selectedAssemblyList, dlg.ListName);
}
}
private AssemblyList CreateDefaultList(string name, string path = null, string newName = null)
{
var list = new AssemblyList(newName ?? name);
switch (name) {
case DotNet4List:
AddToListFromGAC("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
break;
case DotNet35List:
AddToListFromGAC("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
break;
case ASPDotNetMVC3List:
AddToListFromGAC("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToListFromGAC("System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToListFromGAC("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToListFromGAC("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
break;
case object _ when path != null:
foreach (var file in Directory.GetFiles(path, "*.dll")) {
var dllname = Path.GetFileName(file);
if (DoIncludeFile(dllname))
AddToListFromDirectory(file);
}
break;
}
return list;
void AddToListFromGAC(string fullName)
{
AssemblyNameReference reference = AssemblyNameReference.Parse(fullName);
string file = GacInterop.FindAssemblyInNetGac(reference);
if (file != null)
list.OpenAssembly(file);
}
void AddToListFromDirectory(string file)
{
if (File.Exists(file))
list.OpenAssembly(file);
}
bool DoIncludeFile(string fileName)
{
if (fileName == "Microsoft.DiaSymReader.Native.amd64.dll")
return false;
if (fileName.EndsWith("_cor3.dll", StringComparison.OrdinalIgnoreCase))
return false;
if (char.IsUpper(fileName[0]))
return true;
if (fileName == "netstandard.dll")
return true;
if (fileName == "mscorlib.dll")
return true;
return false;
}
}
private void CreateDefaultAssemblyLists()
{
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");
AddToList(dotnet4, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet4, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(dotnet4, "PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet4, "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet4, "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AssemblyList dotnet4 = CreateDefaultList(DotNet4List);
if (dotnet4.assemblies.Count > 0) {
manager.CreateList(dotnet4);
}
}
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");
AddToList(dotnet35, "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(dotnet35, "PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet35, "PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(dotnet35, "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AssemblyList dotnet35 = CreateDefaultList(DotNet35List);
if (dotnet35.assemblies.Count > 0) {
manager.CreateList(dotnet35);
}
}
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");
AddToList(mvc, "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
AddToList(mvc, "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
AddToList(mvc, "System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
AddToList(mvc, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
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");
AssemblyList mvc = CreateDefaultList(ASPDotNetMVC3List);
if (mvc.assemblies.Count > 0) {
manager.CreateList(mvc);
}
}
}
private void AddToList(AssemblyList list, string FullName)
private void ExecuteCreatePreconfiguredAssemblyList(PreconfiguredAssemblyList config)
{
CreateListDialog dlg = new CreateListDialog(Resources.AddPreconfiguredList);
dlg.Owner = parent;
dlg.Closing += (s, args) => {
if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK);
}
}
};
if (dlg.ShowDialog() == true) {
var list = CreateDefaultList(config.Name, config.Path, dlg.ListName);
if (list.assemblies.Count > 0) {
manager.CreateList(list);
}
}
}
}
public class PreconfiguredAssemblyList
{
public string Name { get; }
public string Path { get; }
public PreconfiguredAssemblyList(string name, string path = null)
{
AssemblyNameReference reference = AssemblyNameReference.Parse(FullName);
string file = GacInterop.FindAssemblyInNetGac(reference);
if (file != null)
list.OpenAssembly(file);
this.Name = name;
this.Path = path;
}
}
}

24
ILSpy/Views/CreateListDialog.xaml

@ -2,26 +2,24 @@ @@ -2,26 +2,24 @@
x:Class="ICSharpCode.ILSpy.CreateListDialog" 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"
xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
Title="{x:Static properties:Resources.List}"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Width="300"
Height="150"
FocusManager.FocusedElement="{Binding ElementName=ListName}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
FocusManager.FocusedElement="{Binding ElementName=ListNameBox}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Label Content="{x:Static properties:Resources.EnterListName}"/>
<TextBox Margin="8,8" Name="ListName" TextChanged="TextBox_TextChanged"></TextBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="8,0">
<TextBox Margin="8,8" Name="ListNameBox" TextChanged="TextBox_TextChanged"></TextBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="8,0">
<Button IsDefault="True" Margin="2,0" IsEnabled="False" Name="okButton" Click="OKButton_Click" Content="{x:Static properties:Resources.Create}"/>
<Button IsCancel="True" Margin="2,0" Content="{x:Static properties:Resources.Cancel}"/>
</StackPanel>
</Grid>
</Grid>
</Window>

16
ILSpy/Views/CreateListDialog.xaml.cs

@ -8,31 +8,29 @@ namespace ICSharpCode.ILSpy @@ -8,31 +8,29 @@ namespace ICSharpCode.ILSpy
/// </summary>
public partial class CreateListDialog : Window
{
public CreateListDialog()
public CreateListDialog(string title)
{
InitializeComponent();
this.Title = title;
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
okButton.IsEnabled = !string.IsNullOrWhiteSpace(ListName.Text);
okButton.IsEnabled = !string.IsNullOrWhiteSpace(ListNameBox.Text);
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(ListName.Text))
if (!string.IsNullOrWhiteSpace(ListNameBox.Text))
{
this.DialogResult = true;
}
}
public string NewListName
public string ListName
{
get
{
return ListName.Text;
}
get => ListNameBox.Text;
set => ListNameBox.Text = value;
}
}
}

12
ILSpy/Views/ManageAssemblyLIstsDialog.xaml.cs

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy
@ -29,7 +31,15 @@ namespace ICSharpCode.ILSpy @@ -29,7 +31,15 @@ namespace ICSharpCode.ILSpy
public ManageAssemblyListsDialog()
{
InitializeComponent();
DataContext = new ManageAssemblyListsViewModel();
DataContext = new ManageAssemblyListsViewModel(this);
}
private void PreconfiguredAssemblyListsMenuClick(object sender, RoutedEventArgs e)
{
var menu = (ContextMenu)Resources["PreconfiguredAssemblyListsMenu"];
menu.PlacementTarget = (Button)sender;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
}
}

12
ILSpy/Views/ManageAssemblyListsDialog.xaml

@ -12,6 +12,16 @@ @@ -12,6 +12,16 @@
Height="350"
Width="480"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Window.Resources>
<ContextMenu x:Key="PreconfiguredAssemblyListsMenu" ItemsSource="{Binding PreconfiguredAssemblyLists}" DisplayMemberPath="Name">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Command" Value="{Binding DataContext.CreatePreconfiguredAssemblyListCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
<Setter Property="CommandParameter" Value="{Binding}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</Window.Resources>
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
@ -30,10 +40,12 @@ @@ -30,10 +40,12 @@
<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 RenameCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources.R_ename}"/>
<Button Margin="2" Command="{Binding DeleteCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources.OpenListDialog__Delete}"/>
<Button Margin="2 10 2 2" Command="{Binding ResetCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" Content="{x:Static properties:Resources._Reset}"/>
</StackPanel>
<Button IsCancel="True" Grid.Row="2" Margin="2,0" Content="{x:Static properties:Resources.Close}" />
<Button Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="2,0" Content="{x:Static properties:Resources.AddPreconfiguredList}" Click="PreconfiguredAssemblyListsMenuClick" />
</Grid>
</Window>
Loading…
Cancel
Save