<!--
NavisworksTransport 批处理队列管理页签视图 - 采用与其他页签一致的Navisworks 2026风格

功能说明：
1. 队列列表：显示所有批处理队列项，支持状态筛选
2. 队列操作：执行队列、取消当前、删除项
3. 队列监控：实时显示队列执行进度
4. 报告查看：查看单项碰撞报告

设计原则：与Navisworks 2026风格一致，480像素宽度，现代化UI布局，采用Border分组
-->
<UserControl x:Class="NavisworksTransport.UI.WPF.Views.BatchTaskManagementView"
             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:converters="clr-namespace:NavisworksTransport.UI.WPF.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="480">
    
    <UserControl.Resources>
        <!-- 引用共享的Navisworks 2026样式资源 -->
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/TransportPlugin;component/src/UI/WPF/Resources/NavisworksStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            
            <!-- 转换器资源 -->
            <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
            <converters:BatchQueueStatusConverter x:Key="BatchQueueStatusConverter"/>
            <converters:NullToDashConverter x:Key="NullToDashConverter"/>
            <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter"/>
            <converters:PathTypeConverter x:Key="PathTypeConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto" Padding="10">
        <StackPanel>
            <!-- 区域1: 队列操作 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,0,0,15" Padding="12">
                <StackPanel>
                    <Label Content="批处理队列管理" Style="{StaticResource SectionHeaderStyle}"/>

                    <!-- 操作按钮 -->
                    <StackPanel Orientation="Horizontal" Margin="0,10,0,10">
                        <Button Content="执行队列"
                                Command="{Binding ExecuteQueueCommand}"
                                Style="{StaticResource ActionButtonStyle}"/>
                        <Button Content="停止执行"
                                Command="{Binding StopExecutionCommand}"
                                IsEnabled="True"
                                Style="{StaticResource ActionButtonStyle}"/>
                        <Button Content="删除选中"
                                Command="{Binding DeleteItemCommand}"
                                Style="{StaticResource ActionButtonStyle}"/>
                        <Button Content="查看报告"
                                Command="{Binding ViewReportCommand}"
                                Style="{StaticResource ActionButtonStyle}"/>
                        <Button Content="刷新"
                                Command="{Binding RefreshCommand}"
                                Style="{StaticResource ActionButtonStyle}"/>
                    </StackPanel>
                    
                    <!-- 说明文本 -->
                    <TextBlock Text="提示：在动画控制页面点击&quot;添加到批处理&quot;按钮可添加队列项"
                               FontSize="10"
                               Foreground="{StaticResource NavisworksTextBrush}"
                               Margin="0,5,0,0"
                               TextWrapping="Wrap"/>

                    <!-- 多进程开关 -->
                    <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                        <CheckBox Content="使用多进程"
                                  IsChecked="{Binding UseMultiProcess}"
                                  FontSize="12"
                                  Foreground="{StaticResource NavisworksTextBrush}"/>
                    </StackPanel>
                </StackPanel>
            </Border>
            
            <!-- 区域2: 筛选条件 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,0,0,15" Padding="12">
                <StackPanel>
                    <Label Content="筛选条件" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 状态筛选 -->
                    <Grid Margin="0,10,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Grid.Column="0" Content="队列状态:" Style="{StaticResource ParameterLabelStyle}" Width="80"/>
                        <ComboBox Grid.Column="1"
                                  ItemsSource="{x:Static converters:BatchQueueStatusHelper.AllStatuses}"
                                  SelectedItem="{Binding StatusFilter}"
                                  Width="200"
                                  HorizontalAlignment="Left"
                                  Margin="5,0,0,0"
                                  ToolTip="选择要显示的队列状态">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Converter={StaticResource BatchQueueStatusConverter}}"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </Grid>
                </StackPanel>
            </Border>
            
            <!-- 区域3: 队列列表 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,0,0,15" Padding="12">
                <StackPanel>
                    <Label Content="队列列表" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 队列列表表格 -->
                    <DataGrid ItemsSource="{Binding QueueItems}"
                              SelectedItem="{Binding SelectedItem}"
                              AutoGenerateColumns="False"
                              CanUserAddRows="False"
                              CanUserDeleteRows="False"
                              IsReadOnly="True"
                              SelectionMode="Single"
                              HeadersVisibility="Column"
                              GridLinesVisibility="Horizontal"
                              Margin="0,10,0,0"
                              Height="300">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="路径名称" Binding="{Binding PathRouteName}" Width="*" MinWidth="80"/>
                            <DataGridTextColumn Header="路径类型" Binding="{Binding PathType, Converter={StaticResource PathTypeConverter}}" Width="60"/>
                            <DataGridTextColumn Header="物流对象" Binding="{Binding MovingObjectName, Converter={StaticResource NullToDashConverter}}" Width="120"/>
                            <DataGridTextColumn Header="调整角度" Binding="{Binding ObjectRotationCorrection, StringFormat={}{0:F1}°}" Width="80"/>
                            <DataGridTextColumn Header="手工指定" Binding="{Binding DetectAllObjects, Converter={StaticResource BooleanToYesNoConverter}}" Width="80"/>
                            <DataGridTextColumn Header="状态" Binding="{Binding Status, Converter={StaticResource BatchQueueStatusConverter}}" Width="80"/>
                            <DataGridTextColumn Header="碰撞数" Binding="{Binding CollisionCount, StringFormat=\{0\}}" Width="60"/>
                            <DataGridTextColumn Header="创建时间" Binding="{Binding CreatedTime, StringFormat=yyyy-MM-dd HH:mm}" Width="120"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </StackPanel>
            </Border>
            
            <!-- 区域4: 执行状态 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,0,0,15" Padding="12">
                <StackPanel>
                    <Label Content="执行状态" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 进度文本 -->
                    <TextBlock Text="{Binding ProgressText}"
                               FontSize="10"
                               Foreground="{StaticResource NavisworksTextBrush}"
                               Margin="0,10,0,10"
                               TextWrapping="Wrap"/>
                </StackPanel>
            </Border>
        </StackPanel>
    </ScrollViewer>
</UserControl>
