<UserControl x:Class="MeterVision.Single.UCSingleMain"
             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.Single"
             xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
             xmlns:img="clr-namespace:MeterVision.UC"
             xmlns:local2="clr-namespace:MeterVision"
             mc:Ignorable="d" 
             Background="WhiteSmoke"
             Padding="5 2 5 5"
             AllowDrop="False"
             d:DesignHeight="800" d:DesignWidth="1000">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="400" x:Name="colRight" />
        </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" />
                </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="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="请选择图片或拖拽图片到表格中进行识别" 
                                   TextWrapping="Wrap" FontWeight="Bold" FontSize="14px" VerticalAlignment="Center" />

                        <StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
                        <!--<Button x:Name="btnAddRo2w" Click="BtnAddRow_Click"
                            Width="80" Height="30" VerticalAlignment="Center" HorizontalAlignment="Center" Background="#009ACD"
                                 Content="添加一行" BorderThickness="1" BorderBrush="#D3D3D3" Foreground="White" FontSize="13"/>-->
                            <!--<zdfflatui:FlatButton x:Name="btnAddRow" Background="#2196F3" Foreground="White" Content="数据刷新" Click="BtnAddRow_Click" 
                                              Width="80" Height="28" FontSize="13" Margin="5 0 0 0" />-->
                            <zdfflatui:FlatButton Grid.Column="1" x:Name="btnClearAll" HorizontalAlignment="Center"
                                              Background="#FF4C4C" Content="清空数据"
                                                Click="BtnClearAll_Click" Foreground="White"
                                              Width="80" Height="28" FontSize="13" Margin="0 0 0 0" />
                            <zdfflatui:FlatButton x:Name="btnSelectImage" Background="#2196F3" Foreground="White" Content="选择图片识别" Click="BtnSelectImage_Click" 
                                              Width="100" Height="28" FontSize="13" Margin="10 0 0 0" />
                            <zdfflatui:FlatButton Grid.Column="2" x:Name="btnRefresh" HorizontalAlignment="Center"
                                              Background="#2196F3" Foreground="White" Content="🔄"
                                          ToolTip="刷新数据列表"
                                          Click="BtnRefresh_Click" Margin="10 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 0 0" />
                            
                        </StackPanel>
                    </Grid>
                </Border>
                
                
                
                <Border Grid.Row="1" Visibility="Visible">
                    <local:UCSingleGrid x:Name="ucSingleGrid" Margin="0" Padding="2"/>
                </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=ucSingleGrid,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=ucSingleGrid,Path=mConfigItem.SinglePageSize}"/>-->
                    <ComboBox Width="55" Margin="5" FontSize="13px" 
                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
                              SelectedValue="{Binding ElementName=ucSingleGrid,Path=mConfigItem.PageSize3}"/>
                    <Button x:Name="btnSingleDetailFirstPage" Content="首页" Width="55" Margin="5" FontSize="13px" Click="BtnSingleDetailFirstPage_Click"/>
                    <Button x:Name="btnSingleDetailPrePage" Content="上一页" Width="55" Margin="5" FontSize="13px" Click="BtnSingleDetailPrePage_Click"/>
                    <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
                        <TextBlock.Text>
                            <MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">
                                <Binding ElementName="ucSingleGrid" Path="SingleDetailPage.PageNumber"/>
                                <Binding ElementName="ucSingleGrid" Path="SingleDetailPage.PageCount"/>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>

                    <Button x:Name="btnSingleDetailNextPage" Content="下一页" Width="55" Margin="5" FontSize="13px" Click="BtnSingleDetailNextPage_Click"/>
                    <Button x:Name="btnSingleDetailLastPage" Content="尾页" Width="55" Margin="5" FontSize="13px" Click="BtnSingleDetailLastPage_Click"/>
                    <TextBox x:Name="txtSingleDetailPageNumber" Width="40" Margin="5" TextAlignment="Center" FontSize="13px"
                             Text="{Binding ElementName=ucSingleGrid,Path=SingleDetailPage.PageNumber,Mode=OneWay}"
                             MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
                    <Button x:Name="btnSingleDetailSpeciPage" Content="跳转" Width="55" Margin="5" FontSize="13px" Click="BtnSingleDetailSpeciPage_Click"/>
                </StackPanel>
            </Grid>
        </Border>

        <!--<Border Grid.Column="1" Background="WhiteSmoke">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="45" />
                </Grid.RowDefinitions>

                <Border Grid.Row="1">
                    <RichTextBox x:Name="LogRichTextBox2"
                     VerticalScrollBarVisibility="Auto"
                     HorizontalScrollBarVisibility="Disabled"
                     IsReadOnly="True"
                     VerticalAlignment="Stretch"
                     Margin="5 0 2 0"/>
                </Border>
                
            </Grid>
        </Border>-->


        <Border Grid.Column="1" 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" Background="White" >

                    <TabItem Header="图片信息" FontSize="14px" Margin="0" Padding="10 5 10 5" >
                        <!--ScrollViewer VerticalScrollBarVisibility="Auto">-->
                        <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>
                        <!--</ScrollViewer>-->
                    </TabItem>

                    <TabItem Visibility="Visible" 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="Disabled" 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="LogScrollMiddle_Click" Margin="0 5 10 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" />
                            </StackPanel>
                        </Grid>
                    </TabItem>
                </TabControl>
            
            </Grid>
        </Border>

    </Grid>
</UserControl>
