<UserControl x:Class="ConeCalorimeter.Views.RealtimeDataView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="RealtimeHeaderCellStyle" TargetType="DataGridColumnHeader">
            <Setter Property="Height" Value="46" />
            <Setter Property="Padding" Value="4,0" />
            <Setter Property="Background" Value="#FFFFFF" />
            <Setter Property="BorderBrush" Value="#C8D0CC" />
            <Setter Property="BorderThickness" Value="0,0,1,1" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="Foreground" Value="#111111" />
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"
                                   TextAlignment="Center"
                                   TextWrapping="Wrap"
                                   LineHeight="16"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="RealtimeCellStyle" TargetType="DataGridCell">
            <Setter Property="Padding" Value="2,0" />
            <Setter Property="Background" Value="#FFFFFF" />
            <Setter Property="BorderBrush" Value="#E1E5E3" />
            <Setter Property="BorderThickness" Value="0,0,1,1" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="FontFamily" Value="Consolas" />
            <Setter Property="FontSize" Value="15" />
            <Setter Property="Foreground" Value="#111111" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="DataGridCell">
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter HorizontalAlignment="Center"
                                              VerticalAlignment="Center" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="RealtimeTextElementStyle" TargetType="TextBlock">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="TextWrapping" Value="NoWrap" />
        </Style>
    </UserControl.Resources>

    <Grid Background="#FFFFFF">
        <Border Margin="2"
                Background="#FFFFFF"
                BorderBrush="#D6DCD9"
                BorderThickness="1"
                CornerRadius="6">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="62" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Border Grid.Row="0"
                        Background="#FFFFFF"
                        BorderBrush="#CFCFCF"
                        BorderThickness="0,0,0,1">
                    <Grid Margin="10,0,12,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="226" />
                        </Grid.ColumnDefinitions>

                        <Button Content="关闭"
                                Command="{Binding CloseCommand}"
                                Style="{StaticResource InstrumentButtonStyle}"
                                Width="100"
                                Height="44"
                                FontSize="22"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center" />

                        <StackPanel Grid.Column="2"
                                    Orientation="Horizontal"
                                    HorizontalAlignment="Right"
                                    VerticalAlignment="Center">
                            <Button Content="清除"
                                    Command="{Binding ClearCommand}"
                                    Style="{StaticResource InstrumentButtonStyle}"
                                    Width="100"
                                    Height="44"
                                    FontSize="22"
                                    Margin="0,0,12,0" />
                            <Button Content="导出"
                                    Command="{Binding ExportCommand}"
                                    Style="{StaticResource InstrumentButtonStyle}"
                                    Width="100"
                                    Height="44"
                                    FontSize="22" />
                        </StackPanel>
                    </Grid>
                </Border>

                <DataGrid x:Name="RealtimeDataGrid"
                          Grid.Row="1"
                          ItemsSource="{Binding Rows}"
                          AutoGenerateColumns="False"
                          CanUserAddRows="False"
                          CanUserDeleteRows="False"
                          CanUserReorderColumns="False"
                          CanUserResizeRows="False"
                          GridLinesVisibility="None"
                          HeadersVisibility="Column"
                          Background="#FFFFFF"
                          RowBackground="#FFFFFF"
                          AlternatingRowBackground="#FFFFFF"
                          BorderBrush="#C8D0CC"
                          BorderThickness="0,1,0,0"
                          ColumnHeaderStyle="{StaticResource RealtimeHeaderCellStyle}"
                          CellStyle="{StaticResource RealtimeCellStyle}"
                          HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Auto"
                          RowHeight="26"
                          IsReadOnly="True">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Time(s)" Binding="{Binding TimeText}" Width="82" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="O2 (%)" Binding="{Binding OxygenText}" Width="82" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="CO2 (%)" Binding="{Binding CarbonDioxideText}" Width="88" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="CO (%)" Binding="{Binding CarbonMonoxideText}" Width="82" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="吸光率%" Binding="{Binding AbsorbanceText}" Width="88" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="孔板压差 (Pa)" Binding="{Binding OrificePressureText}" Width="116" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="孔板温度 (K)" Binding="{Binding OrificeTemperatureText}" Width="116" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="HRR" Binding="{Binding Hrr50Text}" Width="78" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="THR (MJ/m2)" Binding="{Binding ThrText}" Width="108" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="SPR" Binding="{Binding Spr50Text}" Width="78" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="TSR (m2)" Binding="{Binding TsrText}" Width="88" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="MLR (g/s)" Binding="{Binding MlrText}" Width="92" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="热释放KW/m2" Binding="{Binding HeatReleaseText}" Width="122" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="EHC" Binding="{Binding EhcText}" Width="70" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                        <DataGridTextColumn Header="损失质量" Binding="{Binding MassLossText}" Width="84" ElementStyle="{StaticResource RealtimeTextElementStyle}" />
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </Border>
    </Grid>
</UserControl>
