﻿<hb:PluginControl x:Class="Plugin.TestResult_WPF.ViewControl"
             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:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
xmlns:pw="https://opensource.panuon.com/wpf"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
             mc:Ignorable="d" 
             Loaded="UserControl_Loaded"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <local:FontSizeConverter x:Key="FontSizeConverter"/>
        <Style TargetType="GroupBox">
            <Setter Property="FontSize" Value="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType=UserControl}, 
Converter={StaticResource FontSizeConverter}, ConverterParameter='20,1920'}" />
        </Style>

        <Style TargetType="Button">
            <Setter Property="Margin" Value="0,10"/>
            <Setter Property="Padding" Value="5"/>
        </Style>

        <Style TargetType="Label">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="LightGray"/>
            <Setter Property="Margin" Value="0,10"/>
            <Setter Property="Padding" Value="5"/>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="7.5*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <local:TestResultView x:Name="testResultView" Grid.Column="0" Loaded="testResultView_Loaded" />
        <StackPanel Grid.Column="1" Background="#FFF">
            <GroupBox Header="产品信息">
                <ComboBox x:Name="modelSelect" Style="{StaticResource FormComboxStyle}"
                          SelectionChanged="modelSelect_SelectionChanged"></ComboBox>
            </GroupBox>
            <GroupBox Header="生产统计">
                <StackPanel>
                    <Label HorizontalContentAlignment="Center" HorizontalAlignment="Stretch">
                        <Label.Style>
                            <Style TargetType="Label">
                                <Setter Property="HorizontalContentAlignment"  Value="Center"/>
                                <Setter Property="HorizontalAlignment"  Value="Stretch"/>
                                <Setter Property="Margin" Value="0,10"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding mesStatus}" Value="true">
                                        <Setter Property="Background" Value="Green"/>
                                        <Setter Property="Content" Value="MES开"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding mesStatus}" Value="false">
                                        <Setter Property="Background" Value="Red"/>
                                        <Setter Property="Content" Value="MES关"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Label.Style>
                    </Label>
                    <Label>
                        <Label.Style>
                            <Style TargetType="Label">
                                <Setter Property="HorizontalContentAlignment"  Value="Center"/>
                                <Setter Property="HorizontalAlignment"  Value="Stretch"/>
                                <Setter Property="Content" Value="{Binding produceStatus}"/>
                                <Setter Property="Margin" Value="0,10"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding produceStatus}" Value="INIT">
                                        <Setter Property="Background" Value="Gray"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding produceStatus}" Value="STOP">
                                        <Setter Property="Background" Value="Red"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding produceStatus}" Value="RUNNING">
                                        <Setter Property="Background" Value="Green"/>
                                        <Setter Property="Foreground" Value="White"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Label.Style>
                    </Label>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="操作">
                <StackPanel dp:StackPanelHelper.ChildSpace="20">
                    <Button x:Name="btnStart" Click="Start_Click" Style="{StaticResource SuccessButton}">
                        <Button.Content>启动</Button.Content>
                    </Button>

                    <Button x:Name="btnStop" Click="Stop_Click" Style="{StaticResource DangerButton}">
                        <Button.Content>停止</Button.Content>
                    </Button>

                    <Button x:Name="btnScan1" Click="Scan_Click_1" Style="{StaticResource PrimaryButton}">
                        <Button.Content>一区扫码</Button.Content>
                    </Button>

                    <Button x:Name="btnScan2" Click="Scan_Click_2" Style="{StaticResource PrimaryButton}">
                        <Button.Content>二区扫码</Button.Content>
                    </Button>
                    <!-- <Button Content="计数清零"/>
                    <Button Content="扫码"/>
                    <Button Content="一区手动"/>
                    <Button Content="二区手动"/>-->
                </StackPanel>
            </GroupBox>
        </StackPanel>
    </Grid>
</hb:PluginControl>
