<UserControl x:Class="SlnMesnac.WPF.Page.IndexPage.IndexContent"
             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.IndexPage"
             mc:Ignorable="d" 
             d:DesignHeight="750" d:DesignWidth="1920" Background="Transparent">

    <UserControl.Resources>
        <!-- 定义数据模板 -->
        <DataTemplate x:Key="TaskTemplate">
            <Border BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="2,5">
                <StackPanel Margin="10,0,0,0">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="站台号：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding conveyorno}" FontSize="18" Foreground="White"  Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="航班号：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding flightno}" FontSize="18" Foreground="White"  Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="任务号：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding taskno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="任务状态：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding taskstate}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="AGV编号：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding agvno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="总行李筐数量：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding totalcount}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="已装载筐数量：" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                        <TextBlock Text="{Binding loadcount}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    </StackPanel>
                    <!-- <StackPanel Orientation="Horizontal"> -->
                    <!--     <TextBlock Text="ID：" FontSize="18" Foreground="White" Margin="0,10,0,0" Visibility="Visible"/> -->
                    <!--     <TextBlock Text="{Binding id}" FontSize="18" Foreground="White"  Margin="0,10,0,0"/> -->
                    <!-- </StackPanel> -->
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,10">
                        <Button Content="待处理任务" FontSize="14" Style="{StaticResource  BUTTON_AGREE}" 
                                Width="80" Height="30" Background="YellowGreen" BorderBrush="YellowGreen" Margin="40,0,0,0"
                                Command="{Binding DataContext.HandleTaskCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                CommandParameter="{Binding}"/>
                        <Button Content="删除任务" FontSize="14" Style="{StaticResource  BUTTON_AGREE}" 
                                Width="80" Height="30" Background="Red" BorderBrush="Red" Margin="20,0,0,0"
                                Command="{Binding DataContext.DeleteTaskCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                CommandParameter="{Binding }"/>
                        
                    </StackPanel>
                </StackPanel>
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="LogMsgTemplate">
            <TextBlock Text="{Binding}" FontSize="16" Foreground="White" TextWrapping="Wrap" MaxWidth="300"/>
        </DataTemplate>

        <DataTemplate x:Key="FlightTemplate">
            <Border BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="2,5">
                <StackPanel Margin="10,0,0,0">
                    <TextBlock Text="{Binding flightNumber}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    <TextBlock Text="{Binding scheduledTime}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    <TextBlock Text="{Binding destination}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    <TextBlock Text="{Binding flightStatus}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
                    <TextBlock Text="{Binding baggageClaim}" FontSize="18" Foreground="White" Margin="0,10,0,10"/>
                </StackPanel>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="6*"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>
        <Border Grid.Column="0" BorderBrush="#1254AB" BorderThickness="0" CornerRadius="5" Background="Transparent">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>
                    <RowDefinition Height="4*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2">
                    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
                        <TextBlock Text="任务列表" FontSize="24" Foreground="White" Margin="20,0,0,0"/>
                        <Button Content="添加" Command="{Binding AddTaskCommand}" FontSize="14" Style="{StaticResource  BUTTON_AGREE}" Width="80" Height="30" Background="YellowGreen" BorderBrush="YellowGreen" Margin="20,0,0,0"/>
                    </StackPanel>
                </Border>
                <Border Grid.Row="1">
                    <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                        <ItemsControl ItemsSource="{Binding TaskItems}" ItemTemplate="{StaticResource TaskTemplate}" />
                    </ScrollViewer>
                    
                </Border>
                <Border Grid.Row="2" BorderBrush="#1254AB" BorderThickness="2" Margin="0,10,0,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="2*"/>
                            <RowDefinition Height="9*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Text="日志信息" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                            <ItemsControl ItemsSource="{Binding LogMessages}" ItemTemplate="{StaticResource LogMsgTemplate}" />
                        </ScrollViewer>
                    </Grid>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Column="1" BorderBrush="#1254AB" BorderThickness="0" CornerRadius="5" Margin="10,0,10,0">
            <Border.Background>
                <ImageBrush ImageSource="/Templates/image/between.png" Stretch="Uniform" />
            </Border.Background>
            <Grid Margin="15,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.5*"/>
                    <RowDefinition Height="0.7*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="0.7*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="1">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1.9*"/>
                            <ColumnDefinition Width="0.4*"/>
                            <ColumnDefinition Width="1.7*"/>
                            <ColumnDefinition Width="0.4*"/>
                            <ColumnDefinition Width="1.6*"/>
                            <ColumnDefinition Width="0.4*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0" >
                            <Button Content="手动呼叫" Command="{Binding ManualCallCommand}" FontSize="16" Style="{StaticResource  BUTTON_AGREE}" Width="120" Height="40" Background="YellowGreen" BorderBrush="YellowGreen"/>
                        </Border>
                        <Border Grid.Column="2">
                            <Button Content="手动终止" Command="{Binding ManualTerminateCommand}" FontSize="16" Style="{StaticResource  BUTTON_AGREE}" Width="120" Height="40" Background="Red" BorderBrush="Red"/>
                        </Border>
                        <Border Grid.Column="4">
                            <Button Content="复      位" Command="{Binding ResetCommand}" FontSize="16" Style="{StaticResource  BUTTON_AGREE}" Width="120" Height="40" Background="#FF9900" BorderBrush="#FF9900"/>
                        </Border>
                    </Grid>
                </Border>
                <Border Grid.Row="2">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.8*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="1.5*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="0.2*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="1#站台" FontSize="18" Foreground="White"/>
                        </Border>
                        <Border Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="4#站台" FontSize="18" Foreground="White"/>
                        </Border>
                    </Grid>
                </Border>
                <Border Grid.Row="4">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.8*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="1.5*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="0.2*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="2#站台" FontSize="18" Foreground="White"/>
                        </Border>
                        <Border Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="5#站台" FontSize="18" Foreground="White"/>
                        </Border>
                    </Grid>
                </Border>
                <Border Grid.Row="6">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.8*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="1.5*"/>
                            <ColumnDefinition Width="1.3*"/>
                            <ColumnDefinition Width="0.2*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="3#站台" FontSize="18" Foreground="White"/>
                        </Border>
                        <Border Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock Text="6#站台" FontSize="18" Foreground="White"/>
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Column="2" BorderBrush="#1254AB" BorderThickness="0" CornerRadius="5" Background="Transparent">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="12*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2">
                    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Vertical">
                        <TextBlock Text="航班信息" FontSize="24" Foreground="White" Margin="20,0,0,0"/>
                        <TextBlock Text="{Binding CurrentDateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" FontSize="18" Foreground="White" Margin="20,0,0,0"/>
                    </StackPanel>
                </Border>
                <Border Grid.Row="1">
                    <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                        <ItemsControl ItemsSource="{Binding FlightItems}" ItemTemplate="{StaticResource FlightTemplate}" />
                    </ScrollViewer>

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