Improve watermark for date display
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user