diff --git a/ILSpy/Analyzers/AnalyzerTreeView.cs b/ILSpy/Analyzers/AnalyzerTreeView.cs index 54256935e..13b29bd3f 100644 --- a/ILSpy/Analyzers/AnalyzerTreeView.cs +++ b/ILSpy/Analyzers/AnalyzerTreeView.cs @@ -73,7 +73,7 @@ namespace ICSharpCode.ILSpy.Analyzers public void Show() { if (!IsVisible) - MainWindow.Instance.ShowInBottomPane("Analyzer", this); + MainWindow.Instance.ShowInNewPane("Analyzer", this, PanePosition.Bottom); } public void Show(AnalyzerTreeNode node) diff --git a/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs b/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs index 177dcc7c6..48a2d592e 100644 --- a/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs +++ b/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs @@ -20,7 +20,7 @@ using System.Linq; namespace ICSharpCode.ILSpy.Analyzers { - [ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete.png", Category = "Analyze", Order = 200)] + [ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete", Category = "Analyze", Order = 200)] internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/Commands/DecompileInNewViewCommand.cs b/ILSpy/Commands/DecompileInNewViewCommand.cs new file mode 100644 index 000000000..3b335743d --- /dev/null +++ b/ILSpy/Commands/DecompileInNewViewCommand.cs @@ -0,0 +1,52 @@ +// 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.Linq; +using ICSharpCode.ILSpy.Properties; +using ICSharpCode.ILSpy.TextView; +using ICSharpCode.ILSpy.TreeNodes; + +namespace ICSharpCode.ILSpy.Commands +{ + // [ExportContextMenuEntry(Header = nameof(Resources.DecompileToNewPanel), Icon = "images/Search", Category = nameof(Resources.Analyze), Order = 90)] + internal sealed class DecompileInNewViewCommand : IContextMenuEntry + { + public bool IsVisible(TextViewContext context) + { + if (context.SelectedTreeNodes == null) + return false; + return true; + } + + public bool IsEnabled(TextViewContext context) + { + if (context.SelectedTreeNodes == null) + return false; + return true; + } + + public async void Execute(TextViewContext context) + { + var dtv = new DecompilerTextView(); + var nodes = context.SelectedTreeNodes.Cast().ToArray(); + var title = string.Join(", ", nodes.Select(x => x.ToString())); + MainWindow.Instance.ShowInNewPane(title, dtv, PanePosition.Document); + await dtv.DecompileAsync(MainWindow.Instance.CurrentLanguage, nodes, new DecompilationOptions()); + } + } +} diff --git a/ILSpy/ContextMenuEntry.cs b/ILSpy/ContextMenuEntry.cs index 9b0bbe36d..d04155f43 100644 --- a/ILSpy/ContextMenuEntry.cs +++ b/ILSpy/ContextMenuEntry.cs @@ -222,15 +222,11 @@ namespace ICSharpCode.ILSpy menuItem.Header = MainWindow.GetResourceString( entryPair.Metadata.Header); menuItem.InputGestureText = entryPair.Metadata.InputGestureText; if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) { - object image = Images.Load(entryPair.Value, entryPair.Metadata.Icon); - if (!(image is Viewbox)) { - image = new Image { - Width = 16, - Height = 16, - Source = (ImageSource)image - }; - } - menuItem.Icon = image; + menuItem.Icon = new Image { + Width = 16, + Height = 16, + Source = Images.Load(entryPair.Value, entryPair.Metadata.Icon) + }; } if (entryPair.Value.IsEnabled(context)) { menuItem.Click += delegate { entry.Execute(context); }; diff --git a/ILSpy/Controls/DockedPane.cs b/ILSpy/Controls/DockedPane.cs deleted file mode 100644 index 6f370ce95..000000000 --- a/ILSpy/Controls/DockedPane.cs +++ /dev/null @@ -1,76 +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.Windows; -using System.Windows.Controls; -using System.Windows.Input; - -namespace ICSharpCode.ILSpy.Controls -{ - class DockedPane : Control - { - static DockedPane() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DockedPane), new FrameworkPropertyMetadata(typeof(DockedPane))); - } - - public static readonly DependencyProperty TitleProperty = - DependencyProperty.Register("Title", typeof(string), typeof(DockedPane)); - - public string Title { - get { return (string)GetValue(TitleProperty); } - set { SetValue(TitleProperty, value); } - } - - public static readonly DependencyProperty ContentProperty = - DependencyProperty.Register("Content", typeof(object), typeof(DockedPane)); - - public object Content { - get { return GetValue(ContentProperty); } - set { SetValue(ContentProperty, value); } - } - - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - Button closeButton = (Button)this.Template.FindName("PART_Close", this); - if (closeButton != null) { - closeButton.Click += closeButton_Click; - } - } - - void closeButton_Click(object sender, RoutedEventArgs e) - { - if (CloseButtonClicked != null) - CloseButtonClicked(this, e); - } - - public event EventHandler CloseButtonClicked; - - protected override void OnKeyDown(KeyEventArgs e) - { - base.OnKeyDown(e); - if (e.Key == Key.F4 && e.KeyboardDevice.Modifiers == ModifierKeys.Control || e.Key == Key.Escape) { - if (CloseButtonClicked != null) - CloseButtonClicked(this, e); - e.Handled = true; - } - } - } -} diff --git a/ILSpy/DebugSteps.xaml.cs b/ILSpy/DebugSteps.xaml.cs index 131530740..ba13f1d84 100644 --- a/ILSpy/DebugSteps.xaml.cs +++ b/ILSpy/DebugSteps.xaml.cs @@ -79,7 +79,7 @@ namespace ICSharpCode.ILSpy public static void Show() { - MainWindow.Instance.ShowInTopPane(Properties.Resources.DebugSteps, new DebugSteps()); + MainWindow.Instance.ShowInNewPane(Properties.Resources.DebugSteps, new DebugSteps(), PanePosition.Top); } void IPane.Closed() diff --git a/ILSpy/Docking/DockingHelper.cs b/ILSpy/Docking/DockingHelper.cs new file mode 100644 index 000000000..157837a6c --- /dev/null +++ b/ILSpy/Docking/DockingHelper.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Controls; +using Xceed.Wpf.AvalonDock.Layout; + +namespace ICSharpCode.ILSpy.Docking +{ + public static class DockingHelper + { + public static void DockHorizontal(LayoutContent layoutContent, ILayoutElement paneRelativeTo, GridLength dockHeight, bool dockBefore = false) + { + if (paneRelativeTo is ILayoutDocumentPane parentDocumentPane) { + var parentDocumentGroup = paneRelativeTo.FindParent(); + if (parentDocumentGroup == null) { + var grandParent = parentDocumentPane.Parent as ILayoutContainer; + parentDocumentGroup = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical }; + grandParent.ReplaceChild(paneRelativeTo, parentDocumentGroup); + parentDocumentGroup.Children.Add(parentDocumentPane); + } + parentDocumentGroup.Orientation = System.Windows.Controls.Orientation.Vertical; + int indexOfParentPane = parentDocumentGroup.IndexOfChild(parentDocumentPane); + var layoutDocumentPane = new LayoutDocumentPane(layoutContent) { DockHeight = dockHeight }; + parentDocumentGroup.InsertChildAt(dockBefore ? indexOfParentPane : indexOfParentPane + 1, layoutDocumentPane); + layoutContent.IsActive = true; + layoutContent.Root.CollectGarbage(); + Application.Current.MainWindow.Dispatcher.Invoke(() => { + + layoutDocumentPane.DockHeight = dockHeight; + }, System.Windows.Threading.DispatcherPriority.Loaded); + } + } + } +} diff --git a/ILSpy/Docking/PanePosition.cs b/ILSpy/Docking/PanePosition.cs new file mode 100644 index 000000000..d162d5d7b --- /dev/null +++ b/ILSpy/Docking/PanePosition.cs @@ -0,0 +1,9 @@ +namespace ICSharpCode.ILSpy +{ + public enum PanePosition + { + Top, + Bottom, + Document + } +} diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 1dd22579f..d97b697dd 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -49,6 +49,7 @@ + @@ -99,6 +100,7 @@ + @@ -122,7 +124,6 @@ ResourceObjectTable.xaml - @@ -136,6 +137,7 @@ DebugSteps.xaml + @@ -162,6 +164,7 @@ + True True diff --git a/ILSpy/MainWindow.xaml b/ILSpy/MainWindow.xaml index c8846031e..faff33607 100644 --- a/ILSpy/MainWindow.xaml +++ b/ILSpy/MainWindow.xaml @@ -4,7 +4,7 @@ x:ClassModifier="public" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tv="clr-namespace:ICSharpCode.TreeView;assembly=ICSharpCode.TreeView" xmlns:local="clr-namespace:ICSharpCode.ILSpy" - xmlns:textView="clr-namespace:ICSharpCode.ILSpy.TextView" + xmlns:avalondock="http://schemas.xceed.com/wpf/xaml/avalondock" xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls" xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties" Title="ILSpy" @@ -51,7 +51,8 @@ - + + @@ -96,6 +97,15 @@ ItemsSource="{Binding SelectedItem.LanguageVersions, ElementName=languageComboBox, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding FilterSettings.LanguageVersion, UpdateSourceTrigger=PropertyChanged}"/> + + + + + + - - - - - - - - - - - - - \ No newline at end of file