<styles:WindowChromeBase x:Class="_1RM.View.Settings.DataSource.SqliteSettingView"
                         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                         xmlns:local="clr-namespace:_1RM.View.Settings.DataSource"
                         xmlns:styles="clr-namespace:Shawn.Utils.WpfResources.Theme.Styles;assembly=Shawn.Utils.WpfResources"
                         xmlns:s="https://github.com/canton7/Stylet"
                         mc:Ignorable="d" 
                         ShowInTaskbar="False"
                         SizeToContent="WidthAndHeight" 
                         WindowStyle="None"
                         Background="Transparent"
                         AllowsTransparency="True"
                         d:DataContext="{d:DesignInstance local:SqliteSettingViewModel}">
    <Window.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="TextAlignment" Value="Right"></Setter>
            <Setter Property="TextWrapping" Value="Wrap"></Setter>
            <Setter Property="Margin" Value="20 5 10 15"></Setter>
        </Style>
        <Style x:Key="TbInput" TargetType="TextBox" BasedOn="{StaticResource TextBoxAccentStyle}">
            <Setter Property="Margin" Value="0 5 0 15"></Setter>
        </Style>
        <Style TargetType="PasswordBox" BasedOn="{StaticResource PasswordBoxAccentStyle}">
            <Setter Property="Margin" Value="0 5 0 15"></Setter>
        </Style>
    </Window.Resources>

    <Border Background="{DynamicResource PrimaryMidBrush}"
            BorderBrush="{DynamicResource PrimaryLightBrush}"
            BorderThickness="1" CornerRadius="{StaticResource DefaultCornerRadius}" ClipToBounds="True">
        <Grid IsSharedSizeScope="True">
            <Grid >

                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="Effect">
                            <Setter.Value>
                                <BlurEffect Radius="2" KernelType="Box"></BlurEffect>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=TopLevelViewModel, Mode=OneWay}" Value="{x:Null}">
                                <Setter Property="Effect" Value="{x:Null}"></Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>

                <StackPanel Margin="20 0" >
                    <TextBlock Text="SQLite" Margin="15" FontSize="{DynamicResource GlobalFontSizeTitle}" Height="30" HorizontalAlignment="Left"></TextBlock>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition MinWidth="280" MaxWidth="300"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" Text="{DynamicResource 'Data Source name'}"></TextBlock>
                        <TextBox Grid.Row="0" Grid.Column="1" 
                                 Name="TbName" 
                                 Style="{StaticResource TbInput}"
                                 IsEnabled="{Binding NameWritable}"
                                 Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                        />

                        <TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource system_options_data_security_database}"></TextBlock>
                        <TextBox Grid.Row="1" Grid.Column="1" 
                                 Style="{StaticResource TbInput}"
                                 Text="{Binding Path, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 FontSize="{DynamicResource GlobalFontSizeSmall}" VerticalContentAlignment="Center" IsReadOnly="True" 
                                 Tag="{Binding Path, Mode=OneWay}"/>
                        <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
                            <Button Margin="5 5 0 15" Content="{DynamicResource Select}" Command="{Binding CmdSelectDbPath}"></Button>
                        </StackPanel>
                    </Grid>

                    <StackPanel Margin="0 20" Orientation="Horizontal" HorizontalAlignment="Center">
                        <StackPanel.Style>
                            <Style TargetType="StackPanel">
                                <Setter Property="Visibility" Value="Collapsed"></Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding OrgSqliteConfig}" Value="{x:Null}">
                                        <Setter Property="Visibility" Value="Visible"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </StackPanel.Style>
                        <Button Command="{Binding CmdSave}" Content="{DynamicResource Save}" Width="100" Margin="10 0"></Button>
                        <Button Command="{Binding CmdCancel}" Content="{DynamicResource Cancel}" Width="100" Margin="10 0"></Button>
                    </StackPanel>

                    <StackPanel Margin="0 20" Orientation="Horizontal" HorizontalAlignment="Center">
                        <StackPanel.Style>
                            <Style TargetType="StackPanel">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding OrgSqliteConfig}" Value="{x:Null}">
                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </StackPanel.Style>
                        <Button Command="{Binding CmdSave}" Content="{DynamicResource Save}" Width="100"></Button>
                    </StackPanel>
                </StackPanel>

            </Grid>

            <Grid>
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="Visibility" Value="Visible"></Setter>
                        <Setter Property="Background" Value="Transparent"></Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=TopLevelViewModel, Mode=OneWay}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Collapsed"></Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
            </Grid>
            <ContentControl s:View.Model="{Binding TopLevelViewModel}"></ContentControl>
        </Grid>
    </Border>
</styles:WindowChromeBase>
