Replace ReactiveUI
This commit is contained in:
parent
43b4d50e43
commit
5584ab4ec8
41 changed files with 472 additions and 1013 deletions
|
|
@ -1,48 +1,38 @@
|
|||
using Avalonia;
|
||||
using AvaloniaEdit.Document;
|
||||
|
||||
using Dock.Model.Core;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Dock.Model.Controls;
|
||||
|
||||
using InkForge.Desktop.Models;
|
||||
using InkForge.Desktop.ViewModels.Documents;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
namespace InkForge.Desktop.Managers;
|
||||
|
||||
public class DocumentManager
|
||||
public partial class DocumentManager
|
||||
{
|
||||
private readonly IDock _documents;
|
||||
private readonly InkForgeFactory _factory;
|
||||
private readonly WelcomePageDocumentViewModel _welcomePage;
|
||||
private readonly WorkspaceManager _workspaceManager;
|
||||
|
||||
public DocumentManager(WorkspaceManager workspaceManager, InkForgeFactory factory)
|
||||
public IDocumentDock Dock { get; }
|
||||
|
||||
public DocumentManager(NoteStore noteStore, InkForgeFactory factory)
|
||||
{
|
||||
_workspaceManager = workspaceManager;
|
||||
_factory = factory;
|
||||
_documents = factory.GetDockable<IDock>("Documents")!;
|
||||
_welcomePage = CreateWelcomePageDocumentViewModel();
|
||||
workspaceManager.WhenAnyValue(v => v.Workspace).Subscribe(OnWorkspaceChanged);
|
||||
Dock = factory.CreateDocumentDock();
|
||||
Dock.IsCollapsable = false;
|
||||
Dock.CanCreateDocument = true;
|
||||
Dock.CreateDocument = CreateDocumentCommand;
|
||||
}
|
||||
|
||||
private void OnWorkspaceChanged(Workspace? workspace)
|
||||
[RelayCommand]
|
||||
private void OnCreateDocument()
|
||||
{
|
||||
if (workspace is null)
|
||||
NoteEditDocumentViewModel editViewModel = new(new()
|
||||
{
|
||||
_factory.AddDockable(_documents, _welcomePage);
|
||||
}
|
||||
else
|
||||
{
|
||||
_factory.RemoveDockable(_welcomePage, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static WelcomePageDocumentViewModel CreateWelcomePageDocumentViewModel()
|
||||
{
|
||||
return ActivatorUtilities.CreateInstance<WelcomePageDocumentViewModel>(
|
||||
Application.Current!.GetValue(App.ServiceProviderProperty)
|
||||
);
|
||||
Name = "Untitled Note",
|
||||
}, new());
|
||||
_factory.AddDockable(Dock, editViewModel);
|
||||
_factory.SetActiveDockable(editViewModel);
|
||||
_factory.SetFocusedDockable(Dock, editViewModel);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue