Add settings page for using legacy PDF mode
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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="" 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="" 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"
|
||||
|
||||
@@ -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=""
|
||||
FontFamily="{StaticResource FontAwesomeSolid}" /> Cancel</TextBlock>
|
||||
</Button>
|
||||
<Button Command="{Binding Save}"
|
||||
Classes="accent">
|
||||
<TextBlock>
|
||||
<Run Text=""
|
||||
FontFamily="{StaticResource FontAwesomeSolid}" /> Save</TextBlock>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user