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. 9
      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 @@ -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 @@ -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)
{

9
ILSpy/Docking/DockWorkspace.cs

@ -26,6 +26,7 @@ using System.Reflection; @@ -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 @@ -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));
}
}

12
ILSpy/MainWindow.xaml.cs

@ -1286,10 +1286,20 @@ namespace ICSharpCode.ILSpy @@ -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();

18
ILSpy/TextView/DecompilerTextView.cs

@ -75,6 +75,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -75,6 +75,7 @@ namespace ICSharpCode.ILSpy.TextView
FoldingManager foldingManager;
ILSpyTreeNode[] decompiledNodes;
Uri currentAddress;
string currentTitle;
DefinitionLookup definitionLookup;
TextSegmentCollection<ReferenceSegment> references;
@ -163,6 +164,16 @@ namespace ICSharpCode.ILSpy.TextView @@ -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 @@ -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 @@ -746,6 +761,7 @@ namespace ICSharpCode.ILSpy.TextView
model.Title = textOutput.Title;
}
currentAddress = textOutput.Address;
currentTitle = textOutput.Title;
}
#endregion

Loading…
Cancel
Save