<UserControl x:Class="SlnMesnac.WPF.Page.BaseConfigInfoPage"
             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" 
             mc:Ignorable="d" 
             d:DesignHeight="1080" d:DesignWidth="1920">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="8*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Margin="0,0,0,10">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">

                <TextBlock Text="配置名称:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="80,0,10,0"/>
                <TextBox x:Name="queryParam" Text="{Binding SearchStr}" 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}" />


                <Button Content="手动输入RFID(异常处理)" x:Name="InputRFIDButton" Foreground="White" FontSize="16"  Width="250" Height="50" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Click="InputRFIDButton_Click" />

                
                <Button Content="重  置" FontSize="16" Visibility="Collapsed" Style="{StaticResource BUTTON_AGREE}"  Width="120" Height="35" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Command="{Binding ResetSearchCommand}" />

            </StackPanel>
        </Border>

        <Border Grid.Row="1" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Margin="0,0,0,10">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">

                <TextBox Text="{Binding SelectedItem.ConfigId, ElementName=dgvMH}" x:Name="ConfigId" Foreground="White" FontSize="18" Width="50" Visibility="Hidden"/>
                
                <TextBlock Text="配置Key:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
                <TextBox Text="{Binding SelectedItem.ConfigKey, ElementName=dgvMH}" x:Name="ConfigKey" Foreground="White" FontSize="18" Width="200" Height="35"/>

                <TextBlock Text="配置名称:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
                <TextBox Text="{Binding SelectedItem.ConfigName, ElementName=dgvMH}" x:Name="ConfigName" Foreground="White" FontSize="18" Width="200" Height="35"/>

                <TextBlock Text="配置内容:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
                <TextBox Text="{Binding SelectedItem.ConfigValue, ElementName=dgvMH}" x:Name="ConfigValue" Foreground="White" FontSize="18" Width="200" Height="35"/>

                <TextBlock Text="配置标识:" FontSize="20" Foreground="White" VerticalAlignment="Center" Margin="30,0,10,0"/>
                <TextBox Text="{Binding SelectedItem.IsFlag, ElementName=dgvMH}" x:Name="ConfigFlag" 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}" />-->
                <Button Content="添加" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Visibility="Collapsed" Width="120" Height="35" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Click="SaveButton_Click" />
                <Button Content="修改" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="35" Background="#007DFA" BorderBrush="#007DFA" Margin="20,0,10,0" Click="EditButton_Click" />

            </StackPanel>
        </Border>

        <Border Grid.Row="2" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Margin="0,0,0,10">
            <DataGrid x:Name="dgvMH" 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" SelectedItem="{Binding SelectedCells, Mode=OneWayToSource}">
                <!--resourceStyle 399行修改选中字体颜色-->
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding ConfigId}" Header="序号" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding ConfigKey}" Header="配置Key" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding ConfigName}" Header="配置名称" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding ConfigValue}" Header="配置内容" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding IsFlag}" Header="是否标识" Width="3*" IsReadOnly="True"/>
                    <DataGridTextColumn Binding="{Binding CreateTime,StringFormat=\{0:yyyy-MM-dd\}}" Header="记录时间" Width="3*" IsReadOnly="True"/>
                    <DataGridTemplateColumn Header="操作" Width="2*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Button Content="删除" CommandParameter="{Binding ConfigId}"  Visibility="Collapsed" Background="Red" Foreground="White" Margin="10,0,0,0" Height="25" BorderBrush="Red" BorderThickness="0" Width="100" Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid  }}"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>

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