diff --git a/MainWindow.axaml b/MainWindow.axaml index cc12c40..ecd21e6 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -10,9 +10,9 @@ x:DataType="vm:MainWindowViewModel" Width="800" MinWidth="400" - Height="600" - MinHeight="400"> - + diff --git a/Models/ReportFile.cs b/Models/ReportFile.cs index 93b1932..051b38e 100644 --- a/Models/ReportFile.cs +++ b/Models/ReportFile.cs @@ -7,56 +7,46 @@ namespace ReceiptPDFBuilder.Models; class ReportFile : ChangeNotifier { private string _title; - private DateOnly _date; - private DateTime _dateTime; - private DateTimeOffset _dto; + private DateTime _receiptDateTime; private string _notes; private string _filePath; public ReportFile() { _title = ""; - _date = DateOnly.FromDateTime(DateTime.Now); + _receiptDateTime = DateTime.Now; _notes = ""; _filePath = ""; } + public ReportFile(ReportFile other) + { + Title = _title = other.Title; + ReceiptDateTime = _receiptDateTime = other.ReceiptDateTime; + Notes = _notes = other.Notes; + FilePath = _filePath = other.FilePath; + } + public string Title { get => _title; set { _title = value; NotifyPropertyChanged(); } } - public DateOnly Date + public DateTime ReceiptDateTime { - get => _date; + get => _receiptDateTime; set { - _date = value; - DateTime = value.ToDateTime(TimeOnly.MinValue); - DTO = new DateTimeOffset(value.ToDateTime(TimeOnly.MinValue)); + _receiptDateTime = value; NotifyPropertyChanged(); + NotifyPropertyChanged(nameof(ReceiptDate)); } } - public DateTime DateTime + public DateOnly ReceiptDate { - get => _dateTime; - set - { - _dateTime = value; - NotifyPropertyChanged(); - } - } - - public DateTimeOffset DTO - { - get => _dto; - set - { - _dto = value; - NotifyPropertyChanged(); - } + get => DateOnly.FromDateTime(_receiptDateTime); } public string Notes diff --git a/ViewModels/EditFileViewModel.cs b/ViewModels/EditFileViewModel.cs index b750ace..5383e5e 100644 --- a/ViewModels/EditFileViewModel.cs +++ b/ViewModels/EditFileViewModel.cs @@ -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); } } \ No newline at end of file diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 3ecbed3..03a79d2 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -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() diff --git a/Views/EditFile.axaml b/Views/EditFile.axaml index 337db0f..2bf726c 100644 --- a/Views/EditFile.axaml +++ b/Views/EditFile.axaml @@ -2,19 +2,54 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="450" x:Class="ReceiptPDFBuilder.Views.EditFile" xmlns:models="clr-namespace:ReceiptPDFBuilder.Models" xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels" xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" x:DataType="vm:EditFileViewModel"> - - - + + + + + \ No newline at end of file diff --git a/Views/MainView.axaml b/Views/MainView.axaml index dd2fe02..fe707a6 100644 --- a/Views/MainView.axaml +++ b/Views/MainView.axaml @@ -36,8 +36,8 @@ CanUserSortColumns="False" BorderThickness="1" VerticalScrollBarVisibility="Visible" - HorizontalScrollBarVisibility="Disabled" ScrollViewer.AllowAutoHide="False" + HorizontalScrollBarVisibility="Disabled" HeadersVisibility="All" BorderBrush="Gray"> @@ -55,7 +55,7 @@ IsReadOnly="False" Width="*"/> + x:Name="LogScrollView" + VerticalScrollBarVisibility="Visible" + AllowAutoHide="False">