Replace ReactiveUI
This commit is contained in:
parent
43b4d50e43
commit
5584ab4ec8
41 changed files with 472 additions and 1013 deletions
|
|
@ -1,3 +1,9 @@
|
|||
using System.Collections.ObjectModel;
|
||||
|
||||
using Avalonia;
|
||||
|
||||
using DynamicData;
|
||||
|
||||
using InkForge.Desktop.Models;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -6,30 +12,24 @@ namespace InkForge.Desktop.ViewModels.Workspaces
|
|||
{
|
||||
public class WorkspaceViewModel
|
||||
{
|
||||
private readonly Workspace _workspace;
|
||||
private readonly NoteStore _noteStore;
|
||||
// private readonly ObservableAsPropertyHelper<string> _workspaceNameProperty;
|
||||
private readonly ReadOnlyObservableCollection<Node<Note, int>> _notes;
|
||||
|
||||
// public string WorkspaceName => _workspaceNameProperty.Value;
|
||||
public string Name => _workspace.Name;
|
||||
|
||||
// public ReactiveCommand<Unit, Unit> AddDocument { get; }
|
||||
public ReadOnlyObservableCollection<Node<Note, int>> Notes => _notes;
|
||||
|
||||
public WorkspaceViewModel(NoteStore noteStore)
|
||||
public WorkspaceViewModel(Workspace workspace, NoteStore noteStore)
|
||||
{
|
||||
_workspace = workspace;
|
||||
_noteStore = noteStore;
|
||||
noteStore.Notes
|
||||
.AsObservableChangeSet(m => m.Key)
|
||||
.Transform(m => m.Value, true)
|
||||
.TransformToTree(m => m.Id)
|
||||
.Bind(out _notes).Subscribe();
|
||||
}
|
||||
|
||||
// public WorkspacesViewModel(Workspace workspace)
|
||||
// {
|
||||
// _workspace = workspace;
|
||||
// _workspaceNameProperty = this.WhenAnyValue(v => v._workspace.Name).ToProperty(this, nameof(WorkspaceName));
|
||||
|
||||
// AddDocument = ReactiveCommand.Create(OnAddDocument);
|
||||
// }
|
||||
|
||||
// private void OnAddDocument()
|
||||
// {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
public interface IWorkspaceViewModelFactory
|
||||
|
|
@ -39,14 +39,14 @@ namespace InkForge.Desktop.ViewModels.Workspaces
|
|||
|
||||
namespace Internal
|
||||
{
|
||||
internal class WorkspaceViewModelFactory(IServiceProvider services) : IWorkspaceViewModelFactory
|
||||
internal class WorkspaceViewModelFactory : IWorkspaceViewModelFactory
|
||||
{
|
||||
private static ObjectFactory<WorkspaceViewModel>? s_workspaceViewModelFactory;
|
||||
|
||||
public WorkspaceViewModel Create(Workspace workspace)
|
||||
public static WorkspaceViewModel Create(Workspace workspace)
|
||||
{
|
||||
s_workspaceViewModelFactory ??= ActivatorUtilities.CreateFactory<WorkspaceViewModel>([typeof(Workspace)]);
|
||||
return s_workspaceViewModelFactory(services, [workspace]);
|
||||
return s_workspaceViewModelFactory(workspace.Services, [workspace]);
|
||||
}
|
||||
|
||||
WorkspaceViewModel IWorkspaceViewModelFactory.Create(Workspace workspace) => Create(workspace);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue