csharpdeeb25a2 | 1 | using CommunityToolkit.Mvvm.ComponentModel; |
| 2 | |
| 3 | namespace CascadeIDE.ViewModels; |
| 4 | |
| 5 | public partial class OpenDocumentViewModel : ObservableObject |
| 6 | { |
| 7 | public OpenDocumentViewModel(string filePath, string title, string content) |
| 8 | { |
| 9 | FilePath = filePath; |
| 10 | Title = title; |
| 11 | OriginalContent = content; |
| 12 | _content = content; |
| 13 | } |
| 14 | |
| 15 | public string FilePath { get; } |
| 16 | public string Title { get; } |
| 17 | public string OriginalContent { get; private set; } |
| 18 | public string DisplayTitle => IsPinned ? $"[P] {Title}{(IsDirty ? "*" : "")}" : $"{Title}{(IsDirty ? "*" : "")}"; |
| 19 | |
| 20 | [ObservableProperty] |
| 21 | [NotifyPropertyChangedFor(nameof(DisplayTitle))] |
| 22 | private string _content; |
| 23 | |
| 24 | [ObservableProperty] |
| 25 | [NotifyPropertyChangedFor(nameof(DisplayTitle))] |
| 26 | private bool _isPinned; |
| 27 | |
| 28 | [ObservableProperty] |
| 29 | [NotifyPropertyChangedFor(nameof(DisplayTitle))] |
| 30 | private bool _isDirty; |
| 31 | |
| 32 | [ObservableProperty] |
| 33 | private int _groupIndex = 1; |
| 34 | |
| 35 | public void ReloadContent(string newContent) |
| 36 | { |
| 37 | OriginalContent = newContent ?? ""; |
| 38 | Content = OriginalContent; |
| 39 | IsDirty = false; |
| 40 | } |
| 41 | } |
| 42 | |
View only · write via MCP/CIDE