<UserControl x:Class="MainShell.Resources.CustomControl.MagazineMapControl"
             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:MainShell.Resources.CustomControl"
             mc:Ignorable="d"
             d:DesignHeight="520" d:DesignWidth="280">
    <Border Background="#07152F" BorderBrush="#2B3E63" BorderThickness="1" CornerRadius="4" Padding="10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBlock Text="{Binding MapViewModel.Title, RelativeSource={RelativeSource AncestorType={x:Type local:MagazineMapControl}}}" Foreground="#9FB7E8" FontWeight="Bold" FontStyle="Italic"/>
                <TextBlock Grid.Column="1" Text="{Binding MapViewModel.TotalSlots, RelativeSource={RelativeSource AncestorType={x:Type local:MagazineMapControl}}, StringFormat={}{0} SLOTS}" Foreground="#00E5A1" FontWeight="Bold"/>
            </Grid>

            <Border Grid.Row="1" Margin="0,10,0,10" BorderBrush="#1B2C4F" BorderThickness="1" Padding="6">
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <ItemsControl ItemsSource="{Binding MapViewModel.Slots, RelativeSource={RelativeSource AncestorType={x:Type local:MagazineMapControl}}}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border Margin="0,1" Padding="6,3" CornerRadius="1" Background="#0D1C3D">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Text="{Binding SlotName}" Foreground="#86A8DA" FontWeight="SemiBold"/>
                                        <TextBlock Grid.Column="1" Text="{Binding StatusText}" Foreground="#506C9A" FontWeight="Bold"/>
                                    </Grid>
                                    <Border.Style>
                                        <Style TargetType="Border">
                                            <Setter Property="Background" Value="#0D1C3D"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding SlotStatus}" Value="Present">
                                                    <Setter Property="Background" Value="#00A77A"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding SlotStatus}" Value="Processing">
                                                    <Setter Property="Background" Value="#F59E0B"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding SlotStatus}" Value="Completed">
                                                    <Setter Property="Background" Value="#2563EB"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding SlotStatus}" Value="Target">
                                                    <Setter Property="Background" Value="#F59E0B"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding SlotStatus}" Value="Alarm">
                                                    <Setter Property="Background" Value="#E53935"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Border.Style>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </Border>

            <UniformGrid Grid.Row="2" Columns="2" Rows="3" Margin="0,2,0,0">
                <StackPanel Orientation="Horizontal" Margin="0,2">
                    <Ellipse Width="10" Height="10" Fill="#00A77A" Margin="0,0,6,0"/>
                    <TextBlock Text="在位" Foreground="#C7D7F1"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,2">
                    <Ellipse Width="10" Height="10" Fill="#23385E" Margin="0,0,6,0"/>
                    <TextBlock Text="空层" Foreground="#C7D7F1"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,2">
                    <Ellipse Width="10" Height="10" Fill="#F59E0B" Margin="0,0,6,0"/>
                    <TextBlock Text="加工中" Foreground="#C7D7F1"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,2">
                    <Ellipse Width="10" Height="10" Fill="#2563EB" Margin="0,0,6,0"/>
                    <TextBlock Text="加工完成" Foreground="#C7D7F1"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,2">
                    <Ellipse Width="10" Height="10" Fill="#E53935" Margin="0,0,6,0"/>
                    <TextBlock Text="异常" Foreground="#C7D7F1"/>
                </StackPanel>
            </UniformGrid>
        </Grid>
    </Border>
</UserControl>
