﻿<UserControl x:Class="Plugin.TestResult_WPF.DataTable"
             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:Plugin.TestResult_WPF"
            xmlns:hb="clr-namespace:HMI.Base;assembly=HMI.Base"
xmlns:uic="clr-namespace:HMI.UI.Converter;assembly=HMI.UI"
xmlns:pw="https://opensource.panuon.com/wpf"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
             mc:Ignorable="d"
             Background="#FFF"
             BorderBrush="Black"
             BorderThickness="1"
             x:Name="control"
             Loaded="UserControl_Loaded"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <local:FontSizeConverter x:Key="FontSizeConverter"/>
    </UserControl.Resources>
    <Grid x:Name="grid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="8.5*"/>
            <RowDefinition Height="1.5*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid x:Name="infoGrid" Grid.Row="0" Background="LightBlue">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock FontSize="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=UserControl}, 
Converter={StaticResource FontSizeConverter}, ConverterParameter='30,940'}"
                   FontWeight="Bold"
                   Margin="0"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center" Background="Transparent" Text="{Binding title}"/>

            <ComboBox Grid.Row="1" FontSize="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=UserControl}, 
Converter={StaticResource FontSizeConverter}, ConverterParameter='15,940'}"
                      Style="{StaticResource FormComboxStyle}"
                      pu:ComboBoxHelper.ClearButtonVisibility="Collapsed"
                      BorderBrush="Black"
                      BorderThickness="0,1,0,0"
                      pu:ComboBoxHelper.Watermark="{DynamicResource Tr.ProductInfo}"
                      Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=UserControl}, 
Converter={StaticResource FontSizeConverter}, ConverterParameter='150,940'}"
                      SelectedValuePath="Content"
                      x:Name="CbProduct" SelectionChanged="CbProduct_SelectionChanged"/>

            <local:InfoTable x:Name="infoTable" Grid.Row="0" Grid.Column="1"
                             Grid.RowSpan="2"
               FontSize="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=UserControl}, 
            Converter={StaticResource FontSizeConverter}, ConverterParameter='15,940'}"></local:InfoTable>
        </Grid>

        <UniformGrid x:Name="mainGrid" Grid.Row="1" Columns="6" dp:UniformGridHelper.InnerBorder="1"
                     dp:UniformGridHelper.InnerBorderIgnore="Left,Right,Bottom">
        </UniformGrid>

        <!--<local:Chart Grid.Row="2" x:Name="chart" BorderThickness="0,1,0,1" BorderBrush="Black" 
                      MouseDoubleClick="chart_MouseDoubleClick"/>-->

        <StatusBar Grid.Row="3">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <DockPanel/>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem DockPanel.Dock="Right">
                <StackPanel Orientation="Horizontal">
                    <Ellipse Width="10" Height="10">
                        <Ellipse.Style>
                            <Style TargetType="Ellipse">
                                <Setter Property="Fill" Value="Gray"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding TcpServerStatus,ElementName=control}" Value="ERROR">
                                        <Setter Property="Fill" Value="Red"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding TcpServerStatus,ElementName=control}" Value="RUNNING">
                                        <Setter Property="Fill" Value="Green"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Ellipse.Style>
                    </Ellipse>
                    <TextBlock Text="{Binding TcpServerInfo}"/>
                    <Button Padding="0" Margin="0" BorderThickness="0" Click="Button_Click">🔄</Button>
                </StackPanel>
            </StatusBarItem>

            <StatusBarItem >
                <TextBox IsReadOnly="True" Background="Transparent" BorderThickness="0" Text="{Binding statusText}"/>
            </StatusBarItem>
        </StatusBar>

        <Grid Grid.Row="4" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Click="ScanWindow_Click" Style="{StaticResource PrimaryButton}"
        Content="{DynamicResource Tr.Scan}"/>
            <Button Grid.Column="1" Click="SetStationGlobal_Click" Style="{StaticResource SuccessButton}"
        Content="{DynamicResource App.Start}"/>
        </Grid>
        
    </Grid>
</UserControl>