<Page
    x:Class="ModernKeePass.Pages.SettingsDatabasePage"
    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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewModels="using:ModernKeePass.ViewModels"
    xmlns:templateSelectors="using:ModernKeePass.TemplateSelectors"
    mc:Ignorable="d">
    <Page.Resources>
        <CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
        <CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
        <CollectionViewSource x:Name="Compressions" Source="{Binding Compressions}" />
        <CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
    </Page.Resources>
    <Page.DataContext>
        <viewModels:SettingsDatabaseVm />
    </Page.DataContext>
    
    <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" />
        <ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsEnabled="{Binding HasRecycleBin}">
            <ComboBox.Resources>
                <DataTemplate x:Name="GroupFirstItem">
                    <TextBlock x:Uid="GroupNewItemTextBox" />
                </DataTemplate>
                <DataTemplate x:Name="GroupOtherItem">
                    <TextBlock Text="{Binding}" />
                </DataTemplate>
            </ComboBox.Resources>
            <ComboBox.ItemTemplateSelector>
                <templateSelectors:FirstItemDataTemplateSelector 
                    FirstItem="{StaticResource GroupFirstItem}" 
                    OtherItem="{StaticResource GroupOtherItem}" />
            </ComboBox.ItemTemplateSelector>
        </ComboBox>
        <TextBlock x:Uid="SettingsDatabaseEncryption" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" SelectedIndex="{Binding CipherIndex, Mode=TwoWay}" />
        <TextBlock x:Uid="SettingsDatabaseCompression" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" />
        <TextBlock x:Uid="SettingsDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding KeyDerivationName, Mode=TwoWay}" />
    </StackPanel>
</Page>
