<UserControl
    x:Class="BPA.SingleDevice.View.RunLogView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:BPA.SingleDevice.View"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <bpa:DialogContainer>
        <Grid Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <!--#region 功能按钮-->
            <StackPanel
                Grid.Row="0"
                Margin="10"
                HorizontalAlignment="Right"
                bpa:PanelHelper.Spacing="15"
                Orientation="Horizontal">

                <StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked, Converter={StaticResource BooleanToVisibleConverter}}">
                    <TextBlock Margin="5,0" Text="开始日期：" />
                    <DatePicker
                        
                        bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
                        bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
                        bpa:InputBoxHelper.IsClearable="false"
                        bpa:InputBoxHelper.Watermark="请选择日期"
                        SelectedDate="{Binding StartTime}"
                        SelectedDateFormat="Short" />
                    <TextBlock Margin="5,0" Text="结束日期：" />
                    <DatePicker
                        
                        bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
                        bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
                        bpa:InputBoxHelper.IsClearable="False"
                        bpa:InputBoxHelper.Watermark="请选择日期"
                        SelectedDate="{Binding EndTime}" />

                    <Button
                        Margin="10,0"
                        Command="{Binding GetHistoryCommand}"
                        Content="查询历史日志" />
                </StackPanel>
                <ToggleButton
                    x:Name="IsShowHistory"
                    HorizontalAlignment="Right"
                    bpa:ToggleButtonHelper.CheckedContent="历史日志"
                    Command="{Binding SwitchLogModeCommand}"
                    Content="实时日志"
                    FontSize="40"
                    Style="{DynamicResource SwitchToggleButton}" />
            </StackPanel>

            <!--#endregion-->

            <!--#region 列表-->
            <bpa:ControlDisplay Grid.Row="1">
                <DataGrid
                    Style="{StaticResource DataGridLargeScrollStyle}"
                    Grid.Row="1"
                    AutoGenerateColumns="False"
                    BorderBrush="Gray"
                    BorderThickness="1"
                    CanUserAddRows="False"
                    CanUserDeleteRows="False"
                    CanUserReorderColumns="False"
                    CanUserResizeColumns="False"
                    CanUserResizeRows="False"
                    CanUserSortColumns="False"
                    GridLinesVisibility="All"
                    IsReadOnly="True"
                    ItemsSource="{Binding Logs}"
                    RowHeight="50"
                    SelectionMode="Single">
                    <DataGrid.Columns>
                        <DataGridTextColumn
                            Width="150"
                            Binding="{Binding Date}"
                            FontSize="22"
                            Header="日期" />
                        <DataGridTextColumn
                            Width="150"
                            Binding="{Binding Time}"
                            FontSize="22"
                            Header="时间" />
                        <DataGridTextColumn
                            Width="*"
                            Binding="{Binding RunLogInfo}"
                            FontSize="22"
                            Header="日志信息" />
                    </DataGrid.Columns>
                </DataGrid>
            </bpa:ControlDisplay>
            <!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
            <!--#endregion-->
        </Grid>
    </bpa:DialogContainer>
</UserControl>