<Page
    x:Class="ModernKeePass.Views.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:converters="using:ModernKeePass.Converters"
    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}" />
        <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
    </Page.Resources>
    <Page.DataContext>
        <viewModels:SettingsDatabaseVm />
    </Page.DataContext>

    <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" Style="{StaticResource MainColorToggleSwitch}" />
        <StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}">
            <RadioButton x:Uid="SettingsDatabaseRecycleBinCreate" GroupName="Recycle" IsChecked="{Binding IsNewRecycleBin, Mode=TwoWay}" />
            <RadioButton x:Name="RadioButton" x:Uid="SettingsDatabaseRecycleBinExisting" GroupName="Recycle" IsChecked="{Binding SelectedItem, Converter={StaticResource NullToBooleanConverter}}" />
            <ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsEnabled="{Binding IsChecked, ElementName=RadioButton}" />
        </StackPanel>
        <TextBlock x:Uid="SettingsDatabaseEncryption" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" SelectedIndex="{Binding CipherIndex, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" />
        <TextBlock x:Uid="SettingsDatabaseCompression" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" />
        <TextBlock x:Uid="SettingsDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
        <ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" SelectedItem="{Binding KeyDerivationName, Mode=TwoWay}" ItemContainerStyle="{StaticResource MainColorComboBoxItem}" />
    </StackPanel>
</Page>
