InkForge/app/InkForge.Desktop/ViewModels/Documents/NoteEditDocumentViewModel.cs
2024-05-02 21:44:13 +02:00

30 lines
678 B
C#

using System.Reactive.Linq;
using AvaloniaEdit.Document;
using Dock.Model.Mvvm.Controls;
using DynamicData.Binding;
using InkForge.Desktop.Models;
namespace InkForge.Desktop.ViewModels.Documents;
public class NoteEditDocumentViewModel : Document
{
public Note Note { get; }
public TextDocument Document { get; }
public NoteEditDocumentViewModel(Note note, TextDocument textDocument)
{
Note = note;
Document = textDocument;
Observable.CombineLatest(
this.WhenValueChanged(v => v.Note.Name),
this.WhenValueChanged(v => v.Document.UndoStack.IsOriginalFile),
(name, original) => original ? name : $"{name} *"
).Subscribe(title => Title = title!);
}
}