<Page
    x:Class="PCUT.Pages.SvgNestPage"
    Tag="Sort"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PCUT"
    xmlns:localExt="using:PCUT.Extensions"
    xmlns:localCV="using:PCUT.Converters"
    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"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <localCV:VisibilityConverter x:Key="visibilityConverter"/>
        <localCV:BooleanInverter x:Key="inverter"/>
        <localVM:ComponentStyle x:Key="previewStyle"/>
    </Page.Resources>

    <Page.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition />
        </TransitionCollection>
    </Page.Transitions>

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition x:Name="PreviewRowDefinition" Height="0.95*"/>
                <RowDefinition Height="0.05*" MinHeight="15"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="PreviewColumnDefinition" Width="*"/>
            </Grid.ColumnDefinitions>
            <ScrollViewer
                Grid.Row="0"
                x:Name="MainScroll"
                ZoomMode="Enabled"
                HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden"
                VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Hidden"
                ManipulationMode="TranslateX,TranslateY" ManipulationDelta="MainScroll_ManipulationDelta"
                Loading="MainScroll_Loading" Margin="0,83,0,0">
                <Viewbox Height="{Binding Height, Source={StaticResource previewStyle}, Mode=OneWay}">
                    <Image x:Name="MainPreview" Source="{x:Bind PreviewModel.Source, Mode=OneWay}" ImageOpened="MainPreview_ImageOpened">
                        <Image.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem x:Name="MainPreviewRefresh" Text="Refresh" Click="MainPreviewRefresh_Click"/>
                                <MenuFlyoutItem x:Name="MainPreviewDefault" Text="Show Default" IsEnabled="{x:Bind PreviewModel.DefaultMode, Mode=OneWay, Converter={StaticResource inverter}}" Click="MainPreviewDefault_Click"/>
                                <MenuFlyoutItem x:Name="NestResult" Text="Show Nested" IsEnabled="{x:Bind PreviewModel.DefaultMode, Mode=OneWay}" Click="NestResult_Click"/>
                                <MenuFlyoutSeparator/>
                                <MenuFlyoutItem x:Name="NestStart" Text="Start" IsEnabled="{x:Bind ProgressModel.Running, Mode=OneWay, Converter={StaticResource inverter}}" Click="NestStart_Click"/>
                                <MenuFlyoutItem x:Name="NestStop" Text="Stop" IsEnabled="{x:Bind ProgressModel.Running, Mode=OneWay}" Click="NestStop_Click"/>
                                <MenuFlyoutSeparator/>
                                <MenuFlyoutItem x:Name="NestSettings" Text="Settings" IsEnabled="{x:Bind ProgressModel.Running, Mode=OneWay, Converter={StaticResource inverter}}" Click="NestSettings_Click" />
                            </MenuFlyout>
                        </Image.ContextFlyout>
                    </Image>
                </Viewbox>
            </ScrollViewer>
            <ProgressBar
                Grid.Row="1"
                HorizontalAlignment="Stretch" VerticalAlignment="Center" MinHeight="10"
                Visibility="{x:Bind ProgressModel.Running, Mode=OneWay, Converter={StaticResource visibilityConverter}}"
                Value="{x:Bind ProgressModel.Progress, Mode=OneWay}"/>
        </Grid>
        <ProgressRing x:Name="LoadingRing" IsActive="True" Visibility="Visible" Height="96" Width="96"/>
    </Grid>
</Page>
