<UserControl x:Class="SlnMesnac.WPF.Page.TaskHistoryControl"
             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:local="clr-namespace:SlnMesnac.WPF.Page"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d"
             xmlns:cvt="clr-namespace:SlnMesnac.WPF.Converter.Generate"
             xmlns:cvt2="clr-namespace:SlnMesnac.WPF.Converter.Index"
              d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" Opacity="1">
    <UserControl.Resources>
        <cvt:RowToIndexConverter x:Key="RowToIndexConverter" />
        <cvt2:WcsTaskStatusConvert x:Key="WcsTaskStatusConvert" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1.5*" />
            <RowDefinition Height="6*" />
        </Grid.RowDefinitions>
        <Grid  Grid.Row="0" Margin="0 0 0 10">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="3*" />
            </Grid.ColumnDefinitions>

            <!--<ComboBox  Background="Green" Foreground="White" Grid.Row="0" Grid.Column="0" materialDesign:HintAssist.Hint="请选择Agv" Height="50" Width="180" FontSize="20" Margin="10" materialDesign:TextFieldAssist.HasClearButton="True">
                <ComboBoxItem Content="AGV01" />
                <ComboBoxItem Content="AGV02" />
                <ComboBoxItem Content="AGV03" />
            </ComboBox>
            <ComboBox  Background="#009999" Grid.Row="0" Grid.Column="1" materialDesign:HintAssist.Hint="请选择任务类型" Height="50" Width="200" FontSize="20" Margin="10" materialDesign:TextFieldAssist.HasClearButton="True">
                <ComboBoxItem Content="Android" />
                <ComboBoxItem Content="iOS" />
                <ComboBoxItem Content="Linux" />
                <ComboBoxItem Content="Windows" />
            </ComboBox>-->
            <Button Grid.Row="1" Grid.Column="0" Height="50" Width="180" FontSize="22" Margin="10"
     Background="#009999" Foreground="White" Command="{Binding RefreshDataCommand}"
     IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
     Style="{StaticResource MaterialDesignPaperLightButton}"
     ToolTip="Resource name: MaterialDesignPaperLightButton">

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">

                    <materialDesign:PackIcon Kind="Magnify" Width="23" Height="23" Margin="5" />

                    <TextBlock Text="查 询 数 据" />
                </StackPanel>
            </Button>

            <Button Grid.Row="1" Grid.Column="2" Height="50" Width="220" FontSize="22" Margin="10"
Background="YellowGreen" Foreground="White" Command="{Binding CreateMoveCommand}"
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
Style="{StaticResource MaterialDesignPaperLightButton}"
ToolTip="Resource name: MaterialDesignPaperLightButton">

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">

                    <materialDesign:PackIcon Kind="Magnify" Width="23" Height="23" Margin="5" />

                    <TextBlock Text="创建移库任务" />
                </StackPanel>
            </Button>

            <Button Grid.Row="1" Grid.Column="4" Height="50" Width="220" FontSize="22" Margin="10"
Background="YellowGreen" Foreground="White" Command="{Binding CreateResignBoxCommand}"
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
Style="{StaticResource MaterialDesignPaperLightButton}"
ToolTip="Resource name: MaterialDesignPaperLightButton">

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">

                    <materialDesign:PackIcon Kind="Magnify" Width="23" Height="23" Margin="5" />

                    <TextBlock Text="手动入库任务" />
                </StackPanel>
            </Button>
        </Grid>
        <Grid  Grid.Row="1">
            <Border BorderBrush="#0288d1" BorderThickness="0" CornerRadius="2" Background="Transparent">
                <DataGrid x:Name="datagrid"  ItemsSource="{Binding WcsTaskLogItems}" Background="Transparent"
                      FontSize="18" FontFamily="四圆黑" ColumnHeaderHeight="40" RowHeight="40"
                      ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Visible"
                      AutoGenerateColumns="False"  CanUserAddRows="False"
                      GridLinesVisibility="None"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                    <DataGrid.Resources>
                        <Style TargetType="DataGridColumnHeader">
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Foreground" Value="#1edaf2" />
                            <Setter Property="FontWeight" Value="Bold" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="VerticalContentAlignment" Value="Center" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="DataGridColumnHeader">
                                        <Grid>
                                            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                            </Border>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style TargetType="DataGridRow">
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Foreground" Value="#1edaf2" />
                            <!-- 默认边框颜色为透明 -->
                            <Setter Property="BorderThickness" Value="2" />
                            <!-- 边框厚度 -->
                            <Style.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <!--<Setter Property="BorderBrush" Value="Red" />-->
                                    <Setter Property="Background" Value="LightGoldenrodYellow" />
                                    <!-- 选中时边框颜色设置为红色，可按需修改 -->
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DataGrid.Resources>
                    <DataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding No}" Header="序号" Width="*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding Id}" Header="任务Id" Width="*" IsReadOnly="True" Visibility="Collapsed" />
                        <DataGridTextColumn Binding="{Binding NextPointNo}" Header="Agv名称" Width="*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding TaskName}" Header="任务名称" Width="3*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding CurrPointNo}" Header="起点库位" Width="1.5*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding EndPointNo}" Header="终点库位" Width="1.5*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding PalletInfoCode}" Header="托盘编号" Width="1.5*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding CreatedTime,StringFormat=\{0:yyyy-MM-dd  HH:mm:ss\}}" Header="创建时间" Width="2*" IsReadOnly="True" />
                        <DataGridTextColumn Binding="{Binding .,Converter={StaticResource WcsTaskStatusConvert}}" Header="计划状态" Width="3*" IsReadOnly="True" />
                    </DataGrid.Columns>
                </DataGrid>
            </Border>
        </Grid>
    </Grid>
</UserControl>