<UserControl x:Class="MeterVision.Patch.UCPatchMain"
             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:local2="clr-namespace:MeterVision"
             xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
             xmlns:img="clr-namespace:MeterVision.UC"
             xmlns:station="clr-namespace:MeterVision.Station"
             mc:Ignorable="d"
             Padding="5 2 5 5"
             Background="WhiteSmoke"
             d:DesignHeight="800" d:DesignWidth="1600">
    <UserControl.Resources>
        <!--<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <local1:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter" />-->

        <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>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="220" x:Name="colLeft" />
            <ColumnDefinition Width="300" x:Name="colStation" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="400" x:Name="colRight" />
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0" BorderBrush="#C0C0C0" BorderThickness="0 0 1 0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>

                <Grid Grid.Row="0" Margin="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <zdfflatui:FlatButton Grid.Column="0" x:Name="btnAddPatch" HorizontalAlignment="Center"
                                              Background="#4CAF50" Content="新建任务"
                                                Click="BtnAddPatch_Click" Foreground="White"
                                              Width="80" Height="28" FontSize="13" Margin="0 0 5 0" />

                    <zdfflatui:FlatButton Grid.Column="1" x:Name="btnDelPatch" HorizontalAlignment="Center"
                                              Background="#FF4C4C" Content="删除任务"
                                                Click="BtnDelPatch_Click" Foreground="White"
                                              Width="80" Height="28" FontSize="13" Margin="0 0 5 0" />

                    <zdfflatui:FlatButton Grid.Column="2" x:Name="btnRefresh" HorizontalAlignment="Center"
                                              Background="#2196F3" Foreground="White" Content="🔄"
                                          ToolTip="刷新数据列表"
                                          Click="BtnRefresh_Click" Margin="0 0 10 0"
                                          Width="30" Height="28" FontSize="20px"  />
                </Grid>

                <!--OliveDrab-->
                <Border Grid.Row="1" BorderThickness="0" BorderBrush="#C0C0C0" Margin="0 0 5 0">
                    <!--嵌套一个DataGrid-->
                    <DataGrid x:Name="dgPatch" GridLinesVisibility="All" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent"
                              BorderBrush="#D3D3D3" HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow"
                              HorizontalScrollBarVisibility="Disabled" CanUserReorderColumns="False" RowHeight="NaN"
                              SelectedItem="{Binding SelectedPatchItem,Mode=TwoWay}"
                              AutoGenerateColumns="False" CanUserAddRows="False" HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch" Background="White" Padding="5" Margin="0">
                        <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,0,0" />
                                <Setter Property="HorizontalContentAlignment" Value="Center" />
                                <Setter Property="Margin" Value="0 0 0 0" />
                                <Setter Property="Padding" Value="5" />
                            </Style>

                            <!-- 自定义行的选中样式 -->
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <!-- 当行被选中时 -->
                                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                        <!-- 设置选中行的背景色 -->
                                        <Setter Property="Background" Value="Transparent"/>
                                        <Setter Property="BorderThickness" Value="1" />
                                        <Setter Property="BorderBrush" Value="CornflowerBlue" />
                                    </DataTrigger>
                                </Style.Triggers>
                                <Setter Property="Margin" Value="0,0,5,5"/>
                                <Setter Property="BorderThickness" Value="1" />
                                <Setter Property="BorderBrush" Value="CadetBlue" />
                                <!-- 或者使用 Padding 属性，取决于你想要的效果 -->
                                <!-- <Setter Property="Padding" Value="0,5,0,5"/> -->
                            </Style>
                            <!-- 自定义选中单元格的背景色 -->
                            <Style TargetType="DataGridCell">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                        <!-- 设置选中单元格的背景色 -->
                                        <Setter Property="Background" Value="AliceBlue"/>
                                        <Setter Property="BorderBrush" Value="Red" />
                                        <!-- 设置选中单元格的前景色 -->
                                        <!--<Setter Property="Foreground" Value="Black"/>-->
                                    </DataTrigger>
                                </Style.Triggers>
                                <!--<Setter Property="Foreground" Value="White" />-->
                                <Setter Property="BorderBrush" Value="SeaGreen" />
                                <Setter Property="BorderThickness" Value="0" />
                            </Style>
                        </DataGrid.Resources>

                        <DataGrid.ContextMenu>
                            <ContextMenu>
                                <MenuItem x:Name="miUpdatePatchname" Header="修改任务名称" Click="MiUpdatePatchname_Click" >
                                    <MenuItem.Icon>
                                        <Image Source="pack://application:,,,/MeterVision;component/Assest/mi_update1.png" Width="16" Height="16"/>
                                    </MenuItem.Icon>
                                </MenuItem>
                                <Separator />
                                <MenuItem x:Name="miDeletePatch" Header="删除任务" Click="MiDeletePatch_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="{Binding Path=TotalPatchRecords, 
                                    RelativeSource={RelativeSource AncestorType=UserControl}, 
                                    StringFormat='任务列表[{0}]'}" Width="*">-->
                            <DataGridTemplateColumn  Width="*">
                                <DataGridTemplateColumn.Header>
                                    <!--<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=TotalPatchRecords,
                                        StringFormat='任务列表 （共 {0} 个）',Mode=OneWay}" />-->
                                    <TextBlock Text="任务列表" FontSize="14px" />
                                </DataGridTemplateColumn.Header>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical"  VerticalAlignment="Stretch" Margin="5 5 10 5">
                                            <Border  HorizontalAlignment="Stretch" BorderBrush="#D3D3D3" BorderThickness="0 0 0 1" Padding="0" Margin="0" >
                                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                                    <Border VerticalAlignment="Center" Margin="0 0 0 5">
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="*" />
                                                                <ColumnDefinition Width="Auto" />
                                                            </Grid.ColumnDefinitions>

                                                            <TextBlock Text="{Binding Index,StringFormat='{}{0}.'}" Grid.Column="0" FontSize="14px" Foreground="#000000" 
                                                                       VerticalAlignment="Center" />
                                                            <TextBlock Text="{Binding PatchState}" Foreground="{Binding PatchStateColor}"
                                                                       Grid.Column="1" FontSize="13px" FontWeight="Bold"
                                                                       HorizontalAlignment="Stretch" TextAlignment="Right" />
                                                        </Grid>
                                                    </Border>

                                                    <TextBlock Text="{Binding PatchName}" FontWeight="Normal" HorizontalAlignment="Center"
                                                            Foreground="{Binding PatchNameColor}" FontSize="14px" 
                                                               TextWrapping="Wrap" TextAlignment="Center"
                                                               VerticalAlignment="Center" Margin="0 0 0 0" />
                                                    <TextBlock Text="{Binding CreateTimeName}" FontSize="13px" TextAlignment="Center" 
                                                            Foreground="#333333" Margin="0 5 0 5"/>
                                                </StackPanel>
                                            </Border>

                                            <TextBlock Text="{Binding StandName,StringFormat='[{0}]'}" TextWrapping="Wrap"
                                                       TextAlignment="Left" FontSize="13px" Foreground="#666666" VerticalAlignment="Center"/>
                                            
                                            <StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0 5 0 0">
                                                    <TextBlock Text="总   数：" TextAlignment="Left" FontSize="14px" VerticalAlignment="Center" Width="55" Foreground="#666666"/>
                                                    <TextBlock Text="{Binding DetailCount}" Margin="0 0 0 0" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </StackPanel>

                                            <!--<StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="已运行：" TextAlignment="Left" FontSize="14px" 
                                                               VerticalAlignment="Center" Width="55" Foreground="#1E90FF"/>
                                                    --><!--<TextBlock Text="{Binding RunCount}" Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>--><!--
                                                    <TextBlock TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center">
                                                        <TextBlock.Text>
                                                            <MultiBinding StringFormat="{}{0,-7} ({1:p1})">
                                                                <Binding Path="RunCount"/>
                                                                <Binding Path="RunRate"/>
                                                            </MultiBinding>
                                                        </TextBlock.Text>
                                                    </TextBlock>
                                                </StackPanel>
                                            </StackPanel>-->

                                            <Grid Height="26" Margin="0">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="已运行：" Grid.Column="0" TextAlignment="Left" FontSize="14px" 
                                                            VerticalAlignment="Center" Width="55" Foreground="#1E90FF"/>

                                                <StackPanel Grid.Column="1" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
                                                    <TextBlock Margin="0 0 0 0" Text="{Binding RunCount}" HorizontalAlignment="Left"
                                                                FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>

                                                <StackPanel Grid.Column="2" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                                    <TextBlock  Text="{Binding RunRate,StringFormat={}{0:P1}}" 
                                                                HorizontalAlignment="Right" Margin="0 0 5 0"
                                                                   FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </Grid>

                                            <!--<StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="正确数：" TextAlignment="Left" FontSize="14px" 
                                                               VerticalAlignment="Center" Width="55" Foreground="#28a745"/>
                                                    --><!--<TextBlock Text="{Binding EqualCount}" Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>--><!--
                                                    <TextBlock Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center">
                                                        <TextBlock.Text>
                                                            <MultiBinding StringFormat="{}{0,-7} ({1:p1})">
                                                                <Binding Path="EqualCount"/>
                                                                <Binding Path="EqualRate"/>
                                                            </MultiBinding>
                                                        </TextBlock.Text>
                                                    </TextBlock>
                                                </StackPanel>
                                            </StackPanel>-->

                                            <Grid Height="26" Margin="0">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="正确数：" Grid.Column="0" TextAlignment="Left" FontSize="14px" 
                                                            VerticalAlignment="Center" Width="55" Foreground="#28a745"/>

                                                <StackPanel Grid.Column="1" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
                                                    <TextBlock Margin="0 0 0 0" Text="{Binding EqualCount}" HorizontalAlignment="Left"
                                                                FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>

                                                <StackPanel Grid.Column="2" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                                    <TextBlock  Text="{Binding EqualRate,StringFormat={}{0:P1}}" 
                                                                HorizontalAlignment="Right" Margin="0 0 5 0"
                                                                   FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </Grid>

                                            <!--<StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="错误数：" TextAlignment="Left" FontSize="14px" 
                                                               VerticalAlignment="Center" Width="55" Foreground="#dc3545"/>
                                                    --><!--<TextBlock Text="{Binding EqualCount}" Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>--><!--
                                                    <TextBlock Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center">
                                                        <TextBlock.Text>
                                                            <MultiBinding StringFormat="{}{0,-7} ({1:p1})">
                                                                <Binding Path="ErrorCount"/>
                                                                <Binding Path="ErrorRate"/>
                                                            </MultiBinding>
                                                        </TextBlock.Text>
                                                    </TextBlock>
                                                </StackPanel>
                                            </StackPanel>-->

                                            <Grid Height="26" Margin="0">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="错误数：" Grid.Column="0" TextAlignment="Left" FontSize="14px" 
                                                            VerticalAlignment="Center" Width="55" Foreground="#dc3545"/>

                                                <StackPanel Grid.Column="1" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
                                                    <TextBlock Margin="0 0 0 0" Text="{Binding ErrorCount}" HorizontalAlignment="Left"
                                                                FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>

                                                <StackPanel Grid.Column="2" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                                    <TextBlock  Text="{Binding ErrorRate,StringFormat={}{0:P1}}" 
                                                                HorizontalAlignment="Right" Margin="0 0 5 0"
                                                                   FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </Grid>

                                            <!--<StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="无效数：" TextAlignment="Left" FontSize="14px" 
                                                               VerticalAlignment="Center" Width="55" Foreground="#FFA500"/>
                                                    --><!--<TextBlock Text="{Binding EqualCount}" Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>--><!--
                                                    <TextBlock Width="120" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center">
                                                        <TextBlock.Text>
                                                            <MultiBinding StringFormat="{}{0,-7} ({1:p1})">
                                                                <Binding Path="InvalidCount"/>
                                                                <Binding Path="InvalidRate"/>
                                                            </MultiBinding>
                                                        </TextBlock.Text>
                                                    </TextBlock>
                                                </StackPanel>
                                            </StackPanel>-->

                                            <Grid Height="26" Margin="0">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="无效数：" Grid.Column="0" TextAlignment="Left" FontSize="14px" 
                                                            VerticalAlignment="Center" Width="55" Foreground="#FFA500"/>

                                                <StackPanel Grid.Column="1" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
                                                    <TextBlock Margin="0 0 0 0" Text="{Binding InvalidCount}" HorizontalAlignment="Left"
                                                                FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>

                                                <StackPanel Grid.Column="2" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                                    <TextBlock  Text="{Binding InvalidRate,StringFormat={}{0:P1}}" 
                                                                HorizontalAlignment="Right" Margin="0 0 5 0"
                                                                   FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </Grid>

                                            <!--删除按钮-->
                                            <!--<StackPanel>
                                                <zdfflatui:FlatButton x:Name="btnDeletePatch" 
                                                  Background="Red" Foreground="White" Content="删除任务"
                                                  Click="BtnDeletePatch_Click"  Height="28" FontSize="13px" Margin="10 5 10 5" />
                                            </StackPanel>-->

                                            <!--<StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="已核正确率：" TextAlignment="Left" FontSize="14px" VerticalAlignment="Center" Width="90" Foreground="#666666"/>
                                                    <TextBlock Text="{Binding CheckRate}" Width="25" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                    <TextBlock Text="%" Width="30" TextAlignment="Left" FontSize="14px" Foreground="#333333" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </StackPanel>

                                            <StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" Height="26" Margin="0">
                                                    <TextBlock Text="总量正确率：" TextAlignment="Left" FontSize="14px" VerticalAlignment="Center" Width="90" Foreground="#666666"/>
                                                    <TextBlock Text="{Binding TotalRate}" Width="25" TextAlignment="Left" FontSize="14px" Foreground="#000000" VerticalAlignment="Center"/>
                                                    <TextBlock Text="%" Width="30" TextAlignment="Left" FontSize="14px" Foreground="#333333" VerticalAlignment="Center"/>
                                                </StackPanel>
                                            </StackPanel>-->
                                        </StackPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Border>

                <Grid Grid.Row="2" Background="WhiteSmoke">
                    <StackPanel Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
                        <!--<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=TotalStandRecords,
                                        StringFormat='模板列表 （共 {0} 个）',Mode=OneWay}" />-->
                        <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=TotalPatchRecords,StringFormat='共 {0} 条数据',Mode=OneWay}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
                        <ComboBox Width="55" Margin="5" FontSize="13px" 
                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
                              SelectedValue="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=mConfigItem.PageSize1}"/>
                    </StackPanel>
                </Grid>

                <Grid Grid.Row="3" Background="WhiteSmoke">
                    <!--<TextBlock Text="50条批量测试任务" VerticalAlignment="Center" HorizontalAlignment="Center"  FontSize="14px"/>-->
                    <StackPanel Grid.Row="2" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
                        
                        <Button x:Name="btnPatchPrePage" Content="上一页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchPrePage_Click"/>
                        <!--<TextBlock Text="2/10" Margin="5" FontSize="13px" VerticalAlignment="Center"/>-->
                        <StackPanel Orientation="Vertical" Margin="5" VerticalAlignment="Center">
                            <!--<TextBlock Text="{Binding TotalPatchRecords,StringFormat='共 {0} 条'}" HorizontalAlignment="Center"  FontSize="13px"/>-->
                            <TextBlock Margin="0" FontSize="13px" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <TextBlock.Text>
                                    <!--<MultiBinding StringFormat="{}{0}/{1}页">-->
                                    <MultiBinding StringFormat="第{0}/{1}页">
                                        <Binding Path="PatchPage.PageNumber"/>
                                        <Binding Path="PatchPage.PageCount"/>
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>
                        </StackPanel>
                        <Button x:Name="btnPatchNextPage" Content="下一页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchNextPage_Click"/>
                    </StackPanel>
                </Grid>
                
            </Grid>
        </Border>


        <Grid Grid.Column="1" Background="WhiteSmoke">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="0"/>
            </Grid.ColumnDefinitions>

            <!--右侧上左站点明细-->
            <Border Grid.Column="0" BorderBrush="#D3D3D3" BorderThickness="0 0 1 0" Padding="0 0 5 0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="40" />
                    </Grid.RowDefinitions>

                    <!--右上空间的上方状态栏-->
                    <Border Grid.Row="0" BorderBrush="#D3D3D3" BorderThickness="0 0 0 0" Padding="0 2 0 2" Margin="2 0 2 0">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <!--<TextBlock Grid.Column="0" Text="站点列表-管理水表识别时所需的参数" 
                                   TextWrapping="Wrap" FontWeight="Bold" FontSize="14px" VerticalAlignment="Center" />-->
                            <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="5 0 2 0">
                                <Button Content="◀️" x:Name="btnLeftCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
                                        Click="BtnLeftCtl_Click" Foreground="White" Background="#333333" Margin="0 0 5 0" />
                                <TextBlock x:Name="txtPatchName" Text="1."  Visibility="Visible"
                                               FontSize="14px" FontWeight="Bold" VerticalAlignment="Center" />
                            </StackPanel>

                            <StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
                                <!--<Button Content="◀️" x:Name="btnLeftCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
                                        Click="BtnLeftCtl_Click" Foreground="White" Background="#333333" Margin="5 0 5 0" />-->

                                <TextBlock Text="站点:" VerticalAlignment="Center" Margin="5 0 5 0"
                                        Foreground="Black" FontSize="14px" />
                                <TextBox x:Name="txtFindStationId" FontSize="14px" Width="110" Text="12345678901" VerticalAlignment="Center" 
                                        Padding="2" Margin="0 0 10 0" PreviewTextInput="TextBox_PreviewTextInput" />
                                <zdfflatui:FlatButton Grid.Column="1" x:Name="btnQuery" HorizontalAlignment="Center"
                                              Background="#2196F3" Content="查询"
                                                Click="BtnQuery_Click" Foreground="White"
                                              Width="60" Height="28" FontSize="14" Margin="0 0 5 0" />

                                <zdfflatui:FlatButton Grid.Column="2" x:Name="btnRefreshStation" HorizontalAlignment="Center"
                                              Background="#2196F3" Foreground="White" Content="🔄"
                                          ToolTip="刷新数据列表" Visibility="Collapsed"
                                          Click="BtnRefreshStation_Click" Margin="10 0 10 0"
                                              Width="30" Height="28" FontSize="20px"  />
                            </StackPanel>

                        </Grid>
                    </Border>

                    <Border Grid.Row="1">
                        <station:UCVpsGrid x:Name="ucStationGrid" Padding="5 5 5 5" />
                    </Border>
                    <!-- 底部分页控件 -->
                    <StackPanel Grid.Row="2" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
                        <TextBlock Text="{Binding ElementName=ucStationGrid,Path=TotalRecords,StringFormat='共 {0} 条数据'}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
                        <ComboBox Width="55" Margin="5" FontSize="13px" 
                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
                              SelectedValue="{Binding ElementName=ucStationGrid,Path=mConfigItem.PageSize2}"/>
                        <!--<Button x:Name="btnStationFirstPage" Content="首页" Width="55" Margin="5" FontSize="13px" Click="BtnStationFirstPage_Click"/>
                            <Button x:Name="btnStationPrePage" Content="上一页" Width="55" Margin="5" FontSize="13px" Click="BtnStationPrePage_Click"/>
                            <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
                                <TextBlock.Text>
                                    -->
                        <!--<MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">-->
                        <!--
                                    <MultiBinding StringFormat="{}{0}/{1}">
                                        <Binding ElementName="ucStationGrid" Path="StationPage.PageNumber"/>
                                        <Binding ElementName="ucStationGrid" Path="StationPage.PageCount"/>
                                    </MultiBinding>
                                </TextBlock.Text>
                            </TextBlock>

                            <Button x:Name="btnStationNextPage" Content="下一页" Width="55" Margin="5" FontSize="13px" Click="BtnStationNextPage_Click"/>
                            <Button x:Name="btnStationLastPage" Content="尾页" Width="55" Margin="5" FontSize="13px" Click="BtnStationLastPage_Click"/>-->
                        <TextBox x:Name="txtStationPageNumber" Width="40" Margin="5" TextAlignment="Center" FontSize="13px"
                                 Text="{Binding ElementName=ucStationGrid,Path=StationPage.PageNumber,Mode=OneWay}" Visibility="Visible"
                                 MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
                        <Button x:Name="btnStationSpeciPage" Content="跳转" Width="50" Margin="5" FontSize="13px" 
                                    Visibility="Visible" Click="BtnStationSpeciPage_Click"/>
                    </StackPanel>

                    <StackPanel Grid.Row="3" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
                        <!--<TextBlock Text="{Binding ElementName=ucStationGrid,Path=TotalRecords,StringFormat='共 {0} 条数据'}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
                            <ComboBox Width="55" Margin="5" FontSize="13px" 
                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
                              SelectedValue="{Binding ElementName=ucStationGrid,Path=mConfigItem.PatchPageSize}"/>-->
                        <Button x:Name="btnStationFirstPage" Content="首页" Width="50" Margin="5" FontSize="13px" Click="BtnStationFirstPage_Click"/>
                        <Button x:Name="btnStationPrePage" Content="上一页" Width="50" Margin="5" FontSize="13px" Click="BtnStationPrePage_Click"/>
                        <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
                            <TextBlock.Text>
                                <!--<MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">-->
                                <MultiBinding StringFormat="{}{0}/{1}">
                                    <Binding ElementName="ucStationGrid" Path="StationPage.PageNumber"/>
                                    <Binding ElementName="ucStationGrid" Path="StationPage.PageCount"/>
                                </MultiBinding>
                            </TextBlock.Text>
                        </TextBlock>

                        <Button x:Name="btnStationNextPage" Content="下一页" Width="50" Margin="5" FontSize="13px" Click="BtnStationNextPage_Click"/>
                        <Button x:Name="btnStationLastPage" Content="尾页" Width="50" Margin="5" FontSize="13px" Click="BtnStationLastPage_Click"/>
                        <!--<TextBox x:Name="txtStationPageNumber" Width="40" Margin="5" TextAlignment="Center" FontSize="13px"
                                 Text="{Binding ElementName=ucStationGrid,Path=StationPage.PageNumber,Mode=OneWay}"
                                 MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
                            <Button x:Name="btnStationSpeciPage" Content="跳转" Width="55" Margin="5" FontSize="13px" Click="BtnStationSpeciPage_Click"/>-->
                    </StackPanel>
                </Grid>
            </Border>
            <!--右侧上左站点明细结束-->
        </Grid>

        <Border Grid.Column="2" BorderBrush="#D3D3D3" BorderThickness="0 0 1 0" Padding="0 0 5 0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="5 0 2 0">
                        <Button Content="◀️" x:Name="btnLeftCtl1" FontSize="20px" Width="28" Height="28" Visibility="Collapsed"
                                Click="BtnLeftCtl_Click"
                               Foreground="White" Background="#333333" Margin="0 0 5 0" />

                        <TextBlock x:Name="txtStationName" Text="站点:111111111" FontSize="14px" FontWeight="Bold" VerticalAlignment="Center" />
                        <!--<TextBlock Text="[2024-10-23 10:25:39]" FontSize="13px"  VerticalAlignment="Center" Margin="2 0 0 0"/>-->
                    </StackPanel>
                    <StackPanel x:Name="pnlDetailFunc" Orientation="Horizontal" HorizontalAlignment="Right">
                        <TextBlock Text="筛选条件" VerticalAlignment="Center" Margin="0 0 5 0" 
                                   Foreground="Black" FontSize="14px" FontWeight="Normal"/>
                        <ComboBox Grid.Column="1" x:Name="cmbRunFlag" FontSize="13px" Foreground="#000000" 
                                      DisplayMemberPath="Value" SelectedValuePath="Key" Width="110"
                                      ItemsSource="{Binding PatchFindTypeKVs}"
                                      SelectedValue="{Binding SelectedPatchFindType,Mode=TwoWay}"                                        
                                      Margin="0,0,10,0" Padding="4" VerticalAlignment="Center"/>

                        <!--ItemsSource="{x:Static local:ConfigItem.RulerDigitList}"-->

                        <zdfflatui:FlatButton x:Name="btnStartTask" HorizontalAlignment="Right"
                                              Click="BtnStartTask_Click"
                                              Background="#2196F3" Content="开始批量任务" Foreground="White"
                                              Width="100" Height="28" FontSize="13" Margin="0 0 5 0" />

                        <zdfflatui:FlatButton Grid.Column="1" x:Name="btnResetTask" HorizontalAlignment="Center"
                                              Background="#FF4C4C" Content="恢复原始"
                                                Click="BtnResetTask_Click" Foreground="White"
                                              Width="80" Height="28" FontSize="13" Margin="0 0 5 0" />
                        
                        <zdfflatui:FlatButton Grid.Column="2" x:Name="btnRefreshDetail" HorizontalAlignment="Center"
                                              Background="#2196F3" Foreground="White" Content="🔄"
                                          ToolTip="刷新数据列表"
                                          Click="BtnRefreshDetail_Click" Margin="0 0 10 0"
                                          Width="30" Height="28" FontSize="20px"  />

                        <Button Content="▶️" x:Name="btnRightCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
                                Click="BtnRightCtl_Click"
                               Foreground="White" Background="#333333" Margin="0 0 5 0" />
                    </StackPanel>
                </Grid>

                <Border Grid.Row="1">
                    <local:UCPatchGrid x:Name="ucPatchGird" Padding="5 5 5 5" />
                </Border>
                <!-- 底部分页控件 -->
                <StackPanel Grid.Row="2" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
                    <!--<TextBlock Text="共 100 条数据" Margin="5" VerticalAlignment="Center" FontSize="13px"/>-->
                    <TextBlock Text="{Binding ElementName=ucPatchGird,Path=TotalRecords,StringFormat='共 {0} 条数据'}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
                    <ComboBox Width="55" Margin="5" FontSize="13px" 
                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
                              SelectedValue="{Binding mConfigItem.PageSize3}"/>
                    <Button x:Name="btnPatchDetailFirstPage" Content="首页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchDetailFirstPage_Click"/>
                    <Button x:Name="btnPatchDetailPrePage" Content="上一页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchDetailPrePage_Click"/>
                    <!--<TextBlock Text="第 2 页 / 共 10 页" Margin="5" FontSize="13px" VerticalAlignment="Center"/>-->
                    <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
                        <TextBlock.Text>
                            <MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">
                                <Binding ElementName="ucPatchGird" Path="PatchDetailPage.PageNumber"/>
                                <Binding ElementName="ucPatchGird" Path="PatchDetailPage.PageCount"/>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                    <Button x:Name="btnPatchDetailNextPage" Content="下一页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchDetailNextPage_Click"/>
                    <Button x:Name="btnPatchDetailLastPage" Content="尾页" Width="55" Margin="5" FontSize="13px" Click="BtnPatchDetailLastPage_Click"/>
                    <TextBox x:Name="txtPatchDetailPageNumber" Width="55" Margin="5" TextAlignment="Center" FontSize="13px"
                             Text="{Binding ElementName=ucPatchGird,Path=PatchDetailPage.PageNumber,Mode=OneWay}"
                             MaxLength="5" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
                    <Button x:Name="btnPatchDetailSpeciPage" Content="跳转" Width="55" Margin="5" FontSize="13px" Click="BtnPatchDetailSpeciPage_Click"/>
                </StackPanel>
            </Grid>                
        </Border>

        <Border Grid.Column="3" Background="White">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Border Grid.Row="0" BorderBrush="#D3D3D3" Background="WhiteSmoke" BorderThickness="0 0 0 0" Padding="0 2 0 2" Margin="2 0 2 0" >
                    <!--Text="{Binding SelectedSingleItemIndex,Mode=OneWay}"-->
                    <TextBlock Grid.Column="0" x:Name="txtRightItemIndex" Text="1." Margin="10 0 0 0"
                                   TextWrapping="Wrap" FontWeight="Bold" FontSize="14px" VerticalAlignment="Center" />
                </Border>

                <TabControl Grid.Row="1" Margin="5" BorderBrush="#D3D3D3" BorderThickness="1">
                    <TabItem Header="图片信息" FontSize="14px" Margin="0" Padding="10 5 10 5">
                        <Grid x:Name="pnlImage">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0.45*"/>
                                <RowDefinition Height="0.55*"/>
                            </Grid.RowDefinitions>

                            <Border Grid.Row="0" BorderThickness="1" BorderBrush="Transparent" >
                                <img:UCImage x:Name="ucImagerSource" />
                            </Border>
                            <Border Grid.Row="1" BorderThickness="1" BorderBrush="Transparent" >
                                <img:UCImage x:Name="ucImageResult"/>
                            </Border>
                        </Grid>
                    </TabItem>

                    <TabItem Header="运行日志" FontSize="14px" Margin="0" Padding="10 5 10 5">
                        <Grid x:Name="pnlLog">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Border Grid.Row="0">
                                <RichTextBox x:Name="LogRichTextBox" BorderThickness="0" VerticalScrollBarVisibility="Auto" 
                                 HorizontalScrollBarVisibility="Auto" IsReadOnly="True" VerticalAlignment="Stretch"
                                 Margin="5 5 5 0" FontSize="14px" />
                            </Border>

                            <StackPanel x:Name="pnlImageCtl" Grid.Row="1" Orientation="Horizontal" Background="#666666" Margin="5" HorizontalAlignment="Center">
                                <Button Content="↑" FontSize="20px" Width="30" Height="30" Click="LogScrollTop_Click" Margin="20 5 20 5" Padding="0" Foreground="White" Background="#333333" />
                                <Button Content="↓" FontSize="20px" Width="30" Height="30" Click="LogScrollBottom_Click" Margin="0 5 20 5" Padding="0" Foreground="White" Background="#333333" />
                                <Button Content="📁" FontSize="20px" Width="30" Height="30" Click="AiLogSave_Click" Margin="0 5 20 5" Padding="0" Foreground="White" Background="#333333" />
                            </StackPanel>
                        </Grid>
                    </TabItem>
                </TabControl>
            </Grid>
        </Border>
    </Grid>
</UserControl>
