<UserControl x:Class="MeterVision.Station.UCVpsGrid"
             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:MeterVision.Station"
             mc:Ignorable="d" 
             Background="White"
             BorderThickness="0"
             Padding="5"
             BorderBrush="#E0E0E0"             
             d:DesignHeight="800" d:DesignWidth="1000">
    <UserControl.Resources>
        <Style TargetType="ContextMenu">
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderBrush" Value="#DDDDDD"/>
            <Setter Property="BorderThickness" Value="1"/>
        </Style>

        <Style TargetType="MenuItem">
            <Setter Property="Padding" Value="5,2"/>
            <!--<Setter Property="Icon" Value="{StaticResource DefaultIcon}"/>-->
        </Style>
    </UserControl.Resources>

    <Grid>
        <DataGrid Name="dgStation" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="80" BorderBrush="#D3D3D3"
                  HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                  FrozenColumnCount="5"
                  SelectedItem="{Binding SelectedStationItem,Mode=TwoWay}"
                  AutoGenerateColumns="False" CanUserAddRows="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White">
            <DataGrid.Resources>
                <Style TargetType="DataGridColumnHeader">
                    <Setter Property="Height" Value="40" />
                    <!--Setter Property="Background" Value="White" /-->
                    <Setter Property="Foreground" Value="Black" />
                    <Setter Property="FontSize" Value="13px" />
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="BorderBrush" Value="#D3D3D3" />
                    <Setter Property="BorderThickness" Value="0,0,1,1" />
                    <Setter Property="HorizontalContentAlignment" Value="Center" />
                </Style>
                <!-- 自定义行的选中样式 -->
                <Style TargetType="DataGridRow">
                    <Style.Triggers>
                        <!-- 当行被选中时 -->
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                            <!-- 设置选中行的背景色 -->
                            <Setter Property="Background" Value="AliceBlue"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>

                <!-- 自定义选中单元格的背景色 -->
                <Style TargetType="DataGridCell">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                            <!-- 设置选中单元格的背景色 -->
                            <Setter Property="Background" Value="AliceBlue"/>
                            <Setter Property="BorderBrush" Value="Transparent" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.Resources>

            <!--<DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="miDelete" Header="删除站点" Click="MiDelete_Click">
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/MeterVision;component/Assest/mi_delete.png" Width="16" Height="16"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </DataGrid.ContextMenu>-->

            <DataGrid.Columns>
                <!--使用自定义模板-->
                <!--<DataGridTemplateColumn Header="序号" Width="50">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Index}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

                <DataGridTemplateColumn Header="站点" Width="280">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid Margin="5 0 10 0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid Grid.Row="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Index,StringFormat='{}{0}.'}" FontSize="14px" Foreground="#000000" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBlock Grid.Column="1" Text="{Binding StationIdName}" FontSize="14px" Foreground="#000000" FontWeight="Bold"
                                               Margin="20 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <TextBlock Grid.Column="2" FontSize="14px" Foreground="{Binding TotalRunRateColor}"  Margin="0 0 10 0"
                                               VerticalAlignment="Center" HorizontalAlignment="Right">
                                        <TextBlock.Text>
                                            <MultiBinding StringFormat="{}{0} / {1}">
                                                <Binding Path="RunCount" />
                                                <Binding Path="TotalCount"/>
                                            </MultiBinding>
                                        </TextBlock.Text>
                                    </TextBlock>
                                </Grid>
                                <Grid Grid.Row="1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Text="正确" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="14px" Foreground="#28a745" />
                                    <TextBlock Grid.Column="1" Text="错误" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="14px" Foreground="#dc3545" />
                                    <TextBlock Grid.Column="2" Text="无效" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="14px" Foreground="#FFA500" />
                                </Grid>

                                <Grid Grid.Row="2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*" />
                                        <!--<ColumnDefinition Width="*" />-->
                                    </Grid.ColumnDefinitions>
                                    <!--<TextBlock Grid.Column="0" Text="{Binding TotalCount,StringFormat='总数: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#000000" />-->
                                    <!--<TextBlock Grid.Column="1" Text="{Binding EqualCountRate,StringFormat='正确: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#28a745" />
                                    <TextBlock Grid.Column="2" Text="{Binding ErrorCountRate,StringFormat='错误: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#dc3545" />
                                    <TextBlock Grid.Column="3" Text="{Binding InvalidCountRate,StringFormat='无效: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#FFA500" />-->
                                    <TextBlock Grid.Column="0" Text="{Binding EqualRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#000000" />
                                    <TextBlock Grid.Column="1" Text="{Binding ErrorRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#000000" />
                                    <TextBlock Grid.Column="2" Text="{Binding InvalidRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                               FontSize="13px" Foreground="#000000" />
                                </Grid>
                                
                            </Grid>
                            
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <!--<DataGridTemplateColumn Header="标注" Width="50">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding MarkCountName}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

            </DataGrid.Columns>

        </DataGrid>

    </Grid>
</UserControl>
