<UserControl x:Class="DBBackupTool.Views.Restore"
             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:DBBackupTool.Views"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             xmlns:UICommon="clr-namespace:UICommon;assembly=UICommon"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
    </UserControl.Resources>
    <Grid Margin="8">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="16"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="16"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.ColumnSpan="3" Grid.RowSpan="3" Background="#80ffffff" Panel.ZIndex="2" Visibility="{Binding LoadingVis}">
            <UICommon:CycleRingLoading Width="100" Foreground="{StaticResource ThemeColor}"/>
        </Grid>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="24"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="24"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Grid.Row="0"  VerticalAlignment="Center">Server Address:</TextBlock>
            <TextBox Grid.Column="2" Grid.Row="0" VerticalAlignment="Center" VerticalContentAlignment="Center" Height="24" Text="{Binding DbInfo.ServerAddress}"/>

            <TextBlock Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" >Port:</TextBlock>
            <TextBox Grid.Column="2" Grid.Row="2" VerticalAlignment="Center"  VerticalContentAlignment="Center" Height="24" Text="{Binding DbInfo.Port}"/>


            <TextBlock Grid.Column="0" Grid.Row="4"  VerticalAlignment="Center" >Database:</TextBlock>
            <TextBox Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" VerticalContentAlignment="Center" Height="24" Text="{Binding DbInfo.DataBase}"/>


            <TextBlock  Grid.Column="0" Grid.Row="6" VerticalAlignment="Center" >User:</TextBlock>
            <TextBox Grid.Column="2" Grid.Row="6" VerticalAlignment="Center"  VerticalContentAlignment="Center" Height="24" Text="{Binding DbInfo.User}"/>


            <TextBlock Grid.Column="0" Grid.Row="8" VerticalAlignment="Center" >Password:</TextBlock>
            <TextBox Grid.Column="2  " Grid.Row="8" VerticalAlignment="Center"  VerticalContentAlignment="Center" Height="24" Text="{Binding DbInfo.PassWord}"/>

            <Button Grid.Row="10" Grid.ColumnSpan="3" Height="24" VerticalAlignment="Center"  Command="{Binding CheckDBCommand}">连接/建库</Button>

            <Grid Grid.Row="12" Grid.ColumnSpan="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="8"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left">备份文件:</TextBlock>
                <Button Grid.Column="2" Width="80"  Command="{Binding SelectPathCommand}">选择文件</Button>
                <Border Grid.Row="2" Grid.ColumnSpan="3" BorderBrush="Black" BorderThickness="1">
                    <TextBlock TextWrapping="Wrap" Margin="4" Text="{Binding SavePath}"/>
                </Border>
            </Grid>
        </Grid>

        <Grid Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="24"/>
                <RowDefinition Height="8"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock VerticalAlignment="Center">
                <Run>恢复列表</Run>
                <Run> </Run>
                <Run>(</Run>
                <Run Text="{Binding TableCount}"/>
                <Run>)</Run>
            </TextBlock>

            <Border Grid.Row="2" Grid.ColumnSpan="3" BorderBrush="Black" BorderThickness="1">
                <ScrollViewer>
                    <ItemsControl Margin="4" ItemsSource="{Binding Tables}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </Border>
        </Grid>

        <Button Grid.Row="2" Grid.ColumnSpan="3" Height="24" Command="{Binding RestoreCommand}">开始还原</Button>
    </Grid>
</UserControl>
