<UserControl x:Class="MeterVision.Patch.UCPatchGrid"
             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.Patch"
             xmlns:converter="clr-namespace:MeterVision.Converter"
             mc:Ignorable="d" 
             Background="White"
             BorderThickness="0"
             Padding="5"
             BorderBrush="#E0E0E0"
             d:DesignHeight="800" d:DesignWidth="1000">
    <UserControl.Resources>
        <converter:ImagePathToImageSourceConverter x:Key="ImagePatchConverter" />
        <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="dgPatchDetail" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="100" BorderBrush="#D3D3D3"
                  HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                  FrozenColumnCount="4"
                  SelectedItem="{Binding SelectedPatchDetailItem,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="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="miViewLog" Header="查看日志" Click="MiViewLog_Click" >
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/MeterVision;component/Assest/mi_log.png" Width="16" Height="16"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem x:Name="miMemo" Header="添加备注" Click="MiAddMemo_Click">
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/MeterVision;component/Assest/memo.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>
                    <Separator/>
                    <MenuItem x:Name="miRecong" Header="重新识别" Click="MiRecong_Click">
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/MeterVision;component/Assest/single_2.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="50" Visibility="Collapsed">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding RunFlagName}" Foreground="{Binding RunFlagColor}" 
                                       FontSize="14px" FontWeight="Normal" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

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


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

                <DataGridTemplateColumn Header="最近一次正确结果" Width="150">
                    <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="13px" HorizontalAlignment="Left"  Margin="0 0 0 5"
                                           Text="{Binding LatestTime,Mode=OneWay}" Foreground="#000000"/>
                                <TextBlock FontSize="13px" HorizontalAlignment="Left"  Margin="0 0 0 5"
                                           Text="{Binding LatestValueName,Mode=OneWay}" Foreground="#000000"/>
                                <TextBlock FontSize="13px" HorizontalAlignment="Left" VerticalAlignment="Center"  Margin="0 0 0 0"
                                           Text="{Binding LatestCompleteName,Mode=OneWay}" Foreground="#000000"/>
                                <TextBlock FontSize="13px" HorizontalAlignment="Left" VerticalAlignment="Center"  Margin="0 0 0 0"
                                           Text="{Binding LastCompressName,Mode=OneWay}" Foreground="#000000"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="识别时间" Width="90">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <TextBlock Text="{Binding RunTime_date}" FontSize="13px" Foreground="#000000" HorizontalAlignment="Center" Margin="0 0 0 5"/>
                                <TextBlock Text="{Binding RunTime_time}" FontSize="14px" Foreground="#000000" HorizontalAlignment="Center"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="正确" Width="45" Visibility="Visible">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Visibility="{Binding ResultVisiable}" Text="{Binding EqaulFlagName,Mode=OneWay}" Foreground="{Binding EqualFlagColor}" FontSize="20px" 
                                       FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn> 

                <DataGridTemplateColumn Header="结果比对" Width="155">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" VerticalAlignment="Center">
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0 0 0 5" Background="Transparent">
                                    <!--<TextBlock Text="识别值：" Foreground="{Binding FinalValueColor}" FontSize="13px" Padding="5 0 0 0" VerticalAlignment="Center"/>-->
                                    <!--<TextBlock Text="{Binding FinalValue}" Foreground="{Binding FinalValueColor}" FontSize="14px" Margin="0 0 0 0" VerticalAlignment="Center" Padding="2" />-->
                                    <TextBlock Text="识别值：" Foreground="{Binding EqualFlagColor}" FontSize="13px" Padding="5 0 0 0" VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding FinalValueName2}" Foreground="{Binding EqualFlagColor}" FontSize="14px" Margin="0 0 0 0" VerticalAlignment="Center" Padding="2" />
                                </StackPanel>

                                <StackPanel Orientation="Horizontal" Margin="0 5 0 0" VerticalAlignment="Center">
                                    <TextBlock Text="标准值：" FontSize="13px" Foreground="#666666" Padding="5 0 0 0" VerticalAlignment="Center" />
                                    <Border BorderBrush="#D3D3D3" BorderThickness="0 0 0 1" Width="85" Padding="2">
                                        <TextBlock Text="{Binding StandValue}" FontSize="14px" Foreground="#000000" 
                                                   VerticalAlignment="Center" ToolTip="双击修改" PreviewMouseLeftButtonDown="StandResultTextBlock_PreviewMouseLeftButtonDown" />
                                    </Border>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="结果图片" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Visibility="{Binding ResultVisiable}" Source="{Binding DstImage,Converter={StaticResource ImagePatchConverter}}"
                                   ToolTip="{Binding DstImage}"
                                   PreviewMouseLeftButtonDown ="DstImage_PreviewMouseLeftButtonDown"
                                   VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2,2,2,2"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>



                <DataGridTemplateColumn Header="识别结果" Width="140">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Visibility="{Binding ResultVisiable}" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="5 0 0 0">
                                <Grid Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 0 5">
                                    <!-- Ellipse: 圆形 -->
                                    <Ellipse x:Name="circle" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18">
                                        <Ellipse.Fill>
                                            <SolidColorBrush Color="{Binding ResultTypeColor}"/>
                                            <!--颜色值要做动态绑定-->
                                        </Ellipse.Fill>
                                    </Ellipse>
                                    <!-- TextBlock: 显示文本 -->
                                    <TextBlock Text="{Binding ResultType}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="13px" Foreground="White" />
                                </Grid>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0 0 0 5">
                                    <TextBlock Text="结果：" FontSize="13px" Foreground="#666666" Padding="5 0 0 0"/>
                                    <TextBlock Text="{Binding FinalValueName}" FontSize="14px" Foreground="#000000" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="原始：" FontSize="13px" Foreground="#666666" Padding="5 0 0 0" />
                                    <TextBlock Text="{Binding RawValueName}" FontSize="14px" Foreground="#000000" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="0 5 0 0" VerticalAlignment="Center">
                                    <TextBlock Text="类型：" FontSize="13px" Foreground="#666666" Padding="5 0 0 0" />
                                    <TextBlock Text="{Binding ResultMeterName}" FontSize="13px" Foreground="#000000" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="调试信息" Width="320">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid Visibility="{Binding ResultVisiable}" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="5 0 5 0">
                                <!-- 定义行和列 -->
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <!-- 第一行 -->
                                <Border Grid.Row="0" Grid.Column="0" BorderBrush="#D3D3D3" BorderThickness="1 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[0]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px" />
                                </Border>
                                <Border Grid.Row="0" Grid.Column="1" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[1]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="2" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[2]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="3" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[3]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="4" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[4]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="5" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[5]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="6" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[6]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="7" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[7]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="8" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[8]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="9" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[9]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="10" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[10]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="11" BorderBrush="#D3D3D3" BorderThickness="0 1 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[11]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>

                                <!-- 第二行 -->
                                <Border Grid.Row="1" Grid.Column="0" BorderBrush="#D3D3D3" BorderThickness="1 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[12]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="1" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[13]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="2" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[14]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="3" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[15]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="4" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[16]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="5" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[17]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="6" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[18]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="7" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[19]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="8" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[20]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="9" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[21]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="10" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[22]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>
                                <Border Grid.Row="1" Grid.Column="11" BorderBrush="#D3D3D3" BorderThickness="0 0 1 1" Padding="0 2">
                                    <TextBlock Text="{Binding AI_result_array[23]}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#333333" FontSize="13px"/>
                                </Border>

                                <StackPanel Grid.Row="2" Grid.ColumnSpan="12" Orientation="Horizontal">
                                    <!--<TextBlock FontSize="14px" HorizontalAlignment="Left" Margin="5 5 0 0">
                                        <Run Text="AI版本：" Foreground="#666666"/> 
                                        <Run Text="{Binding AiVer}" Foreground="#000000" FontSize="14px"/>
                                    </TextBlock>-->
                                    <TextBlock FontSize="14px" HorizontalAlignment="Left"  Margin="5 10 0 0"
                                           Text="{Binding AiVer, StringFormat='AI版本: {0}'}" Foreground="#000000"/>
                                    <TextBlock FontSize="14px" HorizontalAlignment="Left"  Margin="5 10 0 0"
                                           Text="{Binding CompleteValue, StringFormat='完整值: {0}'}" Foreground="#000000"/>
                                </StackPanel>

                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


                <DataGridTemplateColumn Header="操作" Width="80">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                <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="btnLogViewer" Width="Auto" FontSize="13px" Content="日志" Foreground="#2196F3" VerticalAlignment="Center"
                                        Click="BtnLogViewer_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="配置信息1" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Visibility="Visible" 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 NumCountName}" 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 NumInUpperName,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="150">
                    <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 MeterRegionName}" 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 Header="备注" Width="140">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border Background="Transparent" Padding="5" PreviewMouseLeftButtonDown="Memo_PreviewMouseLeftButtonDown">
                                <TextBlock FontSize="14px" Text="{Binding Memo}" TextWrapping="Wrap"                                   
                                   Foreground="#000000" Margin="0" HorizontalAlignment="Left"/>
                                <!--PreviewMouseLeftButtonDown="Memo_PreviewMouseLeftButtonDown"-->
                            </Border>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


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