Add date format pickers (settings not used yet)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MayShow.Models;
|
||||
|
||||
namespace MayShow.Helpers;
|
||||
|
||||
class Constants
|
||||
@@ -10,6 +13,22 @@ class Constants
|
||||
|
||||
public static string ReportSavedDataFileName = "report_data.json";
|
||||
|
||||
public static List<DateDisplayFormat> GetDateDisplayFormats()
|
||||
{
|
||||
return [
|
||||
new DateDisplayFormat("Month/Day/Year", "4/5/2026", "M/d/yyyy"),
|
||||
new DateDisplayFormat("Year-Month-Day", "2026-04-05", "yyyy-dd-MM"),
|
||||
new DateDisplayFormat("Month Day, Year", "April 5, 2026", "MMMM d, yyyy"),
|
||||
new DateDisplayFormat("DOW, Month Day, Year", "Sunday, April 5, 2026", "dddd, MMMM d, yyyy"),
|
||||
new DateDisplayFormat("Abbreviated-Month Day, Year", "Apr 5, 2026", "MMM d, yyyy"),
|
||||
new DateDisplayFormat("DOW, Abbreviated-Month Day, Year", "Sunday, Apr 5, 2026", "dddd, MMM d, yyyy"),
|
||||
new DateDisplayFormat("Day Month, Year", "5 April, 2026", "d MMMM, yyyy"),
|
||||
new DateDisplayFormat("Day Abbreviated-Month, Year", "5 Apr, 2026", "d MMM, yyyy"),
|
||||
new DateDisplayFormat("Day Month, Year", "05 April 2026", "dd MMMM yyyy"),
|
||||
new DateDisplayFormat("Day Abbreviated-Month, Year", "05 Apr 2026", "dd MMM yyyy"),
|
||||
];
|
||||
}
|
||||
|
||||
public static string[] GetQuotes()
|
||||
{
|
||||
// sources:
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PDFsharp-MigraDoc" Version="6.2.4" />
|
||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.10.4" />
|
||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.11.1" />
|
||||
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" />
|
||||
<PackageReference Include="DialogHost.Avalonia" Version="0.10.4" />
|
||||
<PackageReference Include="Xaml.Behaviors.Interactions.DragAndDrop.DataGrid" Version="11.3.9.5" />
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using MayShow.Helpers;
|
||||
|
||||
namespace MayShow.Models;
|
||||
|
||||
class DateDisplayFormat : ChangeNotifier
|
||||
{
|
||||
private string _title;
|
||||
private string _example;
|
||||
private string _value;
|
||||
|
||||
public DateDisplayFormat(string title, string example, string value)
|
||||
{
|
||||
_title = title;
|
||||
_example = example;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get => _title;
|
||||
set { _title = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string Example
|
||||
{
|
||||
get => _example;
|
||||
set { _example = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string Value
|
||||
{
|
||||
get => _value;
|
||||
set { _value = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ class Settings : ChangeNotifier
|
||||
private decimal _imageResizeThreshold;
|
||||
private bool _saveReportJsonDataInInternalDir;
|
||||
private Dictionary<string, string> _workingFolderToInternalFolderName;
|
||||
public string _dataGridDateFormat;
|
||||
public string _reportDateFormat;
|
||||
public int _settingsVersion;
|
||||
|
||||
public Settings()
|
||||
@@ -31,6 +33,8 @@ class Settings : ChangeNotifier
|
||||
_saveReportJsonDataInInternalDir = false;
|
||||
_workingFolderToInternalFolderName = [];
|
||||
_settingsVersion = 1;
|
||||
_dataGridDateFormat = "yyyy-MM-dd";
|
||||
_reportDateFormat = "yyyy-MM-dd";
|
||||
}
|
||||
|
||||
public Settings(Settings other)
|
||||
@@ -43,6 +47,8 @@ class Settings : ChangeNotifier
|
||||
_saveReportJsonDataInInternalDir = other.SaveReportJsonDataInInternalDir;
|
||||
_workingFolderToInternalFolderName = other.WorkingFolderToInternalFolderName;
|
||||
_settingsVersion = other.SettingsVersion;
|
||||
_dataGridDateFormat = "yyyy-MM-dd";
|
||||
_reportDateFormat = "yyyy-MM-dd";
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
@@ -102,6 +108,20 @@ class Settings : ChangeNotifier
|
||||
set { _settingsVersion = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
public string DataGridDateFormat
|
||||
{
|
||||
get => _dataGridDateFormat;
|
||||
set { _dataGridDateFormat = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
public string ReportDateFormat
|
||||
{
|
||||
get => _reportDateFormat;
|
||||
set { _reportDateFormat = value; NotifyPropertyChanged(); }
|
||||
}
|
||||
|
||||
public static string SettingsFileName = "settings.json";
|
||||
|
||||
public static string GetSettingsPath()
|
||||
|
||||
@@ -19,6 +19,7 @@ using MayShow.Interfaces;
|
||||
using MayShow.Models;
|
||||
using MayShow.Helpers;
|
||||
using MayShows.Helpers;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MayShow.ViewModels;
|
||||
|
||||
@@ -28,6 +29,9 @@ class SettingsViewModel: ChangeNotifier
|
||||
private Settings _settings;
|
||||
private string _errorMessage;
|
||||
private ITopLevelGrabber? _topLevelGrabber;
|
||||
private List<DateDisplayFormat> _dateFormats;
|
||||
private int _gridDisplayDateFormatSelectedIndex;
|
||||
private int _reportDisplayDateFormatSelectedIndex;
|
||||
|
||||
public SettingsViewModel(Settings settingsToEdit, ITopLevelGrabber? topLevelGrabber)
|
||||
{
|
||||
@@ -35,6 +39,17 @@ class SettingsViewModel: ChangeNotifier
|
||||
_settings = new Settings(settingsToEdit); // clone it
|
||||
_errorMessage = "";
|
||||
_topLevelGrabber = topLevelGrabber;
|
||||
_dateFormats = Constants.GetDateDisplayFormats();
|
||||
_gridDisplayDateFormatSelectedIndex = _dateFormats.FindIndex(x => x.Value == _previousSettings.DataGridDateFormat);
|
||||
if (_gridDisplayDateFormatSelectedIndex == -1)
|
||||
{
|
||||
_gridDisplayDateFormatSelectedIndex = 0;
|
||||
}
|
||||
_reportDisplayDateFormatSelectedIndex = _dateFormats.FindIndex(x => x.Value == _previousSettings.ReportDateFormat);
|
||||
if (_reportDisplayDateFormatSelectedIndex == -1)
|
||||
{
|
||||
_reportDisplayDateFormatSelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseDocnetPDFImageRendering
|
||||
@@ -109,6 +124,33 @@ class SettingsViewModel: ChangeNotifier
|
||||
}
|
||||
}
|
||||
|
||||
public List<DateDisplayFormat> DateFormats
|
||||
{
|
||||
get => _dateFormats;
|
||||
}
|
||||
|
||||
public int DataGridDisplayDateFormatSelectedIndex
|
||||
{
|
||||
get => _gridDisplayDateFormatSelectedIndex;
|
||||
set
|
||||
{
|
||||
_gridDisplayDateFormatSelectedIndex = value;
|
||||
_settings.DataGridDateFormat = _dateFormats[value].Value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int ReportDisplayDateFormatSelectedIndex
|
||||
{
|
||||
get => _reportDisplayDateFormatSelectedIndex;
|
||||
set
|
||||
{
|
||||
_reportDisplayDateFormatSelectedIndex = value;
|
||||
_settings.ReportDateFormat = _dateFormats[value].Value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public async void ChooseOutputFolder()
|
||||
{
|
||||
var topLevel = _topLevelGrabber?.GetTopLevel();
|
||||
|
||||
@@ -46,8 +46,34 @@
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
<Label Content="File List Date Format"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="14" />
|
||||
<ComboBox SelectedIndex="{Binding DataGridDisplayDateFormatSelectedIndex}"
|
||||
ItemsSource="{Binding DateFormats}"
|
||||
MaxDropDownHeight="300">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:DateDisplayFormat">
|
||||
<TextBlock Text="{Binding Example}"
|
||||
TextWrapping="Wrap"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Label Content="PDF Report Date Format"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="14" />
|
||||
<ComboBox SelectedIndex="{Binding ReportDisplayDateFormatSelectedIndex}"
|
||||
ItemsSource="{Binding DateFormats}"
|
||||
MaxDropDownHeight="300">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:DateDisplayFormat">
|
||||
<TextBlock Text="{Binding Example}"
|
||||
TextWrapping="Wrap"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<CheckBox IsChecked="{Binding SaveReportJsonDataInInternalDir}">Save report data (names, notes, etc.) in MayShow settings directory (saves in working directory by default)</CheckBox>
|
||||
<Button Command="{Binding OpenSettingsDir}">
|
||||
<Button Command="{Binding OpenSettingsDir}">
|
||||
<TextBlock>
|
||||
<Run Text=""
|
||||
FontFamily="{StaticResource FontAwesomeSolid}" /> Open MayShow Settings Directory</TextBlock>
|
||||
|
||||
Reference in New Issue
Block a user