<ContentDialog
    x:Class="PCUT.Pages.CutFilesDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PCUT.Pages"
    xmlns:localVM="using:PCUT.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Opened="ContentDialog_Opened">
    <ContentDialog.DataContext>
        <localVM:CutDialogViewModel/>
    </ContentDialog.DataContext>
    <ContentDialog.Resources>
        <localVM:ComponentStyle x:Key="previewStyle"/>
    </ContentDialog.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.1*"/>
            <RowDefinition Height="0.1*"/>
            <RowDefinition x:Name="PreviewRowDefinition" Height="0.6*"/>
            <RowDefinition Height="0.1*" MinHeight="{Binding CommandDisplayMinHeight}"/>
            <RowDefinition Height="0.1*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="MainColumnDefinition" Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBlock Text="CUT FILES" FontSize="20" HorizontalAlignment="Left" VerticalAlignment="Center"/>
        <Button x:Name="CloseButton" Width="32" Height="32" CornerRadius="32" HorizontalAlignment="Right" VerticalAlignment="Center" Click="CancelButton_Click">
            <!--<SymbolIcon Symbol="Cancel" />-->
            <TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE711;" FontSize="15" Margin="-5 -1 -5 -2" />
        </Button>
        <ScrollViewer
            x:Name="MainScroll"
            Grid.Row="2"
            ZoomMode="Enabled"
            HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden"
            VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Hidden"
            ManipulationMode="TranslateX,TranslateY" ManipulationDelta="MainScroll_ManipulationDelta"
            Loading="MainScroll_Loading">
            <Viewbox Width="{Binding Width, Source={StaticResource previewStyle}, Mode=OneWay}" Height="{Binding Height, Source={StaticResource previewStyle}, Mode=OneWay}">
                <Image x:Name="MainDisplay" Source="{x:Bind DisplayModel.Source, Mode=OneWay}" VerticalAlignment="Center" />
            </Viewbox>
        </ScrollViewer>
        <StackPanel
            Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
            <TextBlock Text="Width:" VerticalAlignment="Center"/>
            <TextBox
                x:Name="PreviewWidthDisplay"
                IsReadOnly="True"
                Text="123"
                Foreground="{ThemeResource SystemAccentColor}"
                VerticalAlignment="Center"
                VerticalContentAlignment="Center"
                Margin="5 0 0 0"/>
            <TextBlock Text="Height:" VerticalAlignment="Center" Margin="5 0 0 0"/>
            <TextBox
                x:Name="PreviewHeightDisplay"
                IsReadOnly="True"
                Text="123"
                Foreground="{ThemeResource SystemAccentColor}"
                VerticalAlignment="Center"
                VerticalContentAlignment="Center"
                Margin="5 0 0 0"/>
            <TextBlock Text="(mm)" Foreground="{ThemeResource SystemAccentColor}" VerticalAlignment="Center" Margin="5 0 0 0" />
        </StackPanel>
        <StackPanel Grid.Row="3" Height="92" MaxHeight="92" Margin="0 4 0 4" Visibility="{Binding CommandDisplay}">
            <TextBlock Text="Print Command:" Height="16" Margin="0 0 0 4"/>
            <TextBox
                Text="{Binding PrintCommand}"
                Height="72"
                MaxHeight="72"
                IsReadOnly="True"
                TextWrapping="Wrap"
                ScrollViewer.VerticalScrollMode="Auto"
                ScrollViewer.VerticalScrollBarVisibility="Auto"/>
        </StackPanel>
        <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button x:Name="CancelButton" Style="{StaticResource CloseDialogButton}" Width="150" Click="CancelButton_Click">Cancel</Button>
            <Button x:Name="StartButton" Style="{StaticResource PrimaryDialogButton}" Width="150" Margin="10 0 0 0" Click="StartButton_Click">Start</Button>
        </StackPanel>
    </Grid>
</ContentDialog>
