Add settings page for using legacy PDF mode

This commit is contained in:
2026-03-02 16:32:40 +09:00
parent d51017bb73
commit fc89854bfc
6 changed files with 137 additions and 2 deletions
+3
View File
@@ -106,6 +106,9 @@
<DataTemplate DataType="{x:Type viewModels:ConfirmViewModel}">
<views:ConfirmView/>
</DataTemplate>
<DataTemplate DataType="{x:Type viewModels:SettingsViewModel}">
<views:SettingsView/>
</DataTemplate>
</Application.DataTemplates>
<Application.Resources>
<ResourceDictionary>
+11
View File
@@ -257,6 +257,17 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
DialogHost.Show(new AboutViewModel());
}
public async Task ShowSettings()
{
var updatedSettings = await DialogHost.Show(new SettingsViewModel(_settings));
if (updatedSettings != null)
{
_settings = (Settings)updatedSettings;
await _settings.SaveSettingsAsync();
LogInfo("Saved updated settings!");
}
}
public void RemoveFile(object f) => RemoveFileImpl((ReportFile)f);
public async void RemoveFileImpl(ReportFile file)
+58
View File
@@ -0,0 +1,58 @@
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using Avalonia.Themes.Fluent;
using DialogHostAvalonia;
using ImageMagick;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using PdfSharp.Fonts;
using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font;
using MayShow.Interfaces;
using MayShow.Models;
using MayShow.Helpers;
namespace MayShow.ViewModels;
class SettingsViewModel: ChangeNotifier
{
private Settings _previousSettings;
private Settings _settings;
public SettingsViewModel(Settings settingsToEdit)
{
_previousSettings = settingsToEdit;
_settings = new Settings
{
LastUsedPath = _previousSettings.LastUsedPath,
UseDocnetPFDImageRendering = _previousSettings.UseDocnetPFDImageRendering
};
}
public bool UseDocnetPDFImageRendering
{
get => _settings.UseDocnetPFDImageRendering;
set
{
_settings.UseDocnetPFDImageRendering = value;
NotifyPropertyChanged();
}
}
public void Cancel()
{
DialogHost.Close("DialogHost", null);
}
public void Save()
{
DialogHost.Close("DialogHost", _settings);
}
}
+10 -2
View File
@@ -12,15 +12,23 @@
x:DataType="vm:MainViewModel">
<Grid ColumnDefinitions="*"
RowDefinitions="Auto, 2*, Auto, Auto, *">
<Button Command="{Binding ShowSettings}"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="4,4,0,4">
<TextBlock><Run Text="&#xf013;" FontFamily="{StaticResource FontAwesomeSolid}"/> Settings</TextBlock>
</Button>
<Button Command="{Binding ShowAbout}"
Grid.Row="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,2,4,0">
Margin="0,4,4,4">
<TextBlock><Run Text="&#xf059;" FontFamily="{StaticResource FontAwesomeSolid}"/> About</TextBlock>
</Button>
<StackPanel Orientation="Vertical"
Spacing="2">
Spacing="2"
Margin="0,4,0,0">
<Label Content="MayShow: Report Builder"
FontSize="20"
FontWeight="Bold"
+40
View File
@@ -0,0 +1,40 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
x:Class="MayShow.Views.SettingsView"
xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:MayShow.ViewModels"
x:DataType="vm:SettingsViewModel"
MaxWidth="350">
<ScrollViewer AllowAutoHide="False">
<StackPanel Orientation="Vertical"
Spacing="4"
Margin="12,4,12,0">
<Label Content="Settings"
HorizontalAlignment="Center"
FontSize="16"
FontWeight="Bold" />
<CheckBox IsChecked="{Binding !UseDocnetPDFImageRendering}">Use legacy PDF handling (does not work with macOS annotations)</CheckBox>
<StackPanel Orientation="Horizontal"
Spacing="12"
Margin="0,4,0,0"
HorizontalAlignment="Right">
<Button Command="{Binding Cancel}">
<TextBlock>
<Run Text="&#xf0e2;"
FontFamily="{StaticResource FontAwesomeSolid}" /> Cancel</TextBlock>
</Button>
<Button Command="{Binding Save}"
Classes="accent">
<TextBlock>
<Run Text="&#xf0c7;"
FontFamily="{StaticResource FontAwesomeSolid}" /> Save</TextBlock>
</Button>
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>
+15
View File
@@ -0,0 +1,15 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace MayShow.Views
{
public partial class SettingsView : UserControl
{
public SettingsView()
{
this.InitializeComponent();
}
}
}