31 lines
678 B
C#
31 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!);
|
||
|
|
}
|
||
|
|
}
|