Browse Source

Refactor DocumentModel API

pull/1716/head
Siegfried Pammer 6 years ago
parent
commit
0d6ac5030c
  1. 8
      ILSpy.BamlDecompiler/BamlResourceEntryNode.cs
  2. 4
      ILSpy/AboutPage.cs
  3. 4
      ILSpy/Commands/DecompileInNewViewCommand.cs
  4. 7
      ILSpy/Commands/SaveCodeContextMenuEntry.cs
  5. 8
      ILSpy/DebugSteps.xaml.cs
  6. 6
      ILSpy/Docking/ActiveTabPageConverter.cs
  7. 2
      ILSpy/Docking/CloseAllDocumentsCommand.cs
  8. 62
      ILSpy/Docking/DockWorkspace.cs
  9. 29
      ILSpy/Docking/PanePosition.cs
  10. 6
      ILSpy/Docking/PaneStyleSelector.cs
  11. 5
      ILSpy/ILSpy.csproj
  12. 18
      ILSpy/MainWindow.xaml
  13. 28
      ILSpy/MainWindow.xaml.cs
  14. 6
      ILSpy/Metadata/CoffHeaderTreeNode.cs
  15. 7
      ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
  16. 5
      ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs
  17. 8
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  18. 5
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  19. 5
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  20. 5
      ILSpy/Metadata/CorTables/EventTableTreeNode.cs
  21. 5
      ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs
  22. 5
      ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs
  23. 5
      ILSpy/Metadata/CorTables/FieldTableTreeNode.cs
  24. 5
      ILSpy/Metadata/CorTables/FileTableTreeNode.cs
  25. 5
      ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs
  26. 5
      ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs
  27. 5
      ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs
  28. 5
      ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs
  29. 5
      ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs
  30. 5
      ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs
  31. 5
      ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs
  32. 5
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  33. 5
      ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs
  34. 5
      ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
  35. 5
      ILSpy/Metadata/CorTables/ParamTableTreeNode.cs
  36. 5
      ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs
  37. 5
      ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs
  38. 5
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  39. 5
      ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs
  40. 5
      ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs
  41. 5
      ILSpy/Metadata/DataDirectoriesTreeNode.cs
  42. 7
      ILSpy/Metadata/DosHeaderTreeNode.cs
  43. 7
      ILSpy/Metadata/MetadataTreeNode.cs
  44. 4
      ILSpy/Metadata/OptionalHeaderTreeNode.cs
  45. 4
      ILSpy/NavigationState.cs
  46. 27
      ILSpy/TextView/DecompilerTextView.cs
  47. 4
      ILSpy/TextView/DecompilerTextView.xaml
  48. 5
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  49. 4
      ILSpy/TreeNodes/ILSpyTreeNode.cs
  50. 6
      ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs
  51. 6
      ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs
  52. 6
      ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs
  53. 2
      ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs
  54. 10
      ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs
  55. 8
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  56. 8
      ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs
  57. 9
      ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs
  58. 2
      ILSpy/ViewModels/AnalyzerPaneModel.cs
  59. 2
      ILSpy/ViewModels/AssemblyListPaneModel.cs
  60. 2
      ILSpy/ViewModels/DebugStepsPaneModel.cs
  61. 2
      ILSpy/ViewModels/PaneModel.cs
  62. 2
      ILSpy/ViewModels/SearchPaneModel.cs
  63. 89
      ILSpy/ViewModels/TabPageModel.cs

8
ILSpy.BamlDecompiler/BamlResourceEntryNode.cs

@ -19,6 +19,7 @@ using ICSharpCode.ILSpy; @@ -19,6 +19,7 @@ using ICSharpCode.ILSpy;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ILSpy.BamlDecompiler.Baml;
using ICSharpCode.ILSpy.ViewModels;
namespace ILSpy.BamlDecompiler
{
@ -28,11 +29,12 @@ namespace ILSpy.BamlDecompiler @@ -28,11 +29,12 @@ namespace ILSpy.BamlDecompiler
{
}
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
IHighlightingDefinition highlighting = null;
textView.RunWithCancellation(
tabPage.SupportsLanguageSwitching = false;
tabPage.ShowTextView(textView => textView.RunWithCancellation(
token => Task.Factory.StartNew(
() => {
AvalonEditTextOutput output = new AvalonEditTextOutput();
@ -45,7 +47,7 @@ namespace ILSpy.BamlDecompiler @@ -45,7 +47,7 @@ namespace ILSpy.BamlDecompiler
return output;
}, token))
.Then(output => textView.ShowNode(output, this, highlighting))
.HandleExceptions();
.HandleExceptions());
return true;
}

4
ILSpy/AboutPage.cs

@ -32,6 +32,8 @@ using System.Xml.Linq; @@ -32,6 +32,8 @@ using System.Xml.Linq;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using OSVersionHelper;
@ -44,7 +46,7 @@ namespace ICSharpCode.ILSpy @@ -44,7 +46,7 @@ namespace ICSharpCode.ILSpy
public override void Execute(object parameter)
{
MainWindow.Instance.UnselectAll();
Display(Docking.DockWorkspace.Instance.GetTextView());
DockWorkspace.Instance.ActiveTabPage.ShowTextView(Display);
}
static readonly Uri UpdateUrl = new Uri("https://ilspy.net/updates.xml");

4
ILSpy/Commands/DecompileInNewViewCommand.cs

@ -70,8 +70,8 @@ namespace ICSharpCode.ILSpy.Commands @@ -70,8 +70,8 @@ namespace ICSharpCode.ILSpy.Commands
return;
var title = string.Join(", ", nodes.Select(x => x.ToString()));
DockWorkspace.Instance.Documents.Add(new ViewModels.DecompiledDocumentModel(title, title) { Language = MainWindow.Instance.CurrentLanguage, LanguageVersion = MainWindow.Instance.CurrentLanguageVersion });
DockWorkspace.Instance.ActiveDocument = DockWorkspace.Instance.Documents.Last();
DockWorkspace.Instance.TabPages.Add(new ViewModels.TabPageModel() { Language = MainWindow.Instance.CurrentLanguage, LanguageVersion = MainWindow.Instance.CurrentLanguageVersion });
DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.Last();
MainWindow.Instance.SelectNodes(nodes);
MainWindow.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)MainWindow.Instance.RefreshDecompiledView);
}

