<UserControl
    x:Class="BPASmartClient.Control.LogOrAlarmView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:BPASmartClient.Control"
    xmlns:k="clr-namespace:BPASmartClient.Model;assembly=BPASmartClient.Model"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
                <ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <!--  底部窗体栏  -->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="45" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--  查询按钮栏  -->
        <StackPanel Margin="10,0,10,0" Orientation="Horizontal">
            <ComboBox Width="120" Text="{Binding SelectedText}"  IsEditable="True" ItemsSource="{Binding Path=BookExs}">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type k:BookEx}">
                        <CheckBox Width="110" IsChecked="{Binding IsChecked}"  Content="{Binding BookN.Name}" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <DatePicker  Margin="10,0,10,0"  Text="{Binding DateTimeStr,Mode=TwoWay,NotifyOnTargetUpdated=True}"></DatePicker>
            <Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding QueryCommand}" >查询数据</Button>
            <Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding OpenCommand}" >打开文件目录</Button>
        </StackPanel>

        <!--  表格栏  -->
        <Grid Grid.Row="1">
            <DataGrid  Margin="10"  ItemsSource="{Binding LogDataGrid, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2">
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="日志时间" Width="300">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Center" Text="{Binding time, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <!--<DataGridTemplateColumn Header="设备ID" Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Center" Text="{Binding deviceId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>-->

                    <DataGridTemplateColumn Header="日志类型" Width="300">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14"  Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="日志内容" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left" Text="{Binding message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14"  Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>

        </Grid>
    </Grid>
</UserControl>
