<UserControl x:Class="BPASmartClient.Control.LogView"
             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:k="clr-namespace:BPASmartClient.Model;assembly=BPASmartClient.Model"
             xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
             xmlns:local="clr-namespace:BPASmartClient.Control"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <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 Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="45"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <!--查询按钮栏-->
        <StackPanel Orientation="Horizontal" Margin="10,0,10,0">
            <ComboBox Width="100" Text="{Binding SelectedText}"  IsEditable="True" ItemsSource="{Binding Path=BookExs}">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type k:BookEx}">
                        <CheckBox Width="95" IsChecked="{Binding IsChecked}"  Content="{Binding BookN.Name}" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Button  Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}"  >导出日志</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>
