<dialogs:PixiEditorPopup xmlns="https://github.com/avaloniaui"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:dialogs="clr-namespace:PixiEditor.AvaloniaUI.Views.Dialogs"
                         xmlns:input="clr-namespace:PixiEditor.AvaloniaUI.Views.Input"
                         xmlns:ui1="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
                         xmlns:visuals="clr-namespace:PixiEditor.AvaloniaUI.Views.Visuals"
                         xmlns:indicators="clr-namespace:PixiEditor.AvaloniaUI.Views.Indicators"
                         CanResize="False"
                         CanMinimize="False"
                         SizeToContent="WidthAndHeight"
                         Name="saveFilePopup"
                         x:Class="PixiEditor.AvaloniaUI.Views.Dialogs.ExportFilePopup"
                         x:ClassModifier="internal"
                         Title="EXPORT_IMAGE">
    <DockPanel Background="{DynamicResource ThemeBackgroundBrush}">
        <Button DockPanel.Dock="Bottom" HorizontalAlignment="Center" IsDefault="True"
                ui1:Translator.Key="EXPORT" Command="{Binding ExportCommand, ElementName=saveFilePopup}" />
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Stretch" Orientation="Vertical"
                    Margin="0,15,0,0">
            <TabControl SelectedIndex="{Binding SelectedExportIndex, ElementName=saveFilePopup}">
                <TabControl.Styles>
                    <Style Selector="TabControl">
                        <Setter Property="HorizontalAlignment" Value="Center" />
                    </Style>
                    <Style Selector="TabItem:selected">
                        <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
                    </Style>
                </TabControl.Styles>
                <TabControl.Items>
                    <TabItem IsSelected="True" ui1:Translator.Key="EXPORT_IMAGE_HEADER">
                    </TabItem>
                    <TabItem ui1:Translator.Key="EXPORT_ANIMATION_HEADER">

                    </TabItem>
                    <TabItem ui1:Translator.Key="EXPORT_SPRITESHEET_HEADER">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="50" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock ui1:Translator.Key="ROWS" Grid.Row="0" Grid.Column="0"/>
                            <input:NumberInput Min="0" Width="50" Grid.Column="1" Grid.Row="0"
                                               Value="{Binding ElementName=saveFilePopup, Path=SpriteSheetRows, Mode=TwoWay}" />
                            <TextBlock ui1:Translator.Key="COLUMNS" Grid.Row="1" Grid.Column="0"/>
                            <input:NumberInput Min="0" Width="50" Grid.Column="1" Grid.Row="1"
                                               Value="{Binding ElementName=saveFilePopup, Path=SpriteSheetColumns, Mode=TwoWay}" />
                        </Grid>
                    </TabItem>
                </TabControl.Items>
            </TabControl>
            <Border Margin="15, 30" Padding="10"
                    Background="{DynamicResource ThemeBackgroundBrush1}"
                    CornerRadius="{DynamicResource ControlCornerRadius}">
                <Grid MinHeight="205" MinWidth="400">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="160" />
                    </Grid.ColumnDefinitions>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <input:SizePicker Grid.Row="0"
                                          x:Name="sizePicker"
                                          IsSizeUnitSelectionVisible="True"
                                          VerticalAlignment="Top"
                                          ChosenHeight="{Binding Path=SaveHeight, Mode=TwoWay, ElementName=saveFilePopup}"
                                          ChosenWidth="{Binding Path=SaveWidth, Mode=TwoWay, ElementName=saveFilePopup}" />
                        <TextBlock Grid.Row="1" Margin="5, 0" VerticalAlignment="Bottom" Classes="hyperlink"
                                   TextWrapping="Wrap"
                                   Width="220" TextAlignment="Center"
                                   Text="{Binding SizeHint, Mode=OneTime, ElementName=saveFilePopup}">
                            <Interaction.Behaviors>
                                <EventTriggerBehavior EventName="PointerPressed">
                                    <InvokeCommandAction
                                        Command="{Binding SetBestPercentageCommand, ElementName=saveFilePopup}" />
                                </EventTriggerBehavior>
                            </Interaction.Behaviors>
                        </TextBlock>
                    </Grid>
                    <Grid Grid.Column="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Export Preview" />
                        <indicators:LoadingIndicator Grid.Row="1"
                                                     IsVisible="{Binding IsGeneratingPreview, ElementName=saveFilePopup}"
                                                     Margin="0, 10, 0, 0" />
                        <Border Grid.Row="1" BorderThickness="1" Height="200" Width="150"
                                IsVisible="{Binding !IsGeneratingPreview, ElementName=saveFilePopup}">
                            <Border RenderOptions.BitmapInterpolationMode="None">
                                <visuals:SurfaceControl x:Name="surfaceControl"
                                                        Surface="{Binding ExportPreview, ElementName=saveFilePopup}"
                                                        Stretch="Uniform" HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"
                                                        RenderOptions.BitmapInterpolationMode="None">
                                    <visuals:SurfaceControl.Background>
                                        <ImageBrush Source="/Images/CheckerTile.png"
                                                    TileMode="Tile" DestinationRect="0, 0, 25, 25" />
                                    </visuals:SurfaceControl.Background>
                                </visuals:SurfaceControl>
                            </Border>
                        </Border>
                    </Grid>
                </Grid>
            </Border>
        </StackPanel>
    </DockPanel>
</dialogs:PixiEditorPopup>