<UserControl
    x:Class="SicUI.Models.PMs.PMMfcRorView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.caliburn.org"
    xmlns:cvt="clr-namespace:Aitex.Core.UI.Converters;assembly=MECF.Framework.UI.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    xmlns:local="clr-namespace:SicUI.Models.PMs"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
    d:DesignHeight="800"
    d:DesignWidth="2200"
    lex:LocalizeDictionary.DesignCulture="."
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
    mc:Ignorable="d">
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="FontSize" Value="15" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="Margin" Value="3" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>


        <Style TargetType="Border">
            <Setter Property="Background" Value="#FFD0DEEB" />
            <Setter Property="BorderBrush" Value="Gray" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="BorderThickness" Value="1,0,1,1" />
        </Style>

        <Style x:Key="InfBorder" TargetType="Border">
            <Setter Property="Background" Value="White" />
            <Setter Property="BorderBrush" Value="Gray" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="BorderThickness" Value="0,0,1,1" />

        </Style>

        <Style TargetType="TextBox">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="15" />
            <Setter Property="Margin" Value="3" />
        </Style>

        <Style TargetType="DataGridCell">
            <Setter Property="TextBlock.TextAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <cvt:ColorConverter_IsTestOK x:Key="ColorConverter_IsTestOK" />

    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="370" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="310" />
            <RowDefinition Height="210" />
            <RowDefinition Height="80" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel
            Width="350"
            Margin="5"
            HorizontalAlignment="Left"
            Orientation="Vertical">
            <Border
                Grid.Row="0"
                Height="30"
                Background="#FF243664"
                BorderThickness="0"
                CornerRadius="8,8,0,0">
                <TextBlock
                    Padding="8,0,0,0"
                    HorizontalAlignment="Center"
                    FontSize="13"
                    Foreground="White"
                    Text="{lex:Loc ID_TXT_Standard_MFC}" />
            </Border>

            <StackPanel Orientation="Horizontal">
                <StackPanel Width="230" HorizontalAlignment="Left">
                    <Border BorderThickness="1,0,1,1">
                        <TextBlock Text="{lex:Loc ID_TXT_Standard_MFC}" />
                    </Border>
                    <Border BorderThickness="1,0,1,1">
                        <TextBlock Text="{lex:Loc ID_TXT_Differential_Pressure}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure1}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure2}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure3}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure4}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Mean_Pressure_Difference}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_MFC_Actual_Flow}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_MFC_Set_Flow}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Reactor_Volume}" />
                    </Border>

                </StackPanel>
                <StackPanel Width="120" HorizontalAlignment="Left">
                    <Border Background="#FFD6D6D6" BorderThickness="0,0,1,1">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Name, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" BorderThickness="0,0,1,1">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.MaintainPressureDifference, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Pressure1, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Pressure2, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Pressure3, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Pressure4, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.MeanDifferencePressure, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.ActualFlow, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.SetFlow, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Text="{Binding StandardMfcRorData.Volume, StringFormat=0.00}"
                            TextAlignment="Center" />
                    </Border>
                </StackPanel>
            </StackPanel>

        </StackPanel>

        <StackPanel
            Grid.Row="1"
            Width="350"
            Margin="5"
            HorizontalAlignment="Left"
            Orientation="Vertical">

            <Border
                Height="30"
                Background="#FF243664"
                BorderThickness="0"
                CornerRadius="8,8,0,0">
                <TextBlock
                    Padding="8,0,0,0"
                    HorizontalAlignment="Center"
                    FontSize="13"
                    Foreground="White"
                    Text="Set" />
            </Border>

            <StackPanel Orientation="Horizontal">
                <StackPanel Width="230" HorizontalAlignment="Left">
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Reactor_Temp}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure_Recording_Interval}" />
                    </Border>
                    <!--<Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Set_Flow}" />
                    </Border>-->
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Pressure}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_Set_Standard_MFC}" />
                    </Border>
                    <Border>
                        <TextBlock Text="{lex:Loc ID_TXT_MFC_Range}" />
                    </Border>
                </StackPanel>
                <StackPanel Width="120">
                    <Border Style="{StaticResource InfBorder}">
                        <TextBox Text="{Binding SelectedMfcRorData.Temperature, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </Border>
                    <Border Style="{StaticResource InfBorder}">
                        <TextBox Text="{Binding SelectedMfcRorData.Interval, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </Border>
                    <!--<Border Style="{StaticResource InfBorder}">
                        <TextBox Text="{Binding SelectedMfcRorData.SetFlow, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </Border>-->
                    <Border Style="{StaticResource InfBorder}">
                        <TextBox Text="{Binding SelectedMfcRorData.BasePressure, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </Border>
                    <Border>
                        <CheckBox
                            Margin="5"
                            VerticalContentAlignment="Center"
                            IsChecked="{Binding SelectedMfcRorData.IsStandardMfc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </Border>
                    <Border Background="#FFD6D6D6" Style="{StaticResource InfBorder}">
                        <TextBlock Text="{Binding SelectedMfcRorData.Scale}" />
                    </Border>

                </StackPanel>

            </StackPanel>
            <StackPanel Height="20" />

        </StackPanel>

        <StackPanel
            Grid.Row="2"
            Margin="5"
            Orientation="Vertical">
            <Border
                Width="350"
                Margin="0,0,0,10"
                HorizontalAlignment="Left"
                lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                BorderThickness="0"
                CornerRadius="8,8,0,0">
                <StackPanel Orientation="Vertical">
                    <Border
                        Background="#FF243664"
                        BorderThickness="0"
                        CornerRadius="8,8,0,0">
                        <TextBlock
                            HorizontalAlignment="Center"
                            FontSize="13"
                            Foreground="White"
                            Text="{lex:Loc ID_BTN_Set_Content}" />
                    </Border>
                    <StackPanel Grid.Row="1" Orientation="Horizontal">
                        <toolkit:CheckComboBox
                            Width="170"
                            Height="25"
                            Margin="26,0,0,0"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            FontFamily="Arial"
                            FontSize="14"
                            ItemsSource="{Binding MfcNameList}"
                            SelectedValue="{Binding SelectedMfcRorArray}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="ItemSelectionChanged">
                                    <cal:ActionMessage MethodName="MfcSelectionChanged" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </toolkit:CheckComboBox>
                        <!--<ComboBox
                            Width="160"
                            Height="30"
                            Margin="10,5,0,5"
                            FontSize="15"
                            ItemsSource="{Binding MfcNameList}"
                            SelectedItem="{Binding SelectedMfcRorData.Name}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="SelectionChanged">
                                    <cal:ActionMessage MethodName="MfcSelectionChanged" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </ComboBox>-->

                        <Button
                            Width="80"
                            Height="30"
                            Margin="35,5,0,5"
                            Content="{lex:Loc ID_BTN_Start_Content}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="StartMfcRor" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>

                    </StackPanel>

                </StackPanel>
            </Border>
        </StackPanel>

        <StackPanel
            Grid.Row="3"
            Margin="5"
            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
            Orientation="Vertical">
            <Border
                Width="350"
                Margin="0,10,0,0"
                HorizontalAlignment="Left"
                BorderThickness="1,0,1,1"
                CornerRadius="8,8,0,0">
                <StackPanel Width="302" Orientation="Horizontal">
                    <StackPanel Margin="0,15">
                        <StackPanel Height="40" Orientation="Horizontal">
                            <TextBlock Width="75" Text="{lex:Loc ID_TXT_StartTime}" />
                            <WindowsFormsHost
                                Width="170"
                                Height="22"
                                Margin="20,0,0,0"
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="14">
                                <forms:DateTimePicker
                                    x:Name="wfTimeFrom"
                                    CustomFormat="yyyy/MM/dd HH:mm:ss"
                                    Format="Custom"
                                    Value="2023-1-1" />
                            </WindowsFormsHost>
                        </StackPanel>
                        <StackPanel
                            Height="40"
                            Margin="0,5,0,0"
                            Orientation="Horizontal">
                            <TextBlock Width="75" Text="{lex:Loc ID_TXT_EndTime}" />
                            <WindowsFormsHost
                                Width="170"
                                Height="22"
                                Margin="20,0,0,0"
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="14">
                                <forms:DateTimePicker
                                    x:Name="wfTimeTo"
                                    CustomFormat="yyyy/MM/dd HH:mm:ss"
                                    Format="Custom"
                                    Value="2023-1-1" />
                            </WindowsFormsHost>
                        </StackPanel>

                        <StackPanel
                            Margin="5"
                            HorizontalAlignment="Center"
                            Orientation="Horizontal">
                            <Button
                                Width="100"
                                Height="30"
                                Margin="5,0,5,0"
                                HorizontalAlignment="Center"
                                Content="{lex:Loc ID_BTN_Query_Content}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="QueryData" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </StackPanel>

                    </StackPanel>
                </StackPanel>
            </Border>
        </StackPanel>

        <DataGrid
            Grid.RowSpan="2"
            Grid.Column="1"
            Width="1660"
            Margin="5"
            HorizontalAlignment="Left"
            AlternationCount="2"
            AutoGenerateColumns="False"
            CanUserAddRows="False"
            ItemsSource="{Binding DataGridMfcRorList}"
            LoadingRow="DataGrid_LoadingRow"
            ScrollViewer.CanContentScroll="True">
            <DataGrid.Columns>
                <DataGridTextColumn
                    Width="50"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Binding="{Binding Path=Header, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}}"
                    Header="#" />

                <DataGridTextColumn
                    Width="100"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Binding="{Binding Name}"
                    Header="{lex:Loc ID_TXT_Name}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="130"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Binding="{Binding StartTime, StringFormat='yyyy-MM-dd HH:mm:ss'}"
                    Header="{lex:Loc ID_TXT_StartTime}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="130"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Binding="{Binding EndTime, StringFormat='yyyy-MM-dd HH:mm:ss'}"
                    Header="{lex:Loc ID_TXT_EndTime}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="125"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding Pressure1, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_Pressure1}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="125"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding Pressure2, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_Pressure2}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="125"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding Pressure3, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_Pressure3}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="125"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding Pressure4, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_Pressure4}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="180"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding MeanDifferencePressure, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_Mean_Pressure_Difference}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="150"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding ActualFlow, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_MFC_Actual_Flow}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="150"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding SetFlow, StringFormat=0.00}"
                    Header="{lex:Loc ID_TXT_MFC_Set_Flow}"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="150"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Binding="{Binding Deviation, StringFormat={}{0:F2}%}"
                    Header="{lex:Loc ID_TXT_Differential_Pressure}"
                    IsReadOnly="True">
                    <DataGridTextColumn.CellStyle>
                        <Style TargetType="DataGridCell">
                            <Setter Property="TextBlock.TextAlignment" Value="Center" />
                            <Setter Property="VerticalAlignment" Value="Center" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Result}" Value="OK">
                                    <Setter Property="Background" Value="LightGreen" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Result}" Value="NG">
                                    <Setter Property="Background" Value="LightCoral" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </DataGridTextColumn.CellStyle>
                </DataGridTextColumn>

                <DataGridTemplateColumn
                    Width="120"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
                    Header="{lex:Loc ID_TXT_Standard_MFC}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                HorizontalAlignment="Center"
                                IsChecked="{Binding IsStandardMfc}"
                                IsEnabled="False" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>



        </DataGrid>

        <StackPanel Grid.Row="2" Grid.Column="2">
            <Border
                Margin="3"
                BorderBrush="Gray"
                BorderThickness="0,0,0,3">
                <Label
                    Content="{lex:Loc ID_TXT_ROR_Test_Result}"
                    FontSize="15"
                    FontWeight="Black" />
            </Border>

            <Button
                Width="70"
                Height="30"
                Margin="3"
                HorizontalAlignment="Left"
                lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                Content="{lex:Loc ID_BTN_Clear_Content}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cal:ActionMessage MethodName="ClearMfcRorData" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </StackPanel>

        <StackPanel Grid.Row="3" Grid.Column="2">
            <ItemsControl ItemsSource="{Binding MfcRorList}">
                <!--  指定子项目容器为WrapPanel控件  -->
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <!--  指定子项目模板  -->
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border
                            Margin="3"
                            BorderBrush="Gray"
                            BorderThickness="1">
                            <StackPanel Height="32" Orientation="Horizontal">
                                <Border
                                    Width="14"
                                    Height="14"
                                    Margin="10,0,2,0"
                                    VerticalAlignment="Center"
                                    Background="{Binding Result, Converter={StaticResource ColorConverter_IsTestOK}}"
                                    CornerRadius="7" />
                                <Label
                                    Width="50"
                                    Margin="0,0,0,0"
                                    VerticalAlignment="Center"
                                    Content="{Binding Name}"
                                    Foreground="{Binding Result, Converter={StaticResource ColorConverter_IsTestOK}}" />
                                <TextBlock
                                    Width="50"
                                    Margin="0,0,0,0"
                                    VerticalAlignment="Center"
                                    Foreground="{Binding Result, Converter={StaticResource ColorConverter_IsTestOK}}"
                                    Text="{Binding Deviation, StringFormat={}{0:F2}%}" />
                            </StackPanel>
                        </Border>

                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>

    </Grid>
</UserControl>
