|
@@ -1,4 +1,5 @@
|
|
|
-using CommunityToolkit.Mvvm.Input;
|
|
|
+using System.Collections.Specialized;
|
|
|
+using CommunityToolkit.Mvvm.Input;
|
|
|
using Dock.Model.Avalonia.Controls;
|
|
|
using PixiEditor.AvaloniaUI.ViewModels.Document;
|
|
|
using PixiEditor.AvaloniaUI.ViewModels.SubViewModels;
|
|
@@ -12,9 +13,20 @@ internal class PixiEditorDocumentDock : DocumentDock
|
|
|
public PixiEditorDocumentDock(FileViewModel manager)
|
|
|
{
|
|
|
this.manager = manager;
|
|
|
+ manager.Owner.DocumentManagerSubViewModel.Documents.CollectionChanged += Documents_CollectionChanged;
|
|
|
CreateDocument = new RelayCommand(CreateDockDocument);
|
|
|
}
|
|
|
|
|
|
+ private void Documents_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
+ {
|
|
|
+ DocumentViewModel documentVm = e.NewItems[^1] as DocumentViewModel;
|
|
|
+ var document = new DockDocumentViewModel(documentVm) { Title = documentVm.FileName };
|
|
|
+
|
|
|
+ Factory?.AddDockable(this, document);
|
|
|
+ Factory?.SetActiveDockable(document);
|
|
|
+ Factory?.SetFocusedDockable(this, document);
|
|
|
+ }
|
|
|
+
|
|
|
private void CreateDockDocument()
|
|
|
{
|
|
|
if (!CanCreateDocument)
|