<!--  Copyright (c) Microsoft Corporation and Contributors.  -->
<!--  Licensed under the MIT License.  -->

<winuiex:WindowEx
    x:Class="Peek.UI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:fp="using:Peek.FilePreviewer"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="using:Peek.UI.Views"
    xmlns:winuiex="using:WinUIEx"
    Title="{x:Bind ViewModel.WindowTitle, Mode=OneWay}"
    MinWidth="480"
    MinHeight="320"
    mc:Ignorable="d">
    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid Name="MainGrid" KeyboardAcceleratorPlacementMode="Hidden">
        <Grid.KeyboardAccelerators>
            <KeyboardAccelerator Key="Left" Invoked="PreviousNavigationInvoked" />
            <KeyboardAccelerator Key="Up" Invoked="PreviousNavigationInvoked" />
            <KeyboardAccelerator Key="Right" Invoked="NextNavigationInvoked" />
            <KeyboardAccelerator Key="Down" Invoked="NextNavigationInvoked" />
            <KeyboardAccelerator Key="Escape" Invoked="CloseInvoked" />
            <KeyboardAccelerator
                Key="W"
                Invoked="CloseInvoked"
                Modifiers="Control" />
        </Grid.KeyboardAccelerators>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <views:TitleBar
            x:Name="TitleBarControl"
            Grid.Row="0"
            FileIndex="{x:Bind ViewModel.DisplayIndex, Mode=OneWay}"
            IsMultiSelection="{x:Bind ViewModel.NeighboringItemsQuery.IsMultipleFilesActivation, Mode=OneWay}"
            Item="{x:Bind ViewModel.CurrentItem, Mode=OneWay}"
            NumberOfFiles="{x:Bind ViewModel.DisplayItemCount, Mode=OneWay}" />

        <fp:FilePreview
            Grid.Row="1"
            Item="{x:Bind ViewModel.CurrentItem, Mode=OneWay}"
            NumberOfFiles="{x:Bind ViewModel.DisplayItemCount, Mode=OneWay}"
            PreviewSizeChanged="FilePreviewer_PreviewSizeChanged"
            ScalingFactor="{x:Bind ViewModel.ScalingFactor, Mode=OneWay}"
            Visibility="{x:Bind ContentVisibility(ViewModel.IsErrorVisible), Mode=OneWay}" />

        <InfoBar
            x:Name="ErrorInfoBar"
            Title="Error"
            Grid.Row="1"
            Grid.RowSpan="2"
            Margin="4,0,4,6"
            VerticalAlignment="Bottom"
            Closed="ErrorInfoBar_Closed"
            IsOpen="{x:Bind ViewModel.IsErrorVisible, Mode=TwoWay}"
            Message="{x:Bind ViewModel.ErrorMessage, Mode=OneWay}"
            Severity="Error" />

        <ContentDialog
            x:Name="DeleteConfirmationDialog"
            x:Uid="DeleteConfirmationDialog"
            DefaultButton="Close">
            <StackPanel
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Spacing="12">
                <TextBlock x:Uid="DeleteConfirmationDialog_Message" TextWrapping="Wrap" />
                <CheckBox x:Name="DeleteDontWarnCheckbox" x:Uid="DeleteConfirmationDialog_DontWarnCheckbox" />
            </StackPanel>
        </ContentDialog>
    </Grid>
</winuiex:WindowEx>
