diff --git a/src/MayShow.Shared/Models/ReportPDFCreator.cs b/src/MayShow.Shared/Models/ReportPDFCreator.cs index 4c2122f..4abcbd6 100644 --- a/src/MayShow.Shared/Models/ReportPDFCreator.cs +++ b/src/MayShow.Shared/Models/ReportPDFCreator.cs @@ -194,7 +194,7 @@ class ReportPDFCreator : ChangeNotifier } var imageTitle = string.IsNullOrWhiteSpace(file.Title) ? file.FileName : file.Title; var imageTitlePar = MakeParagraph(section, imageTitle, true, 12, "ReceiptTitlePar"); - MakeParagraph(section, file.ReceiptDate.ToString("yyyy-MM-dd"), true, 12, "ReceiptDatePar"); + MakeParagraph(section, file.ReceiptDate.ToString(appSettings.ReportDateFormat), true, 12, "ReceiptDatePar"); if (!string.IsNullOrWhiteSpace(file.Notes)) { var imageNotesPar = MakeParagraph(section, file.Notes, false, 10, "ReceiptNotesPar"); diff --git a/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs b/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs index c51d9eb..0b8b600 100644 --- a/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs +++ b/src/MayShow.Shared/ViewModels/CreatePDFReportViewModel.cs @@ -12,6 +12,8 @@ using MayShow.Helpers; using MayShow.Interfaces; using MayShow.Models; using MayShows.Helpers; +using System.Collections.Generic; +using System.Runtime.InteropServices; namespace MayShow.ViewModels; @@ -25,6 +27,7 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger private PDFReport _pdfReport; private Settings _settings; + private List _dateDisplayFormats; private bool _hasUnsavedWork; private CreatePDFReportViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger) @@ -36,6 +39,9 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger ReportFiles = []; _programLog = ""; _settings = Settings.LoadSettings(); + _dateDisplayFormats = Constants.GetDateDisplayFormats(); + NotifyPropertyChanged(nameof(DataGridDateFormat)); + NotifyPropertyChanged(nameof(DataGridDateFormatWatermark)); HasUnsavedWork = false; // setup initial quote and program log data InitializeProgramLog(); @@ -199,6 +205,16 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger } } + public string DataGridDateFormat + { + get => _settings.DataGridDateFormat; + } + + public string DataGridDateFormatWatermark + { + get => _dateDisplayFormats.FirstOrDefault(x => x.Value == _settings.DataGridDateFormat)?.Example ?? "2025-12-04"; + } + private void SetupFileCollectionChangedWatcher() { _pdfReport.Files.CollectionChanged += ( sender, e ) => @@ -213,7 +229,9 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger var quotes = Constants.GetQuotes(); var random = new Random(); var quoteIndex = random.Next(0, quotes.Length); - _programLog = "----- MayShow v" + Constants.AppVersion + " ------" + Environment.NewLine; + var compDetails = RuntimeInformation.OSDescription + " | " + + RuntimeInformation.OSArchitecture.ToString(); + _programLog = "----- MayShow v" + Constants.AppVersion + " | " + compDetails + " ------" + Environment.NewLine; _programLog += quotes[quoteIndex] + Environment.NewLine; _programLog += "---------------------------------------" + Environment.NewLine; _programLog += "Loaded and ready to create report!" + Environment.NewLine; @@ -337,6 +355,8 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger _settings = (Settings)updatedSettings; await _settings.SaveSettingsAsync(); LogInfo("Saved updated settings!"); + NotifyPropertyChanged(nameof(DataGridDateFormat)); + NotifyPropertyChanged(nameof(DataGridDateFormatWatermark)); } } @@ -552,13 +572,15 @@ class CreatePDFReportViewModel : BaseViewModel, ICanCheckShutdown, ILogger { LogInfo(e.StackTrace); } - if (e.InnerException != null) + var otherException = e.InnerException; + while (otherException != null) { - LogInfo("Inner exception: " + e.InnerException.Message); - if (e.InnerException.StackTrace != null) + LogInfo(">> Inner exception: " + otherException.Message); + if (otherException.StackTrace != null) { - LogInfo(e.InnerException.StackTrace); + LogInfo(otherException.StackTrace); } + otherException = otherException.InnerException; } LogInfo("Please report this error to a programmer or fix the issue listed above."); IsCreatingPDF = false;