<UserControl x:Class="MeterVision.Stand.UCStandGrid"
             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.Stand"
             xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
             mc:Ignorable="d" 
             Background="White"
             BorderThickness="0"
             Padding="5"
             BorderBrush="#E0E0E0"
             AllowDrop="True"
             d:DesignHeight="800" d:DesignWidth="1000">
             <!--Drop="UserControl_Drop" 
             DragEnter="UserControl_DragEnter"-->
    <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"/>
        </Style>

    </UserControl.Resources>

    <Grid>
        <DataGrid Name="dgStandDetails" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="100" BorderBrush="#D3D3D3"
                  HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                  FrozenColumnCount="2"
                  SelectedItem="{Binding SelectedStandDetailItem,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" />
                            <!-- 设置选中单元格的前景色 -->
                            <!--<Setter Property="Foreground" Value="Black"/>-->
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.Resources>

            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="miUpdateStandvalue" Header="修改标准值" Click="MiUpdateStandvalue_Click" >
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/MeterVision;component/Assest/mi_update1.png" Width="16" Height="16"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem x:Name="miDelteRow" Header="删除此行" Click="MiDelteRow_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="60">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Index}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="原始图片" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding SrcImage}" MouseLeftButtonDown="Image_MouseLeftButtonDown"
                                   ToolTip="{Binding SrcImage}"
                                   VerticalAlignment="Center" HorizontalAlignment="Center"  Margin="2,2,2,2"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="标准值" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border BorderBrush="#D3D3D3" BorderThickness="0 0 0 1"  Padding="2" Margin="10 0 10 0" VerticalAlignment="Center">
                                <TextBlock Text="{Binding StandValue}" FontSize="14px" Foreground="#000000" Margin="2" ToolTip="点击修改"                                           
                                                   VerticalAlignment="Center" PreviewMouseLeftButtonDown="StandValue_PreviewMouseLeftButtonDown" />
                            </Border>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="操作" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                <Button x:Name="btnConfig" Width="Auto" FontSize="13px" Content="配置" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 10" Click="BtnConfig_Click"  />
                                
                                <Button x:Name="btnUpdateStandvalue" Width="Auto" FontSize="13px" Content="标准值" Foreground="#2196F3" VerticalAlignment="Center"
                                        Click="BtnUpdateStandvalue_Click"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Margin="0 0 0 10" />
                                
                                <Button x:Name="btnDelDetailItem" Width="Auto" FontSize="13px" Content="删除" Foreground="#2196F3" VerticalAlignment="Center"
                                        BorderBrush="Transparent" BorderThickness="0 0 0 0" Background="Transparent" Click="BtnDelDetailItem_Click"  />
                                
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="站点+采样时间" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0 0 0 0" VerticalAlignment="Center">
                                <TextBlock Text="{Binding StationId}" FontSize="14px" Margin="0 0 0 10"
                                           Foreground="{Binding StationIdColor}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <TextBlock Text="{Binding SampleTime1}" FontSize="14px" Margin="0 0 0 5"
                                           Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <TextBlock Text="{Binding SampleTime2}" FontSize="14px" Margin="0 0 0 0"
                                           Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <!--<DataGridTemplateColumn Header="设备SN" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DeviceSn}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

                <!--<DataGridTemplateColumn Header="采样时间" Width="180">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding SampleTime}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

                <!--<DataGridTemplateColumn Header="数字个数" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding NumCount}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="尾数单位" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding LastUnitName}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->

                <DataGridTemplateColumn Header="配置信息1" Width="110">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!--<StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0">-->
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0">
                                <TextBlock FontSize="14px" Text="{Binding MeterTypeName}" 
                                           Foreground="#000000" Margin="0 0 0 10" HorizontalAlignment="Left"/>
                                <TextBlock FontSize="14px" Text="{Binding CountName}" 
                                           Foreground="#000000" Margin="0 0 0 10" HorizontalAlignment="Left" />
                                <TextBlock FontSize="14px" HorizontalAlignment="Left"  Margin="0 0 0 0"
                                           Text="{Binding LastUnitName,Mode=OneWay}" Foreground="#000000"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="配置信息2" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!--<StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0">-->
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0">
                                <TextBlock FontSize="14px" HorizontalAlignment="Left"  Margin="0 0 0 10"
                                           Text="{Binding BrightValName,Mode=OneWay}" Foreground="#000000"/>
                                <TextBlock FontSize="14px" HorizontalAlignment="Left"  Margin="0 0 0 10"
                                           Text="{Binding FlowRateName,Mode=OneWay}" Foreground="#000000"/>
                                <TextBlock FontSize="14px" HorizontalAlignment="Left" VerticalAlignment="Center"  Margin="0 0 0 0"
                                           Text="{Binding LastValueName,Mode=OneWay}" Foreground="#000000"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="区域信息" Width="250">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!--<StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0">-->
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0">
                                <TextBlock FontSize="14px" Text="{Binding DialRegionName}" TextWrapping="Wrap"
                                           Foreground="#000000" Margin="0 0 0 10" HorizontalAlignment="Left"/>
                                <TextBlock FontSize="14px" Text="{Binding FeatureRegionName}" TextWrapping="Wrap"
                                           Foreground="#000000" Margin="0 0 0 5" HorizontalAlignment="Left" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


                <!--<DataGridTemplateColumn Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->
                                
            </DataGrid.Columns>
        </DataGrid>
        
    </Grid>
</UserControl>
