You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.6 KiB
120 lines
3.6 KiB
// 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.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using ICSharpCode.TreeView;
|
|
using Microsoft.Win32;
|
|
|
|
namespace ICSharpCode.ILSpy
|
|
{
|
|
/// <summary>
|
|
/// The main window of the application.
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
AssemblyListTreeNode assemblyList = new AssemblyListTreeNode();
|
|
|
|
static readonly Assembly[] initialAssemblies = {
|
|
typeof(object).Assembly,
|
|
typeof(Uri).Assembly,
|
|
typeof(System.Linq.Enumerable).Assembly,
|
|
typeof(System.Xml.XmlDocument).Assembly,
|
|
typeof(System.Windows.Markup.MarkupExtension).Assembly,
|
|
typeof(System.Windows.Rect).Assembly,
|
|
typeof(System.Windows.UIElement).Assembly,
|
|
typeof(System.Windows.FrameworkElement).Assembly,
|
|
typeof(ICSharpCode.TreeView.SharpTreeView).Assembly,
|
|
typeof(Mono.Cecil.AssemblyDefinition).Assembly,
|
|
typeof(MainWindow).Assembly
|
|
};
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
textEditor.Text = "// Welcome to ILSpy!";
|
|
treeView.Root = assemblyList;
|
|
assemblyList.Select = delegate(SharpTreeNode obj) {
|
|
if (obj != null) {
|
|
foreach (SharpTreeNode node in obj.Ancestors())
|
|
node.IsExpanded = true;
|
|
|
|
treeView.SelectedItem = obj;
|
|
treeView.ScrollIntoView(obj);
|
|
}
|
|
};
|
|
|
|
foreach (Assembly asm in initialAssemblies)
|
|
assemblyList.OpenAssembly(asm.Location);
|
|
}
|
|
|
|
void OpenCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
|
{
|
|
e.Handled = true;
|
|
OpenFileDialog dlg = new OpenFileDialog();
|
|
dlg.Filter = ".NET assemblies|*.dll;*.exe|All files|*.*";
|
|
dlg.Multiselect = true;
|
|
dlg.RestoreDirectory = true;
|
|
if (dlg.ShowDialog() == true) {
|
|
OpenFiles(dlg.FileNames);
|
|
}
|
|
}
|
|
|
|
void OpenFiles(string[] fileNames)
|
|
{
|
|
treeView.UnselectAll();
|
|
SharpTreeNode lastNode = null;
|
|
foreach (string file in fileNames) {
|
|
var asm = assemblyList.OpenAssembly(file);
|
|
if (asm != null) {
|
|
treeView.SelectedItems.Add(asm);
|
|
lastNode = asm;
|
|
}
|
|
}
|
|
if (lastNode != null)
|
|
treeView.ScrollIntoView(lastNode);
|
|
}
|
|
|
|
void ExitClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
void AboutClick(object sender, RoutedEventArgs e)
|
|
{
|
|
AboutDialog dlg = new AboutDialog();
|
|
dlg.Owner = this;
|
|
dlg.ShowDialog();
|
|
}
|
|
|
|
void OpenFromGac_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
OpenFromGacDialog dlg = new OpenFromGacDialog();
|
|
dlg.Owner = this;
|
|
if (dlg.ShowDialog() == true) {
|
|
OpenFiles(dlg.SelectedFileNames);
|
|
}
|
|
}
|
|
}
|
|
}
|