diff --git a/ILSpy/AboutPage.cs b/ILSpy/AboutPage.cs index 8d4671139..36795bcba 100644 --- a/ILSpy/AboutPage.cs +++ b/ILSpy/AboutPage.cs @@ -44,7 +44,10 @@ namespace ICSharpCode.ILSpy { public override void Execute(object parameter) { - MainWindow.Instance.NavigateTo(new RequestNavigateEventArgs(new Uri("resource://aboutpage"), null)); + MainWindow.Instance.NavigateTo( + new RequestNavigateEventArgs(new Uri("resource://aboutpage"), null), + inNewTabPage: true + ); } static readonly Uri UpdateUrl = new Uri("https://ilspy.net/updates.xml"); @@ -54,7 +57,10 @@ namespace ICSharpCode.ILSpy public static void Display(DecompilerTextView textView) { - AvalonEditTextOutput output = new AvalonEditTextOutput() { Title = Resources.About, EnableHyperlinks = true }; + AvalonEditTextOutput output = new AvalonEditTextOutput() { + Title = Resources.About, + EnableHyperlinks = true + }; output.WriteLine(Resources.ILSpyVersion + RevisionClass.FullVersion); if (WindowsVersionHelper.HasPackageIdentity) { diff --git a/ILSpy/Docking/DockWorkspace.cs b/ILSpy/Docking/DockWorkspace.cs index a123f1ad4..35e3d6c65 100644 --- a/ILSpy/Docking/DockWorkspace.cs +++ b/ILSpy/Docking/DockWorkspace.cs @@ -26,6 +26,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; +using System.Windows.Navigation; using System.Windows.Threading; using ICSharpCode.AvalonEdit.Highlighting; @@ -96,7 +97,13 @@ namespace ICSharpCode.ILSpy.Docking this.sessionSettings.FilterSettings.LanguageVersion = value.LanguageVersion; var state = value.GetState(); if (state != null) - MainWindow.Instance.SelectNodes(state.DecompiledNodes); + { + if (state.DecompiledNodes != null) + MainWindow.Instance.SelectNodes(state.DecompiledNodes); + else + MainWindow.Instance.NavigateTo(new RequestNavigateEventArgs(state.ViewedUri, null)); + } + RaisePropertyChanged(nameof(ActiveTabPage)); } } diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 884535761..545ee6bcd 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -1286,10 +1286,20 @@ namespace ICSharpCode.ILSpy } #endregion - internal void NavigateTo(RequestNavigateEventArgs e, bool recordHistory = true) + internal void NavigateTo(RequestNavigateEventArgs e, bool recordHistory = true, bool inNewTabPage = false) { if (e.Uri.Scheme == "resource") { + if (inNewTabPage) + { + DockWorkspace.Instance.TabPages.Add( + new TabPageModel() { + Language = CurrentLanguage, + LanguageVersion = CurrentLanguageVersion + }); + DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.Last(); + } + if (e.Uri.Host == "aboutpage") { RecordHistory(); diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index 3d7dcc08c..56cc729a4 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -75,6 +75,7 @@ namespace ICSharpCode.ILSpy.TextView FoldingManager foldingManager; ILSpyTreeNode[] decompiledNodes; Uri currentAddress; + string currentTitle; DefinitionLookup definitionLookup; TextSegmentCollection references; @@ -163,6 +164,16 @@ namespace ICSharpCode.ILSpy.TextView textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); ContextMenuProvider.Add(this); + + this.DataContextChanged += DecompilerTextView_DataContextChanged; + } + + private void DecompilerTextView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (this.DataContext is PaneModel model) + { + model.Title = currentTitle ?? ILSpy.Properties.Resources.NewTab; + } } void RemoveEditCommand(RoutedUICommand command) @@ -664,8 +675,12 @@ namespace ICSharpCode.ILSpy.TextView this.nextDecompilationRun.TaskCompletionSource.TrySetCanceled(); this.nextDecompilationRun = null; } - if (nodes != null && string.IsNullOrEmpty(textOutput.Title)) + if (nodes != null && (string.IsNullOrEmpty(textOutput.Title) + || textOutput.Title == Properties.Resources.NewTab)) + { textOutput.Title = string.Join(", ", nodes.Select(n => n.Text)); + } + ShowOutput(textOutput, highlighting); decompiledNodes = nodes; } @@ -746,6 +761,7 @@ namespace ICSharpCode.ILSpy.TextView model.Title = textOutput.Title; } currentAddress = textOutput.Address; + currentTitle = textOutput.Title; } #endregion