InkForge/app/InkForge.Desktop/Managers/DocumentManager.cs

39 lines
875 B
C#
Raw Normal View History

2024-05-02 21:44:13 +02:00
using AvaloniaEdit.Document;
2024-03-17 22:27:01 +01:00
2024-05-02 21:44:13 +02:00
using CommunityToolkit.Mvvm.Input;
using Dock.Model.Controls;
2024-03-17 22:27:01 +01:00
using InkForge.Desktop.Models;
using InkForge.Desktop.ViewModels.Documents;
2024-02-26 18:08:18 +01:00
namespace InkForge.Desktop.Managers;
2024-05-02 21:44:13 +02:00
public partial class DocumentManager
2024-02-26 18:08:18 +01:00
{
2024-03-17 22:27:01 +01:00
private readonly InkForgeFactory _factory;
2024-02-26 18:08:18 +01:00
2024-05-02 21:44:13 +02:00
public IDocumentDock Dock { get; }
public DocumentManager(NoteStore noteStore, InkForgeFactory factory)
2024-02-26 18:08:18 +01:00
{
2024-03-17 22:27:01 +01:00
_factory = factory;
2024-05-02 21:44:13 +02:00
Dock = factory.CreateDocumentDock();
Dock.IsCollapsable = false;
Dock.CanCreateDocument = true;
Dock.CreateDocument = CreateDocumentCommand;
2024-03-17 22:27:01 +01:00
}
2024-05-02 21:44:13 +02:00
[RelayCommand]
private void OnCreateDocument()
2024-03-17 22:27:01 +01:00
{
2024-05-02 21:44:13 +02:00
NoteEditDocumentViewModel editViewModel = new(new()
2024-03-17 22:27:01 +01:00
{
2024-05-02 21:44:13 +02:00
Name = "Untitled Note",
}, new());
_factory.AddDockable(Dock, editViewModel);
_factory.SetActiveDockable(editViewModel);
_factory.SetFocusedDockable(Dock, editViewModel);
2024-02-26 18:08:18 +01:00
}
}