<Window x:Class="NavisworksTransport.UI.WPF.Views.CollisionAnalysisDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="预计算碰撞分析 - 排除建议" 
        Height="720" Width="720"
        WindowStartupLocation="CenterOwner"
        ResizeMode="CanResize"
        Background="White">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/TransportPlugin;component/src/UI/WPF/Resources/NavisworksStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            
            <!-- 提示框样式 -->
            <Style x:Key="InfoBorderStyle" TargetType="Border">
                <Setter Property="Background" Value="{StaticResource NavisworksBackgroundBrush}"/>
                <Setter Property="BorderBrush" Value="{StaticResource NavisworksLightBrush}"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="CornerRadius" Value="3"/>
                <Setter Property="Padding" Value="12"/>
            </Style>
            
            <!-- 详情区域样式 -->
            <Style x:Key="DetailsBorderStyle" TargetType="Border">
                <Setter Property="Background" Value="#FFF8F9FA"/>
                <Setter Property="BorderBrush" Value="#FFDEE2E6"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="CornerRadius" Value="3"/>
                <Setter Property="Padding" Value="12"/>
            </Style>
            
            <!-- 数字粗体样式 -->
            <Style x:Key="NumberBoldStyle" TargetType="TextBlock">
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="Foreground" Value="Black"/>
            </Style>
        </ResourceDictionary>
    </Window.Resources>

    <Grid Margin="15">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- 标题和统计 -->
        <StackPanel Grid.Row="0" Margin="0,0,0,12">
            <TextBlock Text="预计算碰撞结果分析" 
                       FontSize="16" 
                       FontWeight="SemiBold" 
                       Foreground="{StaticResource NavisworksPrimaryBrush}"
                       Margin="0,0,0,8"/>
            <TextBlock x:Name="StatsTextBlock" 
                       Text="正在分析..." 
                       FontSize="11"
                       Foreground="{StaticResource NavisworksTextBrush}"/>
        </StackPanel>

        <!-- 说明 -->
        <Border Grid.Row="1" Style="{StaticResource InfoBorderStyle}" Margin="0,0,0,12">
            <TextBlock TextWrapping="Wrap" FontSize="11">
                <Run FontWeight="SemiBold" Foreground="{StaticResource NavisworksPrimaryBrush}">提示：</Run>
                <Run>以下物体在预计算中产生了大量碰撞检测点。这些通常是地面、楼板、墙体等大面积物体。</Run>
                <LineBreak/>
                <Run>勾选"排除"可以将这些物体从碰撞检测中移除，显著减少检测时间。请确认这些物体确实不会与运动物体发生真实碰撞。</Run>
            </TextBlock>
        </Border>

        <!-- 候选碰撞统计 -->
        <Border Grid.Row="2" Background="#FFF5F5F5" BorderBrush="#FFE0E0E0" 
                BorderThickness="1" CornerRadius="3" Padding="12" Margin="0,0,0,12">
            <StackPanel>
                <TextBlock x:Name="DetectionStatsTextBlock" FontSize="12">
                    <Run>候选碰撞检测：</Run>
                    <Run x:Name="CollisionCountRun" FontWeight="Bold" Foreground="Black"/>
                    <Run> 次，</Run>
                    <Run x:Name="HotspotCountRun" FontWeight="Bold" Foreground="Black"/>
                    <Run> 个高频碰撞物体</Run>
                </TextBlock>
                <TextBlock x:Name="EstimatedTimeTextBlock" 
                           FontSize="11" 
                           Foreground="{StaticResource NavisworksSecondaryBrush}"
                           Margin="0,4,0,0"/>
            </StackPanel>
        </Border>

        <!-- 热点列表 -->
        <Border Grid.Row="3" BorderBrush="{StaticResource NavisworksLightBrush}" 
                BorderThickness="1" CornerRadius="3" Margin="0,0,0,12">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10,10,10,8">
                    <TextBlock Text="批量选择：" VerticalAlignment="Center" FontSize="11"
                               Foreground="{StaticResource NavisworksTextBrush}" Margin="0,0,8,0"/>
                    <Button Content="全选"
                            Width="70"
                            Margin="0,0,6,0"
                            Click="SelectAllButton_Click"
                            Style="{StaticResource SecondaryButtonStyle}"/>
                    <Button Content="全取消"
                            Width="80"
                            Click="ClearAllButton_Click"
                            Style="{StaticResource SecondaryButtonStyle}"/>
                </StackPanel>

                <DataGrid Grid.Row="1"
                          x:Name="HotspotsDataGrid" 
                          AutoGenerateColumns="False" 
                          CanUserAddRows="False"
                          SelectionMode="Single"
                          GridLinesVisibility="Horizontal"
                          BorderThickness="0"
                          HeadersVisibility="Column"
                          RowBackground="White"
                          AlternatingRowBackground="{StaticResource NavisworksBackgroundBrush}"
                          SelectionChanged="HotspotsDataGrid_SelectionChanged">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="序号" Width="45" 
                                            Binding="{Binding Index}" IsReadOnly="True">
                            <DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                    <Setter Property="FontSize" Value="11"/>
                                </Style>
                            </DataGridTextColumn.ElementStyle>
                        </DataGridTextColumn>
                        <DataGridCheckBoxColumn Header="排除" Width="50" 
                                                Binding="{Binding IsExcluded, Mode=TwoWay}"/>
                        <DataGridTextColumn Header="物体名称" Width="*" 
                                            Binding="{Binding ObjectName}" IsReadOnly="True">
                            <DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="FontSize" Value="11"/>
                                </Style>
                            </DataGridTextColumn.ElementStyle>
                        </DataGridTextColumn>
                        <DataGridTextColumn Header="碰撞次数" Width="80" 
                                            Binding="{Binding CollisionCount}" IsReadOnly="True">
                            <DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                    <Setter Property="FontSize" Value="11"/>
                                    <Setter Property="FontWeight" Value="Bold"/>
                                    <Setter Property="Foreground" Value="Black"/>
                                </Style>
                            </DataGridTextColumn.ElementStyle>
                        </DataGridTextColumn>
                        <DataGridTextColumn Header="占比" Width="60" 
                                            Binding="{Binding Percentage, StringFormat={}{0:F1}%}" IsReadOnly="True">
                            <DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                    <Setter Property="FontSize" Value="11"/>
                                </Style>
                            </DataGridTextColumn.ElementStyle>
                        </DataGridTextColumn>
                        <DataGridTextColumn Header="原因分析" Width="200" 
                                            Binding="{Binding Reason}" IsReadOnly="True">
                            <DataGridTextColumn.ElementStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="FontSize" Value="10"/>
                                    <Setter Property="Foreground" Value="{StaticResource NavisworksTextBrush}"/>
                                </Style>
                            </DataGridTextColumn.ElementStyle>
                        </DataGridTextColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </Border>

        <!-- 选中物体详情 -->
        <Border Grid.Row="4" Style="{StaticResource DetailsBorderStyle}" Margin="0,0,0,12">
            <StackPanel>
                <TextBlock Text="选中物体详情" 
                           FontWeight="SemiBold" 
                           FontSize="12"
                           Foreground="{StaticResource NavisworksPrimaryBrush}"
                           Margin="0,0,0,6"/>
                <TextBlock x:Name="SelectedObjectDetails" 
                           Text="请选择一个物体查看详情" 
                           Foreground="{StaticResource NavisworksTextBrush}" 
                           FontSize="11"
                           TextWrapping="Wrap"/>
            </StackPanel>
        </Border>

        <!-- 按钮 -->
        <StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="继续生成动画" 
                    Width="120" 
                    Click="ActionButton_Click"
                    Style="{StaticResource ActionButtonStyle}"/>
            <Button Content="取消" 
                    Width="80" 
                    Click="CancelButton_Click"
                    Style="{StaticResource SecondaryButtonStyle}"
                    Margin="10,0,0,0"/>
        </StackPanel>
    </Grid>
</Window>

