Can now edit file info

This commit is contained in:
2026-02-16 15:40:35 +09:00
parent 89ba04e6ea
commit 7f19ad8c15
6 changed files with 101 additions and 46 deletions
+24 -2
View File
@@ -22,10 +22,32 @@ namespace ReceiptPDFBuilder.ViewModels;
class EditFileViewModel : BaseViewModel
{
ReportFile _file;
ReportFile _clonedFile;
ReportFile _originalFile;
public EditFileViewModel(ReportFile file, IChangeViewModel viewModelChanger) : base(viewModelChanger)
{
_file = file;
_clonedFile = new ReportFile(file);
_originalFile = file;
}
public ReportFile OriginalFile
{
get => _originalFile;
}
public ReportFile ClonedFile
{
get => _clonedFile;
}
public void Cancel()
{
DialogHost.Close("DialogHost", null);
}
public void Save()
{
DialogHost.Close("DialogHost", ClonedFile);
}
}
+7 -1
View File
@@ -98,7 +98,7 @@ class MainViewModel : BaseViewModel, IFontResolver
ReportFiles.Add(new ReportFile()
{
Title = Path.GetFileName(filePath),
Date = DateOnly.FromDateTime(File.GetCreationTime(filePath)),
ReceiptDateTime = File.GetCreationTime(filePath),
Notes = "TEST NOTES",
FilePath = filePath,
});
@@ -125,6 +125,12 @@ class MainViewModel : BaseViewModel, IFontResolver
public async void EditFileProperties(ReportFile file)
{
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
if (result != null && result is ReportFile updatedData)
{
file.Title = updatedData.Title;
file.ReceiptDateTime = updatedData.ReceiptDateTime;
file.Notes = updatedData.Notes;
}
}
public async void BuildPDF()