<UserControl x:Class="SlnMesnac.WPF.Page.Generate.GenerateControl"
             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:SlnMesnac.WPF.Page.Generate"
             xmlns:local1="clr-namespace:SlnMesnac.WPF.Converter.Generate"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Background="Transparent">
    <Control.Resources>
        <local1:RowToIndexConverter x:Key="RowToIndexConverter" />
    </Control.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="8*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderBrush="Green" BorderThickness="2" CornerRadius="5" Margin="0,0,0,10">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                
                <TextBlock Text="数据库连接:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="10,0,10,0"/>
                <ComboBox Width="200" Height="35" FontSize="18" VerticalAlignment="Center" Name="comboBox1" ItemsSource="{Binding Options}" SelectedItem="{Binding SelectedOption, Mode=TwoWay}" DisplayMemberPath="."/>

                <TextBlock Text="表名:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
                <TextBox x:Name="queryParam" Foreground="White" FontSize="18" Width="200" Height="35"/>

                <Button Content="查  询" FontSize="16" Style="{StaticResource BUTTON_AGREE}"  Width="120" Height="35" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Command="{Binding QuerySearchCommand}" CommandParameter="{Binding Text, ElementName=queryParam}" />

            </StackPanel>
        </Border>
        <Border Grid.Row="1" BorderBrush="Green" BorderThickness="2" CornerRadius="5" Margin="0,0,0,10">
            <DataGrid x:Name="datagrid" Grid.Row="0" ItemsSource="{Binding TablesDataGrid}" Background="Transparent" 
                FontSize="15" ColumnHeaderHeight="35" 
                RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0" 
                GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
                Foreground="#FFFFFF" >
                <!--resourceStyle 399行修改选中字体颜色-->
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}" Header="表名" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding Description}" Header="说明" Width="3*" IsReadOnly="True"/>
                    <DataGridTemplateColumn Header="操作" Width="2*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Button Content="生成代码" CommandParameter="{Binding Name}" Background="#009999" Foreground="White" Margin="10,0,0,0" Height="25" BorderBrush="#009999" BorderThickness="0" Width="100" Command="{Binding DataContext.CreateCodeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid  }}"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>

                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Border>
    </Grid>
</UserControl>
