<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="450">
    <ScrollViewer AllowAutoHide="False">
        <StackPanel Orientation="Vertical"
                    Spacing="8"
                    Margin="12,4,12,4">
            <Label Content="Settings"
                    HorizontalAlignment="Center"
                    FontSize="16"
                    FontWeight="Bold" />
            <TextBlock TextWrapping="Wrap"
                       HorizontalAlignment="Left"
                       Width="350">
                Always reduce size of images if above this file size in megabytes (MB):
            </TextBlock>
            <NumericUpDown Value="{Binding ImageResizeThreshold}"
                           Increment="0.1"
                           Minimum="0.5"
                           FormatString="0.00"
                           Maximum="10"
                           Width="150"
                           HorizontalAlignment="Left"
                           Margin="0,0,0,4" />
            <CheckBox IsChecked="{Binding !UseDocnetPDFImageRendering}">Use legacy PDF handling (does not work with macOS annotations)</CheckBox>
            <CheckBox IsChecked="{Binding SaveOutputPdfInWorkingDir}">Always save report PDF in working directory</CheckBox>
            <Grid ColumnDefinitions="Auto, *"
                IsVisible="{Binding !SaveOutputPdfInWorkingDir}">
                <Button Content="Choose report output folder..."
                        Grid.Column="0"
                        Command="{Binding ChooseOutputFolder}"
                        VerticalAlignment="Top"/>
                <TextBlock Text="{Binding OutputPdfDirPath}"
                           Margin="4,0,0,0"
                           TextWrapping="Wrap"
                           Grid.Column="1"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"/>
            </Grid>
            <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}">
                <TextBlock>
                    <Run Text="&#xf07c;"
                        FontFamily="{StaticResource FontAwesomeSolid}" /> Open MayShow Settings Directory</TextBlock>
            </Button>
            <TextBlock TextWrapping="Wrap"
                       Foreground="Red"
                       Text="{Binding ErrorMessage}"
                       IsVisible="{Binding HasErrorMessage}"/>
            <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>