Skip to content

Commit

Permalink
Fix broken Window menu and ResetLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Dec 18, 2024
1 parent 51aac5f commit 44da7ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 10 additions & 9 deletions ILSpy/Docking/DockWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Threading;

using AvalonDock;
Expand All @@ -50,6 +51,7 @@ public class DockWorkspace : ObservableObject, ILayoutUpdateStrategy
private readonly IExportProvider exportProvider;

private readonly ObservableCollection<TabPageModel> tabPages = [];
private ReadOnlyCollection<ToolPaneModel> toolPanes;

readonly SessionSettings sessionSettings;

Expand Down Expand Up @@ -123,9 +125,11 @@ public void AddTabPage(TabPageModel tabPage = null)

public ReadOnlyObservableCollection<TabPageModel> TabPages { get; }

private ToolPaneModel[] toolPanes = [];

public ReadOnlyCollection<ToolPaneModel> ToolPanes => toolPanes.AsReadOnly();
public ReadOnlyCollection<ToolPaneModel> ToolPanes => toolPanes ??= exportProvider
.GetExportedValues<ToolPaneModel>("ToolPane")
.OrderBy(item => item.Title)
.ToArray()
.AsReadOnly();

public bool ShowToolPane(string contentId)
{
Expand Down Expand Up @@ -181,12 +185,6 @@ public void InitializeLayout()
AddTabPage();
}

toolPanes = exportProvider
.GetExportedValues<ToolPaneModel>("ToolPane")
.OrderBy(item => item.Title)
.ToArray();
OnPropertyChanged(nameof(ToolPanes));

DockingManager.LayoutUpdateStrategy = this;
XmlLayoutSerializer serializer = new XmlLayoutSerializer(DockingManager);
serializer.LayoutSerializationCallback += LayoutSerializationCallback;
Expand All @@ -198,6 +196,9 @@ public void InitializeLayout()
{
serializer.LayoutSerializationCallback -= LayoutSerializationCallback;
}

DockingManager.SetBinding(DockingManager.AnchorablesSourceProperty, new Binding(nameof(ToolPanes)));
DockingManager.SetBinding(DockingManager.DocumentsSourceProperty, new Binding(nameof(TabPages)));
}

void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
Expand Down
2 changes: 0 additions & 2 deletions ILSpy/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@

<avalondock:DockingManager x:Name="DockManager"
DataContext="{Binding Workspace}"
AnchorablesSource="{Binding ToolPanes}"
DocumentsSource="{Binding TabPages}"
ActiveContent="{Binding ActiveTabPage, Mode=TwoWay, Converter={docking:TabPageGuardConverter}}"
AllowMixedOrientation="True">

Expand Down

0 comments on commit 44da7ce

Please sign in to comment.