<UserControl x:Class="BOB.Views.DataView"
             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:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vs="clr-namespace:BOB.Views"
             xmlns:oxy="http://oxyplot.org/wpf"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             d:DesignHeight="1080"
             d:DesignWidth="1920">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <DataGrid ItemsSource="{Binding CurrentDataSource}"
                  AutoGenerateColumns="True"
                  Margin="20,20,0,0" />
        <GroupBox Header="数据处理"
                  Grid.Row="1"
                  Margin="5"
                  Padding="0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                    
                    <StackPanel Orientation="Horizontal"
                                HorizontalAlignment="Left"
                                Margin="5">
                        <ComboBox ItemsSource="{Binding DataTableList}"
                                  SelectedItem="{Binding SelectTable, Mode=TwoWay}"
                              MinWidth="150"
                              materialDesign:HintAssist.Hint=""
                              Margin="15,0,15,0" />
                        <Button Content="选择数据表"
                                Command="{Binding SelectTableCommand}"
                                Margin="15,0,15,0" />
                        <!-- 查询输入框 -->
                        <!--<TextBox x:Name="QueryTextBox"
                                 Width="200"
                                 Margin="0,0,10,0" />
                        --><!-- 查询按钮 --><!--
                        <Button Content="查询"
                                Command="{Binding QueryCommand}"
                                CommandParameter="{Binding Text, ElementName=QueryTextBox}"
                                Margin="10,0,20,0" />-->
                    </StackPanel>

                    <!-- 右侧内容: 日期选择器 -->
                    <StackPanel Orientation="Horizontal"
                                Grid.Column="2"
                                Margin="5">
                        <TextBlock VerticalAlignment="Center"
                                   Margin="15,0,15,0"
                                   Text="起始日期:" />
                    <DatePicker materialDesign:HintAssist.Hint="起始日期"
                                materialDesign:TextFieldAssist.HasClearButton="True"
                                Style="{StaticResource MaterialDesignFloatingHintDatePicker}"
                                Width="120"
                                
                                    Margin="0,0,10,0"
                                    SelectedDate="{Binding StartDate, Mode=TwoWay}" />
                    <TextBlock VerticalAlignment="Center"
                               materialDesign:HintAssist.Hint=""
                               Margin="15,0,15,0"
                                   Text="结束日期:" />
                    <DatePicker materialDesign:HintAssist.Hint="结束日期"
                                materialDesign:TextFieldAssist.HasClearButton="True"
                                Style="{StaticResource MaterialDesignFloatingHintDatePicker}"
                                Width="120"
                                    Margin="0,0,10,0"
                                    SelectedDate="{Binding EndDate, Mode=TwoWay}" />
                        <!-- 查询按钮 -->
                        <Button Content="查询"
                                Command="{Binding QueryCommand}"
                                Margin="10,0,0,0" />
                        <Button Content="刷新数据"
                                Command="{Binding RefreshCommand}"
                                Margin="15,0,15,0" />
                    </StackPanel>

                    <!-- 分页控件 -->
                    <StackPanel Grid.Row="1"
                            Grid.Column="1"
                            Orientation="Horizontal"
                            HorizontalAlignment="Center"
                            Margin="5">
                    <Button Content="第一页"
                            Command="{Binding FirstPageCommand}"
                            Margin="10,0,10,0" />
                    <Button Content="上一页"
                            Command="{Binding PreviousPageCommand}"
                            Margin="10,0,10,0" />

                    <TextBlock VerticalAlignment="Center"
                               Margin="10 10 0 10"
                               Text="{Binding CurrentPage}"
                               materialDesign:HintAssist.Hint="" />
                    <TextBlock Text="/"
                               Margin="0 10"
                               materialDesign:HintAssist.Hint="" />
                    <TextBlock Text="{Binding UITotalPages}"
                               materialDesign:HintAssist.Hint=""
                               Margin="0 10" />

                    <Button Content="下一页"
                            Command="{Binding NextPageCommand}"
                            Margin="10,0,10,0" />
                    <Button Content="最后一页"
                            Command="{Binding LastPageCommand}"
                            Margin="10,0,15,0" />
                </StackPanel>
            </Grid>
        </GroupBox>
    </Grid>
</UserControl>