7
ILSpy/Commands/SaveCodeContextMenuEntry.cs

@ -24,6 +24,7 @@ using System.Windows; @@ -24,6 +24,7 @@ using System.Windows;
using System.Windows.Input;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.TreeView;
using Microsoft.Win32;
@ -55,11 +56,12 @@ namespace ICSharpCode.ILSpy.TextView @@ -55,11 +56,12 @@ namespace ICSharpCode.ILSpy.TextView
public static void Execute(IReadOnlyList<SharpTreeNode> selectedNodes)
{
var currentLanguage = MainWindow.Instance.CurrentLanguage;
var textView = Docking.DockWorkspace.Instance.GetTextView();
var tabPage = Docking.DockWorkspace.Instance.ActiveTabPage;
tabPage.ShowTextView(textView => {
if (selectedNodes.Count == 1 && selectedNodes[0] is ILSpyTreeNode singleSelection) {
// if there's only one treenode selected
// we will invoke the custom Save logic
if (singleSelection.Save(textView))
if (singleSelection.Save(tabPage))
return;
} else if (selectedNodes.Count > 1 && selectedNodes.All(n => n is AssemblyTreeNode)) {
var selectedPath = SelectSolutionFile();
@ -77,6 +79,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -77,6 +79,7 @@ namespace ICSharpCode.ILSpy.TextView
// try to save all nodes to disk.
var options = new DecompilationOptions() { FullDecompilation = true };
textView.SaveToDisk(currentLanguage, selectedNodes.OfType<ILSpyTreeNode>(), options);
});
}
/// <summary>

8
ILSpy/DebugSteps.xaml.cs

@ -123,13 +123,13 @@ namespace ICSharpCode.ILSpy @@ -123,13 +123,13 @@ namespace ICSharpCode.ILSpy
{
lastSelectedStep = step;
var window = MainWindow.Instance;
var state = DockWorkspace.Instance.GetState();
DockWorkspace.Instance.GetTextView().DecompileAsync(window.CurrentLanguage, window.SelectedNodes,
var state = DockWorkspace.Instance.ActiveTabPage.GetState();
DockWorkspace.Instance.ActiveTabPage.ShowTextViewAsync(textView => textView.DecompileAsync(window.CurrentLanguage, window.SelectedNodes,
new DecompilationOptions(window.CurrentLanguageVersion) {
StepLimit = step,
IsDebug = isDebug,
TextViewState = state
});
TextViewState = state as TextView.DecompilerTextViewState
}));
}
private void tree_KeyDown(object sender, KeyEventArgs e)

6
ILSpy/Docking/ActiveDocumentConverter.cs → ILSpy/Docking/ActiveTabPageConverter.cs

@ -22,11 +22,11 @@ using ICSharpCode.ILSpy.ViewModels; @@ -22,11 +22,11 @@ using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Docking
{
public class ActiveDocumentConverter : IValueConverter
public class ActiveTabPageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is DocumentModel)
if (value is TabPageModel)
return value;
return Binding.DoNothing;
@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Docking @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Docking
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is DocumentModel)
if (value is TabPageModel)
return value;
return Binding.DoNothing;

2
ILSpy/Docking/CloseAllDocumentsCommand.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy.Docking @@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy.Docking
{
public override void Execute(object parameter)
{
DockWorkspace.Instance.CloseAllDocuments();
DockWorkspace.Instance.CloseAllTabs();
}
}

62
ILSpy/Docking/DockWorkspace.cs

