Browse Source

Fix #2205: AboutPage should always be opened in a new tab.

pull/2247/head
Siegfried Pammer 5 years ago
parent
commit
dfbce75699
  1. 10
      ILSpy/AboutPage.cs
  2. 7
      ILSpy/Docking/DockWorkspace.cs
  3. 12
      ILSpy/MainWindow.xaml.cs
  4. 18
      ILSpy/TextView/DecompilerTextView.cs

10
ILSpy/AboutPage.cs

@ -44,7 +44,10 @@ namespace ICSharpCode.ILSpy
{ {
public override void Execute(object parameter) 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"); static readonly Uri UpdateUrl = new Uri("https://ilspy.net/updates.xml");
@ -54,7 +57,10 @@ namespace ICSharpCode.ILSpy
public static void Display(DecompilerTextView textView) 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); output.WriteLine(Resources.ILSpyVersion + RevisionClass.FullVersion);
if (WindowsVersionHelper.HasPackageIdentity) if (WindowsVersionHelper.HasPackageIdentity)
{ {

7
ILSpy/Docking/DockWorkspace.cs

@ -26,6 +26,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Navigation;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
@ -96,7 +97,13 @@ namespace ICSharpCode.ILSpy.Docking
this.sessionSettings.FilterSettings.LanguageVersion = value.LanguageVersion; this.sessionSettings.FilterSettings.LanguageVersion = value.LanguageVersion;
var state = value.GetState(); var state = value.GetState();
if (state != null) if (state != null)
{
if (state.DecompiledNodes != null)
MainWindow.Instance.SelectNodes(state.DecompiledNodes); MainWindow.Instance.SelectNodes(state.DecompiledNodes);
else
MainWindow.Instance.NavigateTo(new RequestNavigateEventArgs(state.ViewedUri, null));
}
RaisePropertyChanged(nameof(ActiveTabPage)); RaisePropertyChanged(nameof(ActiveTabPage));
} }
} }

12
ILSpy/MainWindow.xaml.cs

@ -1286,10 +1286,20 @@ namespace ICSharpCode.ILSpy
} }
#endregion #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 (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") if (e.Uri.Host == "aboutpage")
{ {
RecordHistory(); RecordHistory();

18
ILSpy/TextView/DecompilerTextView.cs

@ -75,6 +75,7 @@ namespace ICSharpCode.ILSpy.TextView
FoldingManager foldingManager; FoldingManager foldingManager;
ILSpyTreeNode[] decompiledNodes; ILSpyTreeNode[] decompiledNodes;
Uri currentAddress; Uri currentAddress;
string currentTitle;
DefinitionLookup definitionLookup; DefinitionLookup definitionLookup;
TextSegmentCollection<ReferenceSegment> references; TextSegmentCollection<ReferenceSegment> references;
@ -163,6 +164,16 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
ContextMenuProvider.Add(this); 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) void RemoveEditCommand(RoutedUICommand command)
@ -664,8 +675,12 @@ namespace ICSharpCode.ILSpy.TextView
this.nextDecompilationRun.TaskCompletionSource.TrySetCanceled(); this.nextDecompilationRun.TaskCompletionSource.TrySetCanceled();
this.nextDecompilationRun = null; 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)); textOutput.Title = string.Join(", ", nodes.Select(n => n.Text));
}
ShowOutput(textOutput, highlighting); ShowOutput(textOutput, highlighting);
decompiledNodes = nodes; decompiledNodes = nodes;
} }
@ -746,6 +761,7 @@ namespace ICSharpCode.ILSpy.TextView
model.Title = textOutput.Title; model.Title = textOutput.Title;
} }
currentAddress = textOutput.Address; currentAddress = textOutput.Address;
currentTitle = textOutput.Title;
} }
#endregion #endregion

Loading…
Cancel
Save