<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>
            <StackPanel Margin="{StaticResource ControlMargin}">
                <TextBlock Text="配置" FontSize="{StaticResource FontSize.H1}" Margin="{StaticResource ControlMargin}"/>
                <StackPanel Margin="{StaticResource ControlMargin}">
                    <TextBlock Text="数据库" FontSize="{StaticResource FontSize.H2}" 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="{StaticResource FontSize.H4}"/>
                            <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}" FontSize="{StaticResource FontSize.H4}">
                        测厚仪数据库[<Run Text="{Binding IsThkExist,Mode=OneWay}"/>]
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="{StaticResource ControlMargin}">
                    <TextBlock Text="统计方式" FontSize="{StaticResource FontSize.H2}" Margin="{StaticResource ControlMargin}"/>

                    <StackPanel Orientation="Horizontal" DataContext="{Binding DbViewerModel}">
                        <StackPanel Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="混合数"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Mix}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="次"/>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="直方图统计步距"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Step}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="um"/>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="扫描图Y轴范围比例"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding YRangePercent}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="倍"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </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>
