<UserControl
    mc:Ignorable="d"
    x:Class="PicView.Avalonia.Views.Main.PrintPreviewView"
    x:DataType="viewModels:MainViewModel"
    xmlns="https://github.com/avaloniaui"
    xmlns:customControls="clr-namespace:PicView.Avalonia.CustomControls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:uc="clr-namespace:PicView.Avalonia.Views.UC"
    xmlns:viewModels="clr-namespace:PicView.Avalonia.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Panel>
        <!--  Spinner overlay  -->
        <uc:SpinWaiter
            HorizontalAlignment="Center"
            IsVisible="{CompiledBinding PrintPreview.IsProcessing.Value,
                                        Mode=OneWay}"
            VerticalAlignment="Center"
            ZIndex="100" />

        <StackPanel>
            <!--  Root grid with two columns  -->
            <Grid
                ColumnDefinitions="2*,3*"
                Height="640"
                IsHitTestVisible="{CompiledBinding !PrintPreview.IsProcessing.Value,
                                                   Mode=OneWay}"
                Margin="20,10,10,20"
                Opacity="{CompiledBinding PrintPreview.Opacity.Value,
                                          Mode=OneWay}"
                RowDefinitions="*,Auto"
                VerticalAlignment="Top">

                <!--  Settings Panel (Left)  -->
                <StackPanel
                    Grid.Column="0"
                    Grid.Row="0"
                    Margin="10,0,30,0"
                    Spacing="12"
                    Width="370">

                    <!--  Printer  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Printer.Value,
                                               Mode=OneWay}" />

                    <ComboBox
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        ItemsSource="{CompiledBinding PrintPreview.Printers.Value}"
                        Margin="0,0,0,4"
                        Padding="5,7,0,7"
                        SelectedItem="{CompiledBinding PrintPreview.PrintSettings.Value.PrinterName.Value,
                                                       Mode=TwoWay}" />

                    <!--  Paper Size  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.PaperSize.Value,
                                               Mode=OneWay}" />

                    <ComboBox
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        ItemsSource="{CompiledBinding PrintPreview.PaperSizes.Value}"
                        Margin="0,0,0,4"
                        Padding="5,7,0,7"
                        SelectedItem="{CompiledBinding PrintPreview.PrintSettings.Value.PaperSize.Value,
                                                       Mode=TwoWay}" />

                    <!--  Orientation  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Orientation.Value,
                                               Mode=OneWay}" />

                    <ComboBox
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        ItemsSource="{CompiledBinding PrintPreview.Orientations.Value}"
                        Margin="0,0,0,4"
                        Padding="5,7,0,7"
                        SelectedIndex="{CompiledBinding PrintPreview.PrintSettings.Value.Orientation.Value,
                                                        Mode=TwoWay}" />

                    <!--  Scale Mode  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Scale.Value,
                                               Mode=OneWay}" />

                    <ComboBox
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        ItemsSource="{CompiledBinding PrintPreview.ScaleModes.Value}"
                        Margin="0,0,0,4"
                        Padding="5,7,0,7"
                        SelectedIndex="{CompiledBinding PrintPreview.PrintSettings.Value.ScaleMode.Value,
                                                        Mode=TwoWay}" />

                    <!--  Color Mode  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Color.Value,
                                               Mode=OneWay}" />

                    <ComboBox
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        ItemsSource="{CompiledBinding PrintPreview.ColorModes.Value}"
                        Margin="0,0,0,4"
                        Padding="5,7,0,7"
                        SelectedIndex="{CompiledBinding PrintPreview.PrintSettings.Value.ColorMode.Value,
                                                        Mode=TwoWay}" />

                    <!--  Copies  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Copies.Value,
                                               Mode=OneWay}" />

                    <NumericUpDown
                        Background="{DynamicResource SecondaryBackgroundColor}"
                        BorderBrush="{DynamicResource MainBorderColor}"
                        BorderThickness="1"
                        FontFamily="/Assets/Fonts/Roboto-Medium.ttf#Roboto"
                        Foreground="{DynamicResource MainTextColor}"
                        Increment="1"
                        Margin="0,0,0,4"
                        Maximum="200"
                        Minimum="1"
                        Padding="5,7,0,7"
                        Value="{CompiledBinding PrintPreview.PrintSettings.Value.Copies.Value,
                                                Mode=TwoWay}" />

                    <!--  Margins  -->
                    <TextBlock
                        Classes="txt"
                        FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                        FontSize="14"
                        Margin="0,6,0,0"
                        Text="{CompiledBinding Translation.Margins.Value,
                                               Mode=OneWay}" />

                    <Grid ColumnDefinitions="*,*,*,*" ColumnSpacing="6">

                        <!--  Top  -->
                        <StackPanel Grid.Column="0">
                            <TextBlock
                                Classes="txt"
                                Margin="0,0,0,5"
                                Text="{CompiledBinding Translation.Top.Value,
                                                       Mode=OneWay}" />
                            <NumericUpDown
                                Background="{DynamicResource SecondaryBackgroundColor}"
                                FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                Foreground="{DynamicResource MainTextColor}"
                                HorizontalAlignment="Stretch"
                                Increment="1"
                                Maximum="100"
                                Minimum="0"
                                Value="{CompiledBinding PrintPreview.PrintSettings.Value.MarginTop.Value,
                                                        Mode=TwoWay}" />
                        </StackPanel>

                        <!--  Bottom  -->
                        <StackPanel Grid.Column="1">
                            <TextBlock
                                Classes="txt"
                                Margin="0,0,0,5"
                                Text="{CompiledBinding Translation.Bottom.Value,
                                                       Mode=OneWay}" />
                            <NumericUpDown
                                Background="{DynamicResource SecondaryBackgroundColor}"
                                FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                Foreground="{DynamicResource MainTextColor}"
                                HorizontalAlignment="Stretch"
                                Increment="1"
                                Maximum="100"
                                Minimum="0"
                                Value="{CompiledBinding PrintPreview.PrintSettings.Value.MarginBottom.Value,
                                                        Mode=TwoWay}" />
                        </StackPanel>

                        <!--  Left  -->
                        <StackPanel Grid.Column="2">
                            <TextBlock
                                Classes="txt"
                                Margin="0,0,0,5"
                                Text="{CompiledBinding Translation.Left.Value,
                                                       Mode=OneWay}" />
                            <NumericUpDown
                                Background="{DynamicResource SecondaryBackgroundColor}"
                                FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                Foreground="{DynamicResource MainTextColor}"
                                HorizontalAlignment="Stretch"
                                Increment="1"
                                Maximum="100"
                                Minimum="0"
                                Value="{CompiledBinding PrintPreview.PrintSettings.Value.MarginLeft.Value,
                                                        Mode=TwoWay}" />
                        </StackPanel>

                        <!--  Right  -->
                        <StackPanel Grid.Column="3">
                            <TextBlock
                                Classes="txt"
                                Margin="0,0,0,5"
                                Text="{CompiledBinding Translation.Right.Value,
                                                       Mode=OneWay}" />
                            <NumericUpDown
                                Background="{DynamicResource SecondaryBackgroundColor}"
                                FontFamily="/Assets/Fonts/Roboto-Regular.ttf#Roboto"
                                Foreground="{DynamicResource MainTextColor}"
                                HorizontalAlignment="Stretch"
                                Increment="1"
                                Maximum="100"
                                Minimum="0"
                                Value="{CompiledBinding PrintPreview.PrintSettings.Value.MarginRight.Value,
                                                        Mode=TwoWay}" />
                        </StackPanel>
                    </Grid>


                </StackPanel>

                <!--  Preview Panel (Right)  -->
                <Border
                    Background="#198B8B8B"
                    CornerRadius="6"
                    Grid.Column="1"
                    Grid.Row="0"
                    Margin="10">
                    <Viewbox
                        Margin="10"
                        Stretch="Uniform"
                        StretchDirection="Both">
                        <Border
                            Background="White"
                            BorderBrush="LightGray"
                            BorderThickness="1"
                            CornerRadius="2"
                            Height="{CompiledBinding PrintPreview.PageHeight.Value}"
                            Width="{CompiledBinding PrintPreview.PageWidth.Value}">
                            <Border.Effect>
                                <DropShadowEffect
                                    BlurRadius="15"
                                    Color="Black"
                                    OffsetX="4"
                                    OffsetY="4"
                                    Opacity="0.3" />
                            </Border.Effect>

                            <customControls:ThumbImage Source="{CompiledBinding PrintPreview.PreviewImage.Value}" Stretch="None" />
                        </Border>
                    </Viewbox>
                </Border>
            </Grid>

            <!--  Footer Buttons  -->
            <StackPanel
                HorizontalAlignment="Right"
                Margin="0,2,25,20"
                Orientation="Horizontal"
                Spacing="15"
                VerticalAlignment="Bottom"
                x:Name="BottomBorder">

                <Button
                    Background="{DynamicResource MenuButtonColor}"
                    Classes="ButtonBorder altHover"
                    Command="{CompiledBinding PrintPreview.CancelCommand}"
                    Foreground="{DynamicResource MainTextColor}"
                    Height="42"
                    ToolTip.Tip="{CompiledBinding Translation.Cancel.Value,
                                                  Mode=OneWay}"
                    Width="140"
                    x:Name="CancelButton">
                    <TextBlock
                        Classes="txt"
                        Text="{CompiledBinding Translation.Cancel.Value,
                                               Mode=OneWay}"
                        TextAlignment="Center" />
                </Button>

                <Button
                    Background="{DynamicResource AccentColor}"
                    Classes="ButtonBorder accentHover"
                    Command="{CompiledBinding PrintPreview.PrintCommand}"
                    Foreground="{DynamicResource MainTextColor}"
                    Height="42"
                    ToolTip.Tip="{CompiledBinding Translation.Print.Value,
                                                  Mode=OneWay}"
                    Width="140"
                    x:Name="PrintButton">
                    <TextBlock
                        Classes="txt"
                        Foreground="{StaticResource SecondaryTextColor}"
                        Text="{CompiledBinding Translation.Print.Value,
                                               Mode=OneWay}"
                        TextAlignment="Center" />
                </Button>


            </StackPanel>

        </StackPanel>
    </Panel>
</UserControl>