<!--
NavisworksTransport 路径规划分析对话框 - 采用与主界面一致的Navisworks 2026风格

功能说明：
1. 多路径对比分析，支持路径选择和维度对比
2. 图文化展示分析结果（条形图/表格）
3. 根据业务目标（安全优先/效率优先）提供调整建议
4. 最佳路径推荐和导出功能

设计原则：参考CollisionReportDialog的布局和样式，使用统一的蓝色主题
-->
<Window x:Class="NavisworksTransport.UI.WPF.Views.PathAnalysisDialog"
        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"
        mc:Ignorable="d"
        Title="路径规划分析 - 多路径对比" 
        Height="800" 
        Width="1200"
        ResizeMode="CanResize" 
        WindowStartupLocation="CenterOwner"
        MinHeight="600"
        MinWidth="900">
        
    <Window.Resources>
        <!-- 引用共享的Navisworks 2026样式资源 -->
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/NavisworksTransportPlugin;component/src/UI/WPF/Resources/NavisworksStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            
            <!-- 转换器定义 -->
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            
            <!-- 路径分析专用样式 -->
            <Style x:Key="AnalysisCardStyle" TargetType="Border">
                <Setter Property="Background" Value="White"/>
                <Setter Property="BorderBrush" Value="#FFD4E7FF"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="CornerRadius" Value="4"/>
                <Setter Property="Padding" Value="15"/>
                <Setter Property="Margin" Value="5"/>
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect Color="Gray" Direction="315" ShadowDepth="2" Opacity="0.3" BlurRadius="4"/>
                    </Setter.Value>
                </Setter>
            </Style>
            
            <Style x:Key="SectionTitleStyle" TargetType="TextBlock">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
                <Setter Property="Foreground" Value="{StaticResource NavisworksPrimaryBrush}"/>
                <Setter Property="Margin" Value="0,0,0,10"/>
            </Style>
            
            <Style x:Key="MetricLabelStyle" TargetType="TextBlock">
                <Setter Property="FontSize" Value="11"/>
                <Setter Property="Foreground" Value="#FF666666"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>
            
            <Style x:Key="MetricValueStyle" TargetType="TextBlock">
                <Setter Property="FontSize" Value="13"/>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="Foreground" Value="{StaticResource NavisworksPrimaryBrush}"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="HorizontalAlignment" Value="Right"/>
            </Style>
            
            <Style x:Key="ChartBarStyle" TargetType="Rectangle">
                <Setter Property="Fill" Value="{StaticResource NavisworksPrimaryBrush}"/>
                <Setter Property="Height" Value="25"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="5,2"/>
            </Style>
            
            <Style x:Key="RecommendationItemStyle" TargetType="Border">
                <Setter Property="Background" Value="#FFF0F8FF"/>
                <Setter Property="BorderBrush" Value="#FFB0D4F1"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="CornerRadius" Value="3"/>
                <Setter Property="Padding" Value="10,8"/>
                <Setter Property="Margin" Value="0,3"/>
            </Style>
            
            <Style x:Key="BestPathStyle" TargetType="Border">
                <Setter Property="Background" Value="#FFF0F8FF"/>
                <Setter Property="BorderBrush" Value="#FF28A745"/>
                <Setter Property="BorderThickness" Value="2"/>
                <Setter Property="CornerRadius" Value="5"/>
                <Setter Property="Padding" Value="15"/>
                <Setter Property="Margin" Value="0,10"/>
            </Style>
            
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <!-- 主内容区域 -->
        <Grid Grid.Row="0" Margin="15">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="320"/>
            </Grid.ColumnDefinitions>
            
            <!-- 左侧：路径选择面板 -->
            <Border Grid.Column="0" Style="{StaticResource AnalysisCardStyle}">
                <StackPanel>
                    <TextBlock Text="📋 路径选择" Style="{StaticResource SectionTitleStyle}"/>
                    
                    <!-- 路径列表 -->
                    <ScrollViewer Height="200" VerticalScrollBarVisibility="Auto">
                        <ItemsControl ItemsSource="{Binding AvailablePaths}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Border Background="#FFF8FBFF" BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="3" Padding="8" Margin="0,2">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <CheckBox Grid.Column="0" IsChecked="{Binding IsSelected, Mode=TwoWay}" VerticalAlignment="Center" Margin="0,0,8,0"/>
                                            <StackPanel Grid.Column="1">
                                                <TextBlock Text="{Binding Name}" FontWeight="SemiBold" FontSize="11"/>
                                                <TextBlock FontSize="9" Foreground="#FF666666">
                                                    <Run Text="长度: "/>
                                                    <Run Text="{Binding Length, StringFormat={}{0:F1}m}"/>
                                                    <Run Text=" | 时间: "/>
                                                    <Run Text="{Binding EstimatedTime}"/>
                                                    <Run Text="s"/>
                                                </TextBlock>
                                            </StackPanel>
                                        </Grid>
                                    </Border>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                    
                    <!-- 操作按钮 -->
                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <Button Content="全选" Command="{Binding SelectAllCommand}" Style="{StaticResource SecondaryButtonStyle}" Width="60" Margin="0,0,8,0"/>
                        <Button Content="清空" Command="{Binding ClearSelectionCommand}" Style="{StaticResource SecondaryButtonStyle}" Width="60"/>
                    </StackPanel>
                    
                    <!-- 分析策略 -->
                    <TextBlock Text="🎯 分析策略" Style="{StaticResource SectionTitleStyle}" Margin="0,20,0,10"/>
                    <RadioButton Content="安全优先（避开碰撞）"
                                 GroupName="AnalysisStrategy"
                                 Tag="安全优先"
                                 Checked="StrategyRadioButton_Checked"
                                 IsChecked="True"
                                 Margin="0,3"/>
                    <RadioButton Content="效率优先（最短路径）"
                                 GroupName="AnalysisStrategy"
                                 Tag="效率优先"
                                 Checked="StrategyRadioButton_Checked"
                                 Margin="0,3"/>

                    <!-- 分析按钮 -->
                    <Button Content="开始分析"
                            Command="{Binding StartAnalysisCommand}"
                            Style="{StaticResource ActionButtonStyle}"
                            Height="35"
                            Margin="0,20,0,0"/>
                </StackPanel>
            </Border>
            
            <!-- 中央：数据对比展示 -->
            <Border Grid.Column="1" Style="{StaticResource AnalysisCardStyle}">
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <StackPanel>
                        <TextBlock Text="📊 对比分析" Style="{StaticResource SectionTitleStyle}"/>
                        
                        <!-- 对比表格 -->
                        <DataGrid ItemsSource="{Binding SelectedPaths}"
                                  AutoGenerateColumns="False" HeadersVisibility="Column" CanUserReorderColumns="False"
                                  CanUserResizeColumns="True" CanUserSortColumns="False" IsReadOnly="True"
                                  BorderBrush="#FFD4E7FF" BorderThickness="1" GridLinesVisibility="Horizontal"
                                  HorizontalGridLinesBrush="#FFEEEEEE" RowBackground="White" AlternatingRowBackground="#FFF8FBFF"
                                  Height="120">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="路径名称" Binding="{Binding Name}" Width="180"/>
                                <DataGridTextColumn Header="长度(m)" Binding="{Binding Length, StringFormat={}{0:F1}}" Width="80"/>
                                <DataGridTextColumn Header="时间(s)" Binding="{Binding EstimatedTime}" Width="80"/>
                                <DataGridTextColumn Header="碰撞" Binding="{Binding CollisionCount}" Width="60"/>
                                <DataGridTextColumn Header="评分" Binding="{Binding Score}" Width="60"/>
                            </DataGrid.Columns>
                        </DataGrid>
                        
                        <!-- 推荐路径 -->
                        <TextBlock Text="🏆 推荐路径" Style="{StaticResource SectionTitleStyle}" Margin="0,25,0,15"/>
                        <Border Background="#FFF0F8FF" BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="3" Padding="15" Margin="0,0,0,15">
                            <StackPanel>
                                <TextBlock FontSize="14" FontWeight="SemiBold" Foreground="#FF2C3E50">
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="推荐路径: {0}">
                                            <Binding Path="RecommendedPath.Name" FallbackValue="未选择"/>
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>
                                <TextBlock FontSize="11" Foreground="#FF7F8C8D" Margin="0,5,0,0">
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="长度: {0:F1}米 | 时间: {1}秒 | 碰撞: {2}次 | 评分: {3}">
                                            <Binding Path="RecommendedPath.Length" FallbackValue="0"/>
                                            <Binding Path="RecommendedPath.EstimatedTime" FallbackValue="0"/>
                                            <Binding Path="RecommendedPath.CollisionCount" FallbackValue="0"/>
                                            <Binding Path="RecommendedPath.Score" FallbackValue="0"/>
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>
                            </StackPanel>
                        </Border>

                        <!-- 分析状态 -->
                        <TextBlock Text="📋 分析状态" Style="{StaticResource SectionTitleStyle}" Margin="0,15,0,10"/>
                        <Border Background="#FFFAFAFA" BorderBrush="#FFE0E0E0" BorderThickness="1" CornerRadius="3" Padding="10">
                            <TextBlock Text="{Binding AnalysisStatus}" FontSize="12" Foreground="#FF666666"/>
                        </Border>
                    </StackPanel>
                </ScrollViewer>
            </Border>
            
            <!-- 右侧：分析结果面板 -->
            <Border Grid.Column="2" Style="{StaticResource AnalysisCardStyle}">
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <StackPanel>
                        <TextBlock Text="🏆 分析结果" Style="{StaticResource SectionTitleStyle}"/>

                        <!-- 优化建议 -->
                        <TextBlock Text="💡 优化建议" FontWeight="SemiBold" FontSize="12" Margin="0,20,0,10"/>
                        <ItemsControl ItemsSource="{Binding OptimizationSuggestions}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Border Style="{StaticResource RecommendationItemStyle}">
                                        <TextBlock Text="{Binding Title}" FontSize="10" TextWrapping="Wrap"/>
                                    </Border>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                        
                        <!-- 导出按钮 -->
                        <Button Content="导出分析报告"
                                Command="{Binding ExportReportCommand}"
                                Style="{StaticResource ActionButtonStyle}"
                                Height="35"
                                Margin="0,20,0,0"/>
                    </StackPanel>
                </ScrollViewer>
            </Border>
        </Grid>
        
        <!-- 底部按钮区域 -->
        <Border Grid.Row="1" 
                BorderBrush="#FFD4E7FF" 
                BorderThickness="1" 
                CornerRadius="0" 
                Background="#FFF8FBFF"
                Margin="15,0,15,15" 
                Padding="15,10">
            <StackPanel Orientation="Horizontal" 
                        HorizontalAlignment="Right">
                
                <Button Content="重新分析" 
                        Style="{StaticResource SecondaryButtonStyle}" 
                        Margin="0,0,10,0"/>
                
                <Button Content="应用推荐" 
                        Style="{StaticResource ActionButtonStyle}" 
                        Margin="0,0,10,0"/>
                
                <Button Content="关闭" 
                        Click="CloseButton_Click" 
                        Style="{StaticResource SecondaryButtonStyle}"/>
                        
            </StackPanel>
        </Border>
    </Grid>
</Window>