<Page x:Class="FLY.Thick.FilmCasting.UI.DbViewer.PgSetup"
      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:FLY.Thick.FilmCasting.UI.DbViewer"
        xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      d:DataContext="{d:DesignInstance local:PageSetupVm}"
      Title="PageSelect">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <StackPanel Margin="{StaticResource ControlMargin}">
            <TextBlock Text="配置" FontSize="32" Margin="{StaticResource ControlMargin}"/>
            <StackPanel Margin="{StaticResource ControlMargin}">
                <TextBlock Text="数据库" FontSize="24" Margin="{StaticResource ControlMargin}"/>
                <StackPanel Orientation="Horizontal">
                    <Button Width="140" Margin="{StaticResource ControlMargin}" Content="选择数据库文件夹"  
                            Command="{Binding DbSelectCmd}"
                    Style="{StaticResource MahApps.Styles.Button.Square.Accent}" />
                    <StackPanel Margin="{StaticResource ControlMargin}">
                        <TextBlock Text="{Binding DbDirPath}" FontSize="15"/>
                        <TextBlock 
                            DataContext="{Binding DbHelper}"
                            Text="{Binding ErrorMsg,Mode=OneWay}" >
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Foreground" Value="Green"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsDbErr}" Value="True">
                                            <Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Control.Validation}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>

                    </StackPanel>
                </StackPanel>
                <StackPanel DataContext="{Binding DbHelper}">
                    <TextBlock Margin="{StaticResource ControlMargin}">
                        测厚仪数据库[<Run Text="{Binding IsThkExist,Mode=OneWay}"/>]
                    </TextBlock>
                </StackPanel>
            </StackPanel>
        </StackPanel>
        <Button VerticalAlignment="Top" HorizontalAlignment="Right" Style="{StaticResource Styles.Button.Circle.Accent}" Margin="{StaticResource ControlMargin}" Grid.Column="1" Click="ButtonBack_Click">
            <iconPacks:PackIconMaterial Kind="ArrowLeft" />
        </Button>

    </Grid>
</Page>