@ -44,19 +44,19 @@ namespace ICSharpCode.ILSpy.Docking @@ -44,19 +44,19 @@ namespace ICSharpCode.ILSpy.Docking
private DockWorkspace()
{
this.Documents.CollectionChanged += Documents_CollectionChanged;
this.TabPages.CollectionChanged += Documents_CollectionChanged;
}
private void Documents_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
var collection = (PaneCollection<DocumentModel>)sender;
var collection = (PaneCollection<TabPageModel>)sender;
bool canClose = collection.Count > 1;
foreach (var item in collection) {
item.IsCloseable = canClose;
}
}
public PaneCollection<DocumentModel> Documents { get; } = new PaneCollection<DocumentModel>();
public PaneCollection<TabPageModel> TabPages { get; } = new PaneCollection<TabPageModel>();
private ToolPaneModel[] toolPanes;
public IEnumerable<ToolPaneModel> ToolPanes {
@ -77,30 +77,26 @@ namespace ICSharpCode.ILSpy.Docking @@ -77,30 +77,26 @@ namespace ICSharpCode.ILSpy.Docking
public void Remove(PaneModel model)
{
if (model is DocumentModel document)
Documents.Remove(document);
if (model is TabPageModel document)
TabPages.Remove(document);
if (model is ToolPaneModel tool)
tool.IsVisible = false;
}
private DocumentModel _activeDocument = null;
public DocumentModel ActiveDocument {
private TabPageModel _activeTabPage = null;
public TabPageModel ActiveTabPage {
get {
return _activeDocument;
return _activeTabPage;
}
set {
if (_activeDocument != value) {
_activeDocument = value;
if (value is DecompiledDocumentModel ddm) {
this.sessionSettings.FilterSettings.Language = ddm.Language;
this.sessionSettings.FilterSettings.LanguageVersion = ddm.LanguageVersion;
if (ddm.TextView is DecompilerTextView view) {
var state = view.GetState();
if (_activeTabPage != value) {
_activeTabPage = value;
this.sessionSettings.FilterSettings.Language = value.Language;
this.sessionSettings.FilterSettings.LanguageVersion = value.LanguageVersion;
var state = value.GetState();
if (state != null)
MainWindow.Instance.SelectNodes(state.DecompiledNodes);
}
}
RaisePropertyChanged(nameof(ActiveDocument));
RaisePropertyChanged(nameof(ActiveTabPage));
}
}
}
@ -158,27 +154,17 @@ namespace ICSharpCode.ILSpy.Docking @@ -158,27 +154,17 @@ namespace ICSharpCode.ILSpy.Docking
public void ShowText(AvalonEditTextOutput textOutput)
{
GetTextView().ShowText(textOutput);
}
public DecompilerTextView GetTextView()
{
return ((DecompiledDocumentModel)ActiveDocument).TextView;
}
public DecompilerTextViewState GetState()
{
return GetTextView()?.GetState();
ActiveTabPage.ShowTextView(textView => textView.ShowText(textOutput));
}
public Task<T> RunWithCancellation<T>(Func<CancellationToken, Task<T>> taskCreation)
{
return GetTextView().RunWithCancellation(taskCreation);
return ActiveTabPage.ShowTextViewAsync(textView => textView.RunWithCancellation(taskCreation));
}
internal void ShowNodes(AvalonEditTextOutput output, TreeNodes.ILSpyTreeNode[] nodes, IHighlightingDefinition highlighting)
{
GetTextView().ShowNodes(output, nodes, highlighting);
ActiveTabPage.ShowTextView(textView => textView.ShowNodes(output, nodes, highlighting));
}
internal void LoadSettings(SessionSettings sessionSettings)
@ -189,19 +175,17 @@ namespace ICSharpCode.ILSpy.Docking @@ -189,19 +175,17 @@ namespace ICSharpCode.ILSpy.Docking
private void FilterSettings_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (ActiveDocument is DecompiledDocumentModel ddm) {
if (e.PropertyName == "Language" || e.PropertyName == "LanguageVersion") {
ddm.Language = sessionSettings.FilterSettings.Language;
ddm.LanguageVersion = sessionSettings.FilterSettings.LanguageVersion;
}
ActiveTabPage.Language = sessionSettings.FilterSettings.Language;
ActiveTabPage.LanguageVersion = sessionSettings.FilterSettings.LanguageVersion;
}
}
internal void CloseAllDocuments()
internal void CloseAllTabs()
{
foreach (var doc in Documents.ToArray()) {
foreach (var doc in TabPages.ToArray()) {
if (doc.IsCloseable)
Documents.Remove(doc);
TabPages.Remove(doc);
}
}
@ -210,7 +194,7 @@ namespace ICSharpCode.ILSpy.Docking @@ -210,7 +194,7 @@ namespace ICSharpCode.ILSpy.Docking
foreach (var pane in ToolPanes) {
pane.IsVisible = false;
}
CloseAllDocuments();
CloseAllTabs();
sessionSettings.DockLayout.Reset();
InitializeLayout(MainWindow.Instance.DockManager);
MainWindow.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)MainWindow.Instance.RefreshDecompiledView);

29
ILSpy/Docking/PanePosition.cs

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
// Copyright (c) 2019 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.
namespace ICSharpCode.ILSpy
{
public enum PanePosition
{
Top,
Bottom,
Left,
Right,
Document
}
}

6
ILSpy/Docking/PaneStyleSelector.cs

@ -25,12 +25,12 @@ namespace ICSharpCode.ILSpy.Docking @@ -25,12 +25,12 @@ namespace ICSharpCode.ILSpy.Docking
{
public Style ToolPaneStyle { get; set; }
public Style DocumentStyle { get; set; }
public Style TabPageStyle { get; set; }
public override Style SelectStyle(object item, DependencyObject container)
{
if (item is DocumentModel)
return DocumentStyle;
if (item is TabPageModel)
return TabPageStyle;
if (item is ToolPaneModel)
return ToolPaneStyle;

5
ILSpy/ILSpy.csproj

@ -141,11 +141,11 @@ @@ -141,11 +141,11 @@
<Compile Include="DebugSteps.xaml.cs">
<DependentUpon>DebugSteps.xaml</DependentUpon>
</Compile>
<Compile Include="Docking\ActiveDocumentConverter.cs" />
<Compile Include="Docking\ActiveTabPageConverter.cs" />
<Compile Include="Docking\CloseAllDocumentsCommand.cs" />
<Compile Include="ViewModels\AssemblyListPaneModel.cs" />
<Compile Include="Docking\DockLayoutSettings.cs" />
<Compile Include="ViewModels\DocumentModel.cs" />
<Compile Include="ViewModels\TabPageModel.cs" />
<Compile Include="Docking\PaneCollection.cs" />
<Compile Include="ViewModels\PaneModel.cs" />
<Compile Include="Docking\PaneStyleSelector.cs" />
@ -184,7 +184,6 @@ @@ -184,7 +184,6 @@
<Generator>MSBuild:Compile</Generator>
</Compile>
<Compile Include="Options\DecompilerSettingsPanel.xaml.cs" />
<Compile Include="Docking\PanePosition.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>

18
ILSpy/MainWindow.xaml

@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
>
<Window.Resources>
<controls:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<docking:ActiveDocumentConverter x:Key="ActiveDocumentConverter"/>
<docking:ActiveTabPageConverter x:Key="ActiveTabPageConverter"/>
<tv:SharpTreeView x:Key="TreeView"
AutomationProperties.Name="Assemblies and Classes"
@ -55,8 +55,8 @@ @@ -55,8 +55,8 @@
<ContentControl Content="{StaticResource AnalyzerTreeView}" />
</DataTemplate>
<DataTemplate x:Key="DecompilerTextViewTemplate">
<textview:DecompilerTextView DataContext="{Binding}" />
<DataTemplate x:Key="DefaultContentTemplate">
<ContentPresenter Content="{Binding Content}" />
</DataTemplate>
</Window.Resources>
@ -132,10 +132,12 @@ @@ -132,10 +132,12 @@
</CheckBox>
<Separator />
<ComboBox Name="languageComboBox" DisplayMemberPath="Name" Width="100" MaxDropDownHeight="Auto"
IsEnabled="{Binding ActiveTabPage.SupportsLanguageSwitching, Source={x:Static docking:DockWorkspace.Instance}}"
ItemsSource="{x:Static local:Languages.AllLanguages}" ToolTip="{x:Static properties:Resources.SelectLanguageDropdownTooltip}"
SelectedItem="{Binding SessionSettings.FilterSettings.Language}"/>
<ComboBox Name="languageVersionComboBox" DisplayMemberPath="DisplayName" Width="120" MaxDropDownHeight="Auto" ToolTip="{x:Static properties:Resources.SelectVersionDropdownTooltip}"
Visibility="{Binding SelectedItem.HasLanguageVersions, ElementName=languageComboBox, Converter={StaticResource BooleanToVisibilityConverter}}"
IsEnabled="{Binding ActiveTabPage.SupportsLanguageSwitching, Source={x:Static docking:DockWorkspace.Instance}}"
ItemsSource="{Binding SelectedItem.LanguageVersions, ElementName=languageComboBox, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding SessionSettings.FilterSettings.LanguageVersion, UpdateSourceTrigger=PropertyChanged}"/>
</ToolBar>
@ -162,8 +164,8 @@ @@ -162,8 +164,8 @@
<avalondock:DockingManager x:Name="DockManager"
DataContext="{Binding Workspace}"
AnchorablesSource="{Binding ToolPanes}"
DocumentsSource="{Binding Documents}"
ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}"
DocumentsSource="{Binding TabPages}"
ActiveContent="{Binding ActiveTabPage, Mode=TwoWay, Converter={StaticResource ActiveTabPageConverter}}"
AllowMixedOrientation="True">
<avalondock:DockingManager.DocumentHeaderTemplate>
@ -184,7 +186,7 @@ @@ -184,7 +186,7 @@
<docking:TemplateMapping Type="{x:Type viewmodels:SearchPaneModel}" Template="{StaticResource SearchPaneTemplate}" />
<docking:TemplateMapping Type="{x:Type viewmodels:DebugStepsPaneModel}" Template="{StaticResource DebugStepsPaneTemplate}" />
<docking:TemplateMapping Type="{x:Type viewmodels:AnalyzerPaneModel}" Template="{StaticResource AnalyzerPaneTemplate}" />
<docking:TemplateMapping Type="{x:Type viewmodels:DecompiledDocumentModel}" Template="{StaticResource DecompilerTextViewTemplate}" />
<docking:TemplateMapping Type="{x:Type viewmodels:TabPageModel}" Template="{StaticResource DefaultContentTemplate}" />
</docking:PaneTemplateSelector.Mappings>
</docking:PaneTemplateSelector>
</avalondock:DockingManager.LayoutItemTemplateSelector>
@ -203,7 +205,7 @@ @@ -203,7 +205,7 @@
<Setter Property="CanClose" Value="{Binding Model.IsCloseable}" />
</Style>
</docking:PaneStyleSelector.ToolPaneStyle>
<docking:PaneStyleSelector.DocumentStyle>
<docking:PaneStyleSelector.TabPageStyle>
<Style TargetType="{x:Type avalondock:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
@ -213,7 +215,7 @@ @@ -213,7 +215,7 @@
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
<Setter Property="CanClose" Value="{Binding Model.IsCloseable, Mode=TwoWay}" />
</Style>
</docking:PaneStyleSelector.DocumentStyle>
</docking:PaneStyleSelector.TabPageStyle>
</docking:PaneStyleSelector>
</avalondock:DockingManager.LayoutItemContainerStyleSelector>
</avalondock:DockingManager>

28
ILSpy/MainWindow.xaml.cs

@ -392,7 +392,7 @@ namespace ICSharpCode.ILSpy @@ -392,7 +392,7 @@ namespace ICSharpCode.ILSpy
// only if not showing the about page, perform the update check:
await ShowMessageIfUpdatesAvailableAsync(spySettings);
} else {
AboutPage.Display(DockWorkspace.Instance.GetTextView());
DockWorkspace.Instance.ActiveTabPage.ShowTextView(AboutPage.Display);
}
}
}
@ -453,11 +453,11 @@ namespace ICSharpCode.ILSpy @@ -453,11 +453,11 @@ namespace ICSharpCode.ILSpy
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
DockWorkspace.Instance.Documents.Add(new DecompiledDocumentModel() {
DockWorkspace.Instance.TabPages.Add(new TabPageModel() {
Language = CurrentLanguage,
LanguageVersion = CurrentLanguageVersion
});
DockWorkspace.Instance.ActiveDocument = DockWorkspace.Instance.Documents.First();
DockWorkspace.Instance.ActiveTabPage = DockWorkspace.Instance.TabPages.First();
ILSpySettings spySettings = this.spySettingsForMainWindow_Loaded;
this.spySettingsForMainWindow_Loaded = null;
@ -930,7 +930,7 @@ namespace ICSharpCode.ILSpy @@ -930,7 +930,7 @@ namespace ICSharpCode.ILSpy
Task decompilationTask;
bool ignoreDecompilationRequests;
void DecompileSelectedNodes(DecompilerTextViewState state = null, bool recordHistory = true)
void DecompileSelectedNodes(DecompilerTextViewState newState = null, bool recordHistory = true)
{
if (ignoreDecompilationRequests)
return;
@ -939,18 +939,20 @@ namespace ICSharpCode.ILSpy @@ -939,18 +939,20 @@ namespace ICSharpCode.ILSpy
return;
if (recordHistory) {
var dtState = DockWorkspace.Instance.GetState();
if (dtState != null)
history.UpdateCurrent(new NavigationState(dtState));
var currentState = DockWorkspace.Instance.ActiveTabPage.GetState();
if (currentState != null)
history.UpdateCurrent(new NavigationState(currentState));
history.Record(new NavigationState(treeView.SelectedItems.OfType<SharpTreeNode>()));
}
DockWorkspace.Instance.ActiveTabPage.SupportsLanguageSwitching = true;
if (treeView.SelectedItems.Count == 1) {
ILSpyTreeNode node = treeView.SelectedItem as ILSpyTreeNode;
if (node != null && node.View(DockWorkspace.Instance.GetTextView()))
if (node != null && node.View(DockWorkspace.Instance.ActiveTabPage))
return;
}
decompilationTask = DockWorkspace.Instance.GetTextView().DecompileAsync(this.CurrentLanguage, this.SelectedNodes, new DecompilationOptions() { TextViewState = state });
decompilationTask = DockWorkspace.Instance.ActiveTabPage.ShowTextViewAsync(textView => textView.DecompileAsync(this.CurrentLanguage, this.SelectedNodes, new DecompilationOptions() { TextViewState = newState }));
}
void SaveCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
@ -1017,9 +1019,9 @@ namespace ICSharpCode.ILSpy @@ -1017,9 +1019,9 @@ namespace ICSharpCode.ILSpy
void NavigateHistory(bool forward)
{
var dtState = DockWorkspace.Instance.GetState();
if (dtState != null)
history.UpdateCurrent(new NavigationState(dtState));
var state = DockWorkspace.Instance.ActiveTabPage.GetState();
if (state != null)
history.UpdateCurrent(new NavigationState(state));
var newState = forward ? history.GoForward() : history.GoBack();
ignoreDecompilationRequests = true;
@ -1030,7 +1032,7 @@ namespace ICSharpCode.ILSpy @@ -1030,7 +1032,7 @@ namespace ICSharpCode.ILSpy
if (newState.TreeNodes.Any())
treeView.FocusNode(newState.TreeNodes.First());
ignoreDecompilationRequests = false;
DecompileSelectedNodes(newState.ViewState, false);
DecompileSelectedNodes(newState.ViewState as DecompilerTextViewState, false);
}
#endregion

6
ILSpy/Metadata/CoffHeaderTreeNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.Decompiler; @@ -25,6 +25,7 @@ using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Metadata
{
@ -41,8 +42,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -41,8 +42,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
var dataGrid = new DataGrid {
Columns = {
new DataGridTextColumn { IsReadOnly = true, Header = "Member", Binding = new Binding("Member") },
@ -71,7 +73,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -71,7 +73,7 @@ namespace ICSharpCode.ILSpy.Metadata
dataGrid.ItemsSource = entries;
textView.ShowContent(new[] { this }, dataGrid);
tabPage.Content = dataGrid;
return true;
}

7
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

@ -41,8 +41,11 @@ namespace ICSharpCode.ILSpy.Metadata @@ -41,8 +41,11 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.Title = Text.ToString();
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("AssemblyRefView");
var metadata = module.Metadata;
@ -55,7 +58,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -55,7 +58,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/AssemblyTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("AssemblyView");
var metadata = module.Metadata;
@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

8
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.IL; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Metadata
{
@ -42,20 +43,21 @@ namespace ICSharpCode.ILSpy.Metadata @@ -42,20 +43,21 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ConstantsView");
var metadata = module.Metadata;
var list = new List<ConstantEntry>();
for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.Constant); row++) {
for (int row = 1; row <= metadata.GetTableRowCount(TableIndex.Constant); row++) {
list.Add(new ConstantEntry(module, MetadataTokens.ConstantHandle(row)));
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("CustomAttributesView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("DeclSecurityAttrsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/EventTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("EventDefsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/ExportedTypeTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ExportedTypesView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/FieldLayoutTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("FieldLayoutsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/FieldTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("FieldDefsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/FileTableTreeNode.cs

@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("FilesView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/GenericParamConstraintTableTreeNode.cs

@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("GenericParamConstraintsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/GenericParamTableTreeNode.cs

@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("GenericParamsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
}
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/ManifestResourceTableTreeNode.cs

@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ManifestResourcesView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/MemberRefTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("MemberRefsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/MethodImplTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("MethodImplView");
var metadata = module.Metadata;
@ -61,7 +62,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -61,7 +62,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/MethodSemanticsTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("MethodSemanticsView");
var metadata = module.Metadata;
@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/MethodSpecTableTreeNode.cs

@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("MethodSpecsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("MethodDefsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/ModuleRefTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ModuleRefsView");
var metadata = module.Metadata;
@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs

@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -48,8 +48,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ModulesView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/ParamTableTreeNode.cs

@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("ParamsView");
var metadata = module.Metadata;
@ -63,7 +64,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -63,7 +64,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/PropertyTableTreeNode.cs

@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,8 +47,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("PropertyDefsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/StandAloneSigTableTreeNode.cs

@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -46,8 +46,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("StandAloneSigsView");
var metadata = module.Metadata;
@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -59,7 +60,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -51,8 +51,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -51,8 +51,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("TypeDefsView");
var metadata = module.Metadata;
@ -63,7 +64,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -63,7 +64,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/TypeRefTableTreeNode.cs

@ -49,8 +49,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -49,8 +49,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("TypeRefsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/CorTables/TypeSpecTableTreeNode.cs

@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -50,8 +50,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
ListView view = Helpers.CreateListView("TypeSpecsView");
var metadata = module.Metadata;
@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -62,7 +63,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = list;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

5
ILSpy/Metadata/DataDirectoriesTreeNode.cs

@ -39,8 +39,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -39,8 +39,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
var dataGrid = new DataGrid {
Columns = {
new DataGridTextColumn { IsReadOnly = true, Header = "Name", Binding = new Binding("Name") },
@ -76,7 +77,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -76,7 +77,7 @@ namespace ICSharpCode.ILSpy.Metadata
dataGrid.ItemsSource = entries;
textView.ShowContent(new[] { this }, dataGrid);
tabPage.Content = dataGrid;
return true;
}

7
ILSpy/Metadata/DosHeaderTreeNode.cs

@ -21,8 +21,8 @@ using System.Windows.Controls; @@ -21,8 +21,8 @@ using System.Windows.Controls;
using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Metadata
{
@ -39,8 +39,9 @@ namespace ICSharpCode.ILSpy.Metadata @@ -39,8 +39,9 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
var view = Helpers.CreateListView("EntryView");
var reader = module.Reader.GetEntireImage().GetReader(0, 64);
@ -80,7 +81,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -80,7 +81,7 @@ namespace ICSharpCode.ILSpy.Metadata
view.ItemsSource = entries;
textView.ShowContent(new[] { this }, view);
tabPage.Content = view;
return true;
}

7
ILSpy/Metadata/MetadataTreeNode.cs

@ -28,6 +28,7 @@ using System.Windows.Data; @@ -28,6 +28,7 @@ using System.Windows.Data;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Metadata
{
@ -47,6 +48,12 @@ namespace ICSharpCode.ILSpy.Metadata @@ -47,6 +48,12 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Library;
public override bool View(TabPageModel tabPage)
{
tabPage.SupportsLanguageSwitching = false;
return false;
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.WriteCommentLine(output, "Metadata");

4
ILSpy/Metadata/OptionalHeaderTreeNode.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.Metadata
public override object Icon => Images.Literal;
public override bool View(DecompilerTextView textView)
public override bool View(ViewModels.TabPageModel tabPage)
{
var dataGrid = new DataGrid {
Columns = {
@ -95,7 +95,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -95,7 +95,7 @@ namespace ICSharpCode.ILSpy.Metadata
dataGrid.ItemsSource = entries;
textView.ShowContent(new[] { this }, dataGrid);
tabPage.Content = dataGrid;
return true;
}

4
ILSpy/NavigationState.cs

@ -28,9 +28,9 @@ namespace ICSharpCode.ILSpy @@ -28,9 +28,9 @@ namespace ICSharpCode.ILSpy
private readonly HashSet<SharpTreeNode> treeNodes;
public IEnumerable<SharpTreeNode> TreeNodes { get { return treeNodes; } }
public DecompilerTextViewState ViewState { get; private set; }
public ViewState ViewState { get; private set; }
public NavigationState(DecompilerTextViewState viewState)
public NavigationState(ViewState viewState)
{
this.treeNodes = new HashSet<SharpTreeNode>(viewState.DecompiledNodes);
ViewState = viewState;

27
ILSpy/TextView/DecompilerTextView.cs

@ -559,9 +559,6 @@ namespace ICSharpCode.ILSpy.TextView @@ -559,9 +559,6 @@ namespace ICSharpCode.ILSpy.TextView
/// </summary>
public void ShowNodes(AvalonEditTextOutput textOutput, ILSpyTreeNode[] nodes, IHighlightingDefinition highlighting = null)
{
textEditor.Visibility = Visibility.Visible;
dynamicContent.Visibility = Visibility.Hidden;
dynamicContent.Content = null;
// Cancel the decompilation task:
if (currentCancellationTokenSource != null) {
currentCancellationTokenSource.Cancel();
@ -583,10 +580,6 @@ namespace ICSharpCode.ILSpy.TextView @@ -583,10 +580,6 @@ namespace ICSharpCode.ILSpy.TextView
/// </summary>
void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null)
{
textEditor.Visibility = Visibility.Visible;
dynamicContent.Visibility = Visibility.Hidden;
dynamicContent.Content = null;
Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength);
Stopwatch w = Stopwatch.StartNew();
@ -645,14 +638,6 @@ namespace ICSharpCode.ILSpy.TextView @@ -645,14 +638,6 @@ namespace ICSharpCode.ILSpy.TextView
model.Title = textOutput.Title;
}
}
public void ShowContent(ILSpyTreeNode[] nodes, object content)
{
textEditor.Visibility = Visibility.Collapsed;
dynamicContent.Visibility = Visibility.Visible;
dynamicContent.Content = content;
decompiledNodes = nodes;
}
#endregion
#region Decompile (for display)
@ -1060,23 +1045,19 @@ namespace ICSharpCode.ILSpy.TextView @@ -1060,23 +1045,19 @@ namespace ICSharpCode.ILSpy.TextView
}
}
#endregion
}
private void self_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
public class ViewState
{
if (e.OldValue is DecompiledDocumentModel oldModel)
oldModel.TextView = null;
if (e.NewValue is DecompiledDocumentModel newModel)
newModel.TextView = this;
}
public ILSpyTreeNode[] DecompiledNodes;
}
public class DecompilerTextViewState
public class DecompilerTextViewState : ViewState
{
private List<Tuple<int, int>> ExpandedFoldings;
private int FoldingsChecksum;
public double VerticalOffset;
public double HorizontalOffset;
public ILSpyTreeNode[] DecompiledNodes;
public void SaveFoldingsState(IEnumerable<FoldingSection> foldings)
{

4
ILSpy/TextView/DecompilerTextView.xaml

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties"
xmlns:ae="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
DataContextChanged="self_DataContextChanged">
xmlns:ae="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="boolToVisibility" />
</UserControl.Resources>
@ -18,7 +17,6 @@ @@ -18,7 +17,6 @@
<Style TargetType="{x:Type Button}" />
</ae:TextEditor.Resources>
</ae:TextEditor>
<ContentControl Name="dynamicContent" />
<Border Name="waitAdorner" Background="#C0FFFFFF" Visibility="Collapsed">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="14pt" Text="{x:Static properties:Resources.Decompiling}"/>

5
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -32,6 +32,7 @@ using Microsoft.Win32; @@ -32,6 +32,7 @@ using Microsoft.Win32;
using ICSharpCode.Decompiler.TypeSystem;
using TypeDefinitionHandle = System.Reflection.Metadata.TypeDefinitionHandle;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -276,7 +277,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -276,7 +277,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
language.DecompileAssembly(LoadedAssembly, output, options);
}
public override bool Save(DecompilerTextView textView)
public override bool Save(TabPageModel tabPage)
{
Language language = this.Language;
if (string.IsNullOrEmpty(language.ProjectFileExtension))
@ -301,7 +302,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -301,7 +302,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
}
textView.SaveToDisk(language, new[] { this }, options, dlg.FileName);
tabPage.ShowTextView(textView => textView.SaveToDisk(language, new[] { this }, options, dlg.FileName));
}
return true;
}

4
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -64,7 +64,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// This method is called on the main thread when only a single item is selected.
/// If it returns false, normal decompilation is used to view the item.
/// </summary>
public virtual bool View(TextView.DecompilerTextView textView)
public virtual bool View(ViewModels.TabPageModel tabPage)
{
return false;
}
@ -74,7 +74,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -74,7 +74,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// This method is called on the main thread when only a single item is selected.
/// If it returns false, normal decompilation is used to save the item.
/// </summary>
public virtual bool Save(TextView.DecompilerTextView textView)
public virtual bool Save(ViewModels.TabPageModel tabPage)
{
return false;
}

6
ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs

@ -24,6 +24,7 @@ using System.Windows.Media.Imaging; @@ -24,6 +24,7 @@ using System.Windows.Media.Imaging;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -61,7 +62,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -61,7 +62,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override object Icon => Images.ResourceImage;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
try {
AvalonEditTextOutput output = new AvalonEditTextOutput();
@ -90,7 +91,8 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -90,7 +91,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
output.AddButton(Images.Save, Resources.Save, delegate {
Save(null);
});
textView.ShowNode(output, this);
tabPage.ShowTextView(textView => textView.ShowNode(output, this));
tabPage.SupportsLanguageSwitching = false;
return true;
}
catch (Exception) {

6
ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

@ -24,6 +24,7 @@ using System.Windows.Media.Imaging; @@ -24,6 +24,7 @@ using System.Windows.Media.Imaging;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -60,7 +61,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override object Icon => Images.ResourceImage;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
try {
AvalonEditTextOutput output = new AvalonEditTextOutput();
@ -74,7 +75,8 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -74,7 +75,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
output.AddButton(Images.Save, Resources.Save, delegate {
Save(null);
});
textView.ShowNode(output, this);
tabPage.ShowTextView(textView => textView.ShowNode(output, this));
tabPage.SupportsLanguageSwitching = false;
return true;
} catch (Exception) {
return false;

6
ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs

@ -24,6 +24,7 @@ using System.Windows.Media.Imaging; @@ -24,6 +24,7 @@ using System.Windows.Media.Imaging;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -67,7 +68,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -67,7 +68,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override object Icon => Images.ResourceImage;
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
try {
AvalonEditTextOutput output = new AvalonEditTextOutput();
@ -81,7 +82,8 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -81,7 +82,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
output.AddButton(Images.Save, Resources.Save, delegate {
Save(null);
});
textView.ShowNode(output, this);
tabPage.ShowTextView(textView => textView.ShowNode(output, this));
tabPage.SupportsLanguageSwitching = false;
return true;
}
catch (Exception) {

2
ILSpy/TreeNodes/ResourceNodes/ResourceEntryNode.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
language.WriteCommentLine(output, string.Format("{0} = {1}", key, data));
}
public override bool Save(DecompilerTextView textView)
public override bool Save(ViewModels.TabPageModel tabPage)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(key));

10
ILSpy/TreeNodes/ResourceNodes/ResourceTreeNode.cs

@ -26,6 +26,7 @@ using ICSharpCode.Decompiler; @@ -26,6 +26,7 @@ using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.ViewModels;
using Microsoft.Win32;
namespace ICSharpCode.ILSpy.TreeNodes
@ -65,12 +66,12 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -65,12 +66,12 @@ namespace ICSharpCode.ILSpy.TreeNodes
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (smartOutput != null) {
smartOutput.AddButton(Images.Save, Resources.Save, delegate { Save(Docking.DockWorkspace.Instance.GetTextView()); });
smartOutput.AddButton(Images.Save, Resources.Save, delegate { Save(Docking.DockWorkspace.Instance.ActiveTabPage); });
output.WriteLine();
}
}
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
Stream s = Resource.TryOpenStream();
if (s != null && s.Length < DecompilerTextView.DefaultOutputLengthLimit) {
@ -85,14 +86,15 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -85,14 +86,15 @@ namespace ICSharpCode.ILSpy.TreeNodes
ext = ".xml";
else
ext = Path.GetExtension(DecompilerTextView.CleanUpName(Resource.Name));
textView.ShowNode(output, this, HighlightingManager.Instance.GetDefinitionByExtension(ext));
tabPage.ShowTextView(textView => textView.ShowNode(output, this, HighlightingManager.Instance.GetDefinitionByExtension(ext)));
tabPage.SupportsLanguageSwitching = false;
return true;
}
}
return false;
}
public override bool Save(DecompilerTextView textView)
public override bool Save(TabPageModel tabPage)
{
Stream s = Resource.TryOpenStream();
if (s == null)

8
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -29,6 +29,7 @@ using ICSharpCode.ILSpy.Controls; @@ -29,6 +29,7 @@ using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using Microsoft.Win32;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.TreeNodes
{
@ -105,7 +106,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -105,7 +106,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
public override bool Save(DecompilerTextView textView)
public override bool Save(TabPageModel tabPage)
{
Stream s = Resource.TryOpenStream();
if (s == null) return false;
@ -144,12 +145,13 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -144,12 +145,13 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
EnsureLazyChildren();
base.Decompile(language, output, options);
var textView = (DecompilerTextView)Docking.DockWorkspace.Instance.ActiveTabPage.Content;
if (stringTableEntries.Count != 0) {
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
return new ResourceStringTable(stringTableEntries, Docking.DockWorkspace.Instance.GetTextView());
return new ResourceStringTable(stringTableEntries, textView);
}
);
}
@ -161,7 +163,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -161,7 +163,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
return new ResourceObjectTable(otherEntries, Docking.DockWorkspace.Instance.GetTextView());
return new ResourceObjectTable(otherEntries, textView);
}
);
}

8
ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.AvalonEdit.Highlighting; @@ -25,6 +25,7 @@ using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Xaml
{
@ -53,12 +54,12 @@ namespace ICSharpCode.ILSpy.Xaml @@ -53,12 +54,12 @@ namespace ICSharpCode.ILSpy.Xaml
{
}
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
IHighlightingDefinition highlighting = null;
textView.RunWithCancellation(
tabPage.ShowTextView(textView => textView.RunWithCancellation(
token => Task.Factory.StartNew(
() => {
try {
@ -75,7 +76,8 @@ namespace ICSharpCode.ILSpy.Xaml @@ -75,7 +76,8 @@ namespace ICSharpCode.ILSpy.Xaml
}
return output;
}, token)
).Then(t => textView.ShowNode(t, this, highlighting)).HandleExceptions();
).Then(t => textView.ShowNode(t, this, highlighting)).HandleExceptions());
tabPage.SupportsLanguageSwitching = false;
return true;
}
}

9
ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

@ -25,6 +25,7 @@ using ICSharpCode.AvalonEdit.Highlighting; @@ -25,6 +25,7 @@ using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpy.ViewModels;
namespace ICSharpCode.ILSpy.Xaml
{
@ -79,12 +80,12 @@ namespace ICSharpCode.ILSpy.Xaml @@ -79,12 +80,12 @@ namespace ICSharpCode.ILSpy.Xaml
}
}
public override bool View(DecompilerTextView textView)
public override bool View(TabPageModel tabPage)
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
IHighlightingDefinition highlighting = null;
textView.RunWithCancellation(
tabPage.ShowTextView(textView => textView.RunWithCancellation(
token => Task.Factory.StartNew(
() => {
try {
@ -102,7 +103,9 @@ namespace ICSharpCode.ILSpy.Xaml @@ -102,7 +103,9 @@ namespace ICSharpCode.ILSpy.Xaml
}
return output;
}, token)
).Then(t => textView.ShowNode(t, this, highlighting)).HandleExceptions();
).Then(t => textView.ShowNode(t, this, highlighting))
.HandleExceptions());
tabPage.SupportsLanguageSwitching = false;
return true;
}
}

2
ILSpy/ViewModels/AnalyzerPaneModel.cs

@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels
public static AnalyzerPaneModel Instance { get; } = new AnalyzerPaneModel();
public override PanePosition DefaultPosition => PanePosition.Bottom;
private AnalyzerPaneModel()
{
ContentId = PaneContentId;

2
ILSpy/ViewModels/AssemblyListPaneModel.cs

@ -26,8 +26,6 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -26,8 +26,6 @@ namespace ICSharpCode.ILSpy.ViewModels
public static AssemblyListPaneModel Instance { get; } = new AssemblyListPaneModel();
public override PanePosition DefaultPosition => PanePosition.Left;
private AssemblyListPaneModel()
{
Title = Resources.Assemblies;

2
ILSpy/ViewModels/DebugStepsPaneModel.cs

@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels
public static DebugStepsPaneModel Instance { get; } = new DebugStepsPaneModel();
public override PanePosition DefaultPosition => PanePosition.Top;
private DebugStepsPaneModel()
{
ContentId = PaneContentId;

2
ILSpy/ViewModels/PaneModel.cs

@ -59,8 +59,6 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -59,8 +59,6 @@ namespace ICSharpCode.ILSpy.ViewModels
this.closeCommand = new CloseCommandImpl(this);
}
public abstract PanePosition DefaultPosition { get; }
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)

2
ILSpy/ViewModels/SearchPaneModel.cs

@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -24,8 +24,6 @@ namespace ICSharpCode.ILSpy.ViewModels
public static SearchPaneModel Instance { get; } = new SearchPaneModel();
public override PanePosition DefaultPosition => PanePosition.Top;
private SearchPaneModel()
{
ContentId = PaneContentId;

89
ILSpy/ViewModels/DocumentModel.cs → ILSpy/ViewModels/TabPageModel.cs

@ -16,45 +16,15 @@ @@ -16,45 +16,15 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.ILSpy.Properties;
using System;
using System.Threading.Tasks;
using System.Windows;
using ICSharpCode.ILSpy.TextView;
namespace ICSharpCode.ILSpy.ViewModels
{
public abstract class DocumentModel : PaneModel
public class TabPageModel : PaneModel
{
public override PanePosition DefaultPosition => PanePosition.Document;
protected DocumentModel(string contentId, string title)
{
this.ContentId = contentId;
this.Title = title;
}
}
public class DecompiledDocumentModel : DocumentModel
{
public DecompiledDocumentModel()
: base("//Decompiled", Resources.View)
{
}
public DecompiledDocumentModel(string id, string title)
: base("//Decompiled/" + id, title)
{
}
private DecompilerTextView textView;
public DecompilerTextView TextView {
get => textView;
set {
if (textView != value) {
textView = value;
RaisePropertyChanged(nameof(TextView));
}
}
}
private Language language;
public Language Language {
get => language;
@ -76,5 +46,56 @@ namespace ICSharpCode.ILSpy.ViewModels @@ -76,5 +46,56 @@ namespace ICSharpCode.ILSpy.ViewModels
}
}
}
private bool supportsLanguageSwitching = true;
public bool SupportsLanguageSwitching {
get => supportsLanguageSwitching;
set {
if (supportsLanguageSwitching != value) {
supportsLanguageSwitching = value;
RaisePropertyChanged(nameof(SupportsLanguageSwitching));
}
}
}
private object content;
public object Content {
get => content;
set {
if (content != value) {
content = value;
RaisePropertyChanged(nameof(Content));
}
}
}
public ViewState GetState()
{
return null;
}
}
public static class TabPageModelExtensions
{
public static Task<T> ShowTextViewAsync<T>(this TabPageModel tabPage, Func<DecompilerTextView, Task<T>> action)
{
var textView = new DecompilerTextView();
tabPage.Content = textView;
return action(textView);
}
public static Task ShowTextViewAsync(this TabPageModel tabPage, Func<DecompilerTextView, Task> action)
{
var textView = new DecompilerTextView();
tabPage.Content = textView;
return action(textView);
}
public static void ShowTextView(this TabPageModel tabPage, Action<DecompilerTextView> action)
{
var textView = new DecompilerTextView();
tabPage.Content = textView;
action(textView);
}
}
}
Loading…
Cancel
Save