Improve watermark for date display

This commit is contained in:
2026-04-13 19:10:33 +09:00
parent 5b0508721f
commit 3482ed7336
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -28,6 +28,7 @@ using SixLabors.ImageSharp.Processing;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
using Docnet.Core.Readers; using Docnet.Core.Readers;
using MigraDoc.DocumentObjectModel.Visitors; using MigraDoc.DocumentObjectModel.Visitors;
using System.Collections.Generic;
namespace MayShow.ViewModels; namespace MayShow.ViewModels;
@@ -44,6 +45,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
private DateTime? _lastGeneratedTime; private DateTime? _lastGeneratedTime;
private Settings _settings; private Settings _settings;
private List<DateDisplayFormat> _dateDisplayFormats;
private bool _hasUnsavedWork; private bool _hasUnsavedWork;
@@ -66,7 +68,9 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
_reportTitle = ""; _reportTitle = "";
_lastGeneratedTime = null; _lastGeneratedTime = null;
_settings = Settings.LoadSettings(); _settings = Settings.LoadSettings();
_dateDisplayFormats = Constants.GetDateDisplayFormats();
NotifyPropertyChanged(nameof(DataGridDateFormat)); NotifyPropertyChanged(nameof(DataGridDateFormat));
NotifyPropertyChanged(nameof(DataGridDateFormatWatermark));
if (!string.IsNullOrWhiteSpace(_settings.LastUsedPath)) if (!string.IsNullOrWhiteSpace(_settings.LastUsedPath))
{ {
LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath); LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath);
@@ -178,6 +182,11 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
get => _settings.DataGridDateFormat; get => _settings.DataGridDateFormat;
} }
public string DataGridDateFormatWatermark
{
get => _dateDisplayFormats.Where(x => x.Value == _settings.DataGridDateFormat).FirstOrDefault()?.Example ?? "2025-12-04";
}
private void LogInfo(string message, params object[]? arguments) private void LogInfo(string message, params object[]? arguments)
{ {
var timestamp = string.Format("[{0:s}]", DateTime.Now); var timestamp = string.Format("[{0:s}]", DateTime.Now);
@@ -305,6 +314,7 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
await _settings.SaveSettingsAsync(); await _settings.SaveSettingsAsync();
LogInfo("Saved updated settings!"); LogInfo("Saved updated settings!");
NotifyPropertyChanged(nameof(DataGridDateFormat)); NotifyPropertyChanged(nameof(DataGridDateFormat));
NotifyPropertyChanged(nameof(DataGridDateFormatWatermark));
} }
} }
+1 -1
View File
@@ -157,7 +157,7 @@
DisplayDate="{Binding ReceiptDateTime}" DisplayDate="{Binding ReceiptDateTime}"
SelectedDateFormat="Custom" SelectedDateFormat="Custom"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Watermark="12/31/2025" Watermark="{Binding $parent[UserControl].((vm:MainViewModel)DataContext).DataGridDateFormatWatermark}"
CustomDateFormatString="{Binding $parent[UserControl].((vm:MainViewModel)DataContext).DataGridDateFormat}"/> CustomDateFormatString="{Binding $parent[UserControl].((vm:MainViewModel)DataContext).DataGridDateFormat}"/>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate> </DataGridTemplateColumn.CellEditingTemplate>