<!--
NavisworksTransport 路径编辑页签视图 - 采用与动画控制和分层管理一致的Navisworks 2026风格

功能说明：
1. 自动路径规划：起终点选择、物体尺寸参数（长宽高）、安全间隙设置
2. 路径列表：新建、删除、重命名路径，显示路径状态
3. 路径编辑：开始编辑、结束编辑、清空路径、路径点管理
4. 路径文件管理：导入、导出全部、导出选中路径操作和状态显示

设计原则：与Navisworks 2026风格一致，480像素宽度，现代化UI布局，采用GroupBox分组
-->
<UserControl x:Class="NavisworksTransport.UI.WPF.Views.PathEditingView"
             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>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/TransportPlugin;component/src/UI/WPF/Resources/NavisworksStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            
            <!-- 转换器资源 -->
            <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
            <converters:PathTypeConverter x:Key="PathTypeConverter"/>
            <converters:BoolToBrushConverter x:Key="BoolToBrushConverter"/>
            <converters:BoolToOpacityConverter x:Key="BoolToOpacityConverter"/>
            <converters:EditableNumberConverter x:Key="EditableNumberConverter"/>
            
            <!-- 多层吊装转换器 -->
            <converters:IndexPlusOneConverter x:Key="IndexPlusOneConverter"/>
            <converters:DirectionToTextConverter x:Key="DirectionToTextConverter"/>
            <converters:DirectionToColorConverter x:Key="DirectionToColorConverter"/>
            <converters:TargetToTextConverter x:Key="TargetToTextConverter"/>
            
            <!-- 滑块样式 -->
            <Style x:Key="SliderStyle" TargetType="Slider">
                <Setter Property="Foreground" Value="{StaticResource NavisworksSecondaryBrush}"/>
                <Setter Property="Height" Value="20"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto" Padding="10">
        <StackPanel>
            
            <!-- 区域1: 自动路径规划 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Padding="10">
                <StackPanel>
                    <Label Content="自动路径规划" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 起点和终点设置 -->
                    <StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                            <Button Content="选择起点" 
                                    Command="{Binding SelectStartPointCommand}" 
                                    Style="{StaticResource SecondaryButtonStyle}"/>
                            <TextBox Text="{Binding AutoPathStartPoint}" 
                                     Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                        </StackPanel>
                        
                        <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                            <Button Content="选择终点" 
                                    Command="{Binding SelectEndPointCommand}" 
                                    Style="{StaticResource SecondaryButtonStyle}"/>
                            <TextBox Text="{Binding AutoPathEndPoint}" 
                                     Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                        </StackPanel>
                    </StackPanel>
                    
                    <!-- 物体参数设置 - 改为三个独立参数 -->
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        
                        <!-- 物体长度 -->
                        <Label Grid.Row="0" Grid.Column="0" Content="物体长度:" Style="{StaticResource ParameterLabelStyle}"/>
                        <TextBox Grid.Row="0" Grid.Column="1"
                                 Text="{Binding ObjectLength, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                 Style="{StaticResource ParameterInputStyle}"/>
                        <Label Grid.Row="0" Grid.Column="2" Content="米" Style="{StaticResource UnitLabelStyle}"/>

                        <!-- 物体宽度 -->
                        <Label Grid.Row="0" Grid.Column="3" Content="物体宽度:" Style="{StaticResource ParameterLabelStyle}"/>
                        <TextBox Grid.Row="0" Grid.Column="4"
                                 Text="{Binding ObjectWidth, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                 Style="{StaticResource ParameterInputStyle}"/>
                        <Label Grid.Row="0" Grid.Column="5" Content="米" Style="{StaticResource UnitLabelStyle}"/>

                        <!-- 物体高度 -->
                        <Label Grid.Row="1" Grid.Column="0" Content="物体高度:" Style="{StaticResource ParameterLabelStyle}"/>
                        <TextBox Grid.Row="1" Grid.Column="1"
                                 Text="{Binding ObjectHeight, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                 Style="{StaticResource ParameterInputStyle}"/>
                        <Label Grid.Row="1" Grid.Column="2" Content="米" Style="{StaticResource UnitLabelStyle}"/>

                        <!-- 安全间隙 -->
                        <Label Grid.Row="1" Grid.Column="3" Content="安全间隙:" Style="{StaticResource ParameterLabelStyle}"/>
                        <TextBox Grid.Row="1" Grid.Column="4"
                                 Text="{Binding SafetyMargin, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.00###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                 Style="{StaticResource ParameterInputStyle}"/>
                        <Label Grid.Row="1" Grid.Column="5" Content="米" Style="{StaticResource UnitLabelStyle}"/>
                    </Grid>
                    
                    <!-- 路径策略选择 -->
                    <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                        <Label Content="路径策略:" Style="{StaticResource ParameterLabelStyle}"/>
                        <ComboBox ItemsSource="{Binding PathStrategyOptions}"
                                  SelectedItem="{Binding SelectedPathStrategy}"
                                  DisplayMemberPath="DisplayName"
                                  SelectedValuePath="Value"
                                  ToolTip="选择路径规划算法策略"/>
                        <TextBlock Text="优化偏好设置，影响路径生成算法" 
                                   Style="{StaticResource StatusTextStyle}"
                                   VerticalAlignment="Center"
                                   Margin="10,0,0,0"
                                   Foreground="#FF666666"/>
                    </StackPanel>
                    
                    <!-- 高级设置区域 -->
                    <Expander Header="高级设置" IsExpanded="False" Margin="0,5,0,0">
                        <StackPanel Margin="10">
                            <!-- 网格大小设置 -->
                            <Grid Margin="0,5,0,0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                
                                <!-- 启用选项 -->
                                <CheckBox Grid.Row="0" 
                                          Content="手动设置网格大小" 
                                          IsChecked="{Binding IsGridSizeManuallyEnabled}"
                                          ToolTip="启用后可手动设置路径规划的网格精度，否则系统根据模型大小自动选择"/>
                                
                                <!-- 滑块控制 -->
                                <StackPanel Grid.Row="1" IsEnabled="{Binding IsGridSizeManuallyEnabled}">
                                    <Label Content="网格大小(米)" Style="{StaticResource ParameterLabelStyle}"/>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Slider Grid.Column="0" 
                                                Value="{Binding GridSize}" 
                                                Minimum="0.1" 
                                                Maximum="5.0" 
                                                TickFrequency="0.1"
                                                Style="{StaticResource SliderStyle}"/>
                                        <TextBlock Grid.Column="1" 
                                                   Text="{Binding GridSize, StringFormat={}{0:F1}}" 
                                                   VerticalAlignment="Center" 
                                                   Margin="10,0,0,0" 
                                                   Width="30"/>
                                    </Grid>
                                </StackPanel>
                                
                                <!-- 建议信息 -->
                                <TextBlock Grid.Row="2" 
                                           Text="建议：大型厂区(&gt;1000m)用5米，中型建筑(500-1000m)用2米，小型建筑(100-500m)用1米，精细规划(&lt;100m)用0.5米"
                                           Style="{StaticResource StatusTextStyle}"
                                           TextWrapping="Wrap"
                                           Foreground="#FF666666"
                                           FontStyle="Italic"
                                           Margin="0,5,0,0"/>
                            </Grid>
                        </StackPanel>
                    </Expander>
                    
                    <!-- 规划操作按钮 -->
                    <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                        <Button Content="自动规划路径" 
                                Command="{Binding AutoPlanPathCommand}" 
                                Style="{StaticResource ActionButtonStyle}"
                                IsEnabled="{Binding CanExecuteAutoPlanPath}"/>
                        <Button Content="重置参数" 
                                Command="{Binding ClearAutoPathCommand}" 
                                Style="{StaticResource SecondaryButtonStyle}"/>
                    </StackPanel>
                    
                </StackPanel>
            </Border>
            
            <!-- 区域2: 路径列表管理 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,10,0,0" Padding="10">
                <StackPanel>
                    <Label Content="路径列表" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 路径管理按钮 -->
                    <Grid Margin="0,5,0,0">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Button Content="地面" 
                                    Command="{Binding NewPathCommand}"
                                    Style="{StaticResource ActionButtonStyle}"/>
                            <Button Content="吊装"
                                    Command="{Binding NewHoistingPathCommand}"
                                    Style="{StaticResource ActionButtonStyle}"
                                    ToolTip="创建吊装路径（支持多层）"/>
                            <Button Content="空轨"
                                    Command="{Binding NewRailPathCommand}"
                                    Style="{StaticResource SecondaryButtonStyle}"
                                    ToolTip="创建基于空轨基准线吸附的传统 Rail 路径"/>
                            <Button Content="自由"
                                    Command="{Binding NewFreePathCommand}"
                                    Style="{StaticResource SecondaryButtonStyle}"
                                    ToolTip="创建自由路径（任意多点，路径点即物体几何中心）"/>
                            <Button Content="复制"
                                    Command="{Binding DuplicatePathCommand}"
                                    Style="{StaticResource SecondaryButtonStyle}"
                                    IsEnabled="{Binding SelectedPathRoute, Converter={x:Static converters:BoolToVisibilityConverter.IsNotNullToBoolConverter}}"/>
                            <Button Content="删除" 
                                    Command="{Binding DeletePathCommand}" 
                                    Style="{StaticResource SecondaryButtonStyle}"
                                    IsEnabled="{Binding SelectedPathRoute, Converter={x:Static converters:BoolToVisibilityConverter.IsNotNullToBoolConverter}}"/>
                            <Button Content="重命名" 
                                    Command="{Binding RenamePathCommand}"
                                    Style="{StaticResource SecondaryButtonStyle}"
                                    IsEnabled="{Binding SelectedPathRoute, Converter={x:Static converters:BoolToVisibilityConverter.IsNotNullToBoolConverter}}"/>
                        </StackPanel>
                        <Button Content="路径分析" 
                                ToolTip="多路径对比分析..."
                                Style="{StaticResource SecondaryButtonStyle}"
                                Click="OnPathAnalysisButtonClick"
                                HorizontalAlignment="Right"/>
                    </Grid>
                    
                    <!-- 路径列表 -->
                    <DataGrid x:Name="PathRoutesGrid" ItemsSource="{Binding PathRoutes}"
                              SelectedItem="{Binding SelectedPathRoute}"
                              AutoGenerateColumns="False"
                              CanUserAddRows="False"
                              CanUserDeleteRows="False"
                              SelectionMode="Extended"
                              HeadersVisibility="Column"
                              GridLinesVisibility="Horizontal"
                              Height="340"
                              BorderBrush="#FFCCCCCC"
                              BorderThickness="1"
                              Margin="0,5,0,0">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="路径名称" Binding="{Binding Name, UpdateSourceTrigger=PropertyChanged}" Width="120" IsReadOnly="False"/>
                            <DataGridTextColumn Header="类型" Binding="{Binding PathType, Converter={StaticResource PathTypeConverter}}" Width="50" IsReadOnly="True"/>
                            <DataGridTextColumn Header="点数" Binding="{Binding PointCount}" Width="50" IsReadOnly="True"/>
                            <DataGridTextColumn Header="状态" Binding="{Binding StatusString}" Width="60" IsReadOnly="True"/>
                            <DataGridTextColumn Header="创建时间" Binding="{Binding CreatedTime, StringFormat='MM-dd HH:mm:ss'}" Width="100" IsReadOnly="True"/>
                            <DataGridTemplateColumn Header="操作" Width="60" IsReadOnly="True">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="时标" ToolTip="时间标签..."
                                                Padding="2" FontSize="10"
                                                Width="44" Height="20"
                                                HorizontalAlignment="Center"
                                                VerticalAlignment="Center"
                                                Click="OnTimeTagButtonClick"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>

                </StackPanel>
            </Border>

            <!-- 区域3: 路径编辑 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,10,0,0" Padding="10">
                <StackPanel>
                    <Label Content="路径编辑" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 编辑控制按钮 -->
                    <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                        <Button Content="添加路径点" 
                                Command="{Binding StartEditCommand}" 
                                Style="{StaticResource ActionButtonStyle}"
                                IsEnabled="{Binding CanExecuteStartEdit}"/>
                        <Button Content="修改路径点" 
                                Command="{Binding ModifyPointCommand}" 
                                Style="{StaticResource SecondaryButtonStyle}"
                                IsEnabled="{Binding CanExecuteModifyPoint}"/>
                        <Button Content="结束" 
                                Command="{Binding EndEditCommand}" 
                                Style="{StaticResource SecondaryButtonStyle}"
                                IsEnabled="{Binding CanExecuteEndEdit}"/>
                        <Button Content="清空" 
                                Command="{Binding ClearPathCommand}"
                                Style="{StaticResource SecondaryButtonStyle}"
                                Background="#FFFFE6E6"
                                Foreground="#FF8B0000"
                                IsEnabled="{Binding CanExecuteClearPath}"/>
                    </StackPanel>
                    
                    <!-- 当前路径信息 -->
                    <TextBlock Text="{Binding SelectedPathRoute.Name, StringFormat='当前路径: {0}', TargetNullValue='编辑路径: 未选择路径'}" 
                               Style="{StaticResource StatusTextStyle}"
                               FontWeight="SemiBold"
                               Foreground="#FF2B579A"
                               Margin="0,5,0,0"/>

                    <!-- 路径点列表标题栏和工具按钮 -->
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="路径点列表" VerticalAlignment="Center" FontSize="11" Foreground="#FF666666"/>
                        <Button Grid.Column="1" 
                                ToolTip="查看选中模型元素的包围盒信息"
                                Click="OnMeasureBoundsButtonClick"
                                Style="{StaticResource IconButtonStyle}"
                                Width="24"
                                Height="24"
                                Margin="0,0,2,0">
                            <Path Data="M3,7 L14,7 L14,18 L3,18 Z M3,7 L7,3 L18,3 L14,7 M14,18 L18,14 L18,3 L14,7"
                                  Stroke="{StaticResource NavisworksPrimaryBrush}" 
                                  StrokeThickness="1.2"
                                  Fill="Transparent"
                                  Width="16" Height="16" Stretch="Uniform"/>
                        </Button>
                        <Button Grid.Column="2"
                                ToolTip="过弯检测 — 检查模块能否通过 L 形通道"
                                Click="OnCornerTurnCheckClick"
                                Style="{StaticResource IconButtonStyle}"
                                Width="24"
                                Height="24">
                            <Path Data="{StaticResource CornerCheckIconGeometry}" 
                                  Fill="{StaticResource NavisworksPrimaryBrush}" 
                                  Width="16" Height="16" Stretch="Uniform"/>
                        </Button>
                    </Grid>
                    
                    <!-- 路径点列表 -->
                    <ListView ItemsSource="{Binding SelectedPathRoute.Points}" 
                              SelectedItem="{Binding SelectedPathPoint}"
                              Height="180"
                              BorderBrush="#FFCCCCCC"
                              BorderThickness="1"
                              Margin="0,5,0,0">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="点名称" DisplayMemberBinding="{Binding Name}" Width="80"/>
                                <GridViewColumn Header="坐标" DisplayMemberBinding="{Binding CoordinateString}" Width="140"/>
                                <GridViewColumn Header="类型" DisplayMemberBinding="{Binding TypeDisplayString}" Width="60"/>
                                <GridViewColumn Header="操作" Width="180">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                                <Button Content="坐标编辑"
                                                        ToolTip="编辑坐标..."
                                                        Command="{Binding DataContext.EditPointCoordinatesCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                        CommandParameter="{Binding}"
                                                        Padding="2"
                                                        FontSize="10"
                                                        Width="52"
                                                        Height="20"
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"
                                                        Margin="0,0,2,0"/>
                                                <Button Content="删除"
                                                        ToolTip="删除路径点"
                                                        Command="{Binding DataContext.DeletePointCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                        CommandParameter="{Binding}"
                                                        Background="#FFFFE6E6"
                                                        Foreground="#FF8B0000"
                                                        Padding="2"
                                                        FontSize="10"
                                                        Width="44"
                                                        Height="20"
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"
                                                        Margin="0"/>
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>

                    <Expander Header="吊装参数" IsExpanded="True" Margin="0,8,0,0">
                        <StackPanel Margin="10,6,0,0">
                            <StackPanel Visibility="{Binding IsHoistingRouteSelected, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Inverse}">
                                <TextBlock Text="选择一条吊装路径后，可在这里编辑各空中层的绝对高度。"
                                           Style="{StaticResource StatusTextStyle}"
                                           Foreground="#FF666666"/>
                            </StackPanel>

                            <StackPanel Visibility="{Binding IsHoistingRouteSelected, Converter={StaticResource BoolToVisibilityConverter}}">
                                <TextBlock Text="{Binding HoistingLayerEditHintText}"
                                           Style="{StaticResource StatusTextStyle}"
                                           TextWrapping="Wrap"
                                           Foreground="#FF666666"/>

                                <ListView ItemsSource="{Binding HoistingLayerEditItems}"
                                          Margin="0,6,0,0"
                                          Height="120"
                                          BorderBrush="#FFCCCCCC"
                                          BorderThickness="1">
                                    <ListView.View>
                                        <GridView>
                                            <GridViewColumn Header="层级" Width="48">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding DisplayIndex}"
                                                                   HorizontalAlignment="Center"/>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="高度(米)" Width="88">
                                                <GridViewColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <TextBox Text="{Binding HeightInMeters, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                                                 HorizontalContentAlignment="Center"
                                                                 Style="{StaticResource ParameterInputStyle}"/>
                                                    </DataTemplate>
                                                </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="关联点" DisplayMemberBinding="{Binding PointSummary}" Width="92"/>
                                        </GridView>
                                    </ListView.View>
                                </ListView>

                                <WrapPanel Margin="0,8,0,0">
                                    <Button Content="应用层高"
                                            Command="{Binding ApplyHoistingLayerHeightsCommand}"
                                            IsEnabled="{Binding CanApplyHoistingLayerHeights}"
                                            Style="{StaticResource ActionButtonStyle}"/>
                                </WrapPanel>
                            </StackPanel>
                        </StackPanel>
                    </Expander>
                    
                </StackPanel>
            </Border>

            <!-- 区域4: Rail 创建与参数 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,10,0,0" Padding="10">
                <StackPanel>
                    <Label Content="终端安装 / Rail" Style="{StaticResource SectionHeaderStyle}"/>
                    <TextBlock Text="创建直线装配 Rail 路径，并在选中 Rail 路径后调整其安装方式。"
                               Style="{StaticResource StatusTextStyle}"
                               TextWrapping="Wrap"
                               Margin="0,2,0,0"/>

                    <Expander Header="创建 Rail 路径" IsExpanded="False" Margin="0,8,0,0">
                        <StackPanel Margin="10,6,0,0">
                            <Grid Margin="0,0,0,6">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0"
                                       Content="安装方式:"
                                       Style="{StaticResource ParameterLabelStyle}"
                                       VerticalAlignment="Center"/>
                                <ComboBox Grid.Column="1"
                                          Margin="6,0,10,0"
                                          ItemsSource="{Binding RailMountModeOptions}"
                                          SelectedValue="{Binding AssemblyMountMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                          SelectedValuePath="Value"
                                          DisplayMemberPath="DisplayName"
                                          ToolTip="选择直线装配路径使用轨上安装还是轨下安装"/>
                                <Label Grid.Column="2"
                                       Content="安装法向偏移:"
                                       Style="{StaticResource ParameterLabelStyle}"
                                       VerticalAlignment="Center"/>
                                <StackPanel Grid.Column="3"
                                            Orientation="Horizontal"
                                            Margin="6,0,0,0"
                                            VerticalAlignment="Center">
                                    <TextBox Width="72"
                                             Text="{Binding AssemblyAnchorVerticalOffsetInMeters, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                             Style="{StaticResource ParameterInputStyle}"/>
                                    <Label Content="米" Style="{StaticResource UnitLabelStyle}"/>
                                </StackPanel>
                            </Grid>

                            <Grid Margin="0,0,0,6">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0"
                                       Content="终点箱体:"
                                       Style="{StaticResource ParameterLabelStyle}"
                                       VerticalAlignment="Center"/>
                                <TextBox Grid.Column="1"
                                         Margin="6,0,10,0"
                                         Text="{Binding AssemblyTerminalObjectName}"
                                         Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                                <Label Grid.Column="2"
                                       Content="装配起点:"
                                       Style="{StaticResource ParameterLabelStyle}"
                                       VerticalAlignment="Center"/>
                                <TextBox Grid.Column="3"
                                         Margin="6,0,0,0"
                                         Text="{Binding AssemblyStartPointText}"
                                         Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                            </Grid>

                            <Expander Header="更多创建参数" IsExpanded="False">
                                <StackPanel Margin="10,6,0,0">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Label Grid.Column="0"
                                               Content="球心:"
                                               Style="{StaticResource ParameterLabelStyle}"
                                               VerticalAlignment="Center"/>
                                        <StackPanel Grid.Column="1"
                                                    Orientation="Horizontal"
                                                    Margin="6,0,0,0"
                                                    VerticalAlignment="Center">
                                            <TextBox Width="56"
                                                     Text="{Binding AssemblySphereCenterX, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                                     Style="{StaticResource ParameterInputStyle}"/>
                                            <Label Content="X" Style="{StaticResource UnitLabelStyle}"/>
                                            <TextBox Width="56"
                                                     Text="{Binding AssemblySphereCenterY, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                                     Style="{StaticResource ParameterInputStyle}"/>
                                            <Label Content="Y" Style="{StaticResource UnitLabelStyle}"/>
                                            <TextBox Width="56"
                                                     Text="{Binding AssemblySphereCenterZ, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                                     Style="{StaticResource ParameterInputStyle}"/>
                                            <Label Content="Z" Style="{StaticResource UnitLabelStyle}"/>
                                        </StackPanel>
                                    </Grid>
                                </StackPanel>
                            </Expander>

                            <WrapPanel Margin="0,8,0,0">
                                <Button Content="捕获箱体"
                                        Command="{Binding CaptureAssemblyTerminalObjectForCreateCommand}"
                                        Style="{StaticResource SecondaryButtonStyle}"/>
                                <Button Content="取端面"
                                        Command="{Binding AnalyzeAssemblyEndFaceCommand}"
                                        Style="{StaticResource SecondaryButtonStyle}"
                                        IsEnabled="{Binding CanAnalyzeAssemblyEndFace}"
                                        ToolTip="点击一次即可自动分析端面（使用取面工具）"/>
                                <Button Content="选安装面"
                                        Command="{Binding PickAssemblyInstallationCommand}"
                                        Style="{StaticResource SecondaryButtonStyle}"
                                        IsEnabled="{Binding CanPickAssemblyInstallation}"
                                        ToolTip="点击一次自动确定安装参考面（使用取面工具）"/>
                                <Button Content="取起点"
                                        Command="{Binding SelectAssemblyStartPointForCreateCommand}"
                                        Style="{StaticResource ActionButtonStyle}"
                                        IsEnabled="{Binding CanSelectAssemblyStartPointForCreate}"/>
                                <Button Content="隐藏辅助线"
                                        Command="{Binding ClearAssemblyReferenceRodCommand}"
                                        Style="{StaticResource SecondaryButtonStyle}"/>
                                <Button Content="取消装配"
                                        Command="{Binding CancelRailAssemblyWorkflowCommand}"
                                        Style="{StaticResource SecondaryButtonStyle}"
                                        IsEnabled="{Binding CanCancelRailAssemblyWorkflow}"/>
                            </WrapPanel>
                        </StackPanel>
                    </Expander>

                    <Expander Header="Rail 参数" IsExpanded="True" Margin="0,8,0,0">
                        <StackPanel Margin="10,6,0,0">
                            <StackPanel Visibility="{Binding IsRailRouteSelected, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Inverse}">
                                <TextBlock Text="选择一条 Rail 路径后，可在这里修改安装方式。"
                                           Style="{StaticResource StatusTextStyle}"
                                           Foreground="#FF666666"/>
                            </StackPanel>

                            <StackPanel Visibility="{Binding IsRailRouteSelected, Converter={StaticResource BoolToVisibilityConverter}}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Label Grid.Column="0"
                                           Grid.Row="0"
                                           Content="当前路径:"
                                           Style="{StaticResource ParameterLabelStyle}"
                                           VerticalAlignment="Center"/>
                                    <TextBox Grid.Column="1"
                                             Grid.Row="0"
                                             Margin="6,0,10,0"
                                             Text="{Binding SelectedPathRoute.Name}"
                                             Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                                    <Label Grid.Column="2"
                                           Grid.Row="0"
                                           Content="安装方式:"
                                           Style="{StaticResource ParameterLabelStyle}"
                                           VerticalAlignment="Center"/>
                                    <ComboBox Grid.Column="3"
                                              Grid.Row="0"
                                              Margin="6,0,0,0"
                                              ItemsSource="{Binding RailMountModeOptions}"
                                              SelectedValue="{Binding SelectedRailMountMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                              SelectedValuePath="Value"
                                              DisplayMemberPath="DisplayName"/>

                                    <Label Grid.Column="0"
                                           Grid.Row="1"
                                           Margin="0,6,0,0"
                                           Content="终点箱体:"
                                           Style="{StaticResource ParameterLabelStyle}"
                                           VerticalAlignment="Center"/>
                                    <WrapPanel Grid.Column="1"
                                               Grid.Row="1"
                                               Grid.ColumnSpan="3"
                                               Margin="6,6,0,0"
                                               Orientation="Horizontal"
                                               VerticalAlignment="Center"
                                               ItemHeight="28">
                                        <Button Content="重选箱体"
                                                Padding="10,2"
                                                Margin="0,0,10,0"
                                                Command="{Binding ReCaptureAssemblyTerminalObjectForEditCommand}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                        <TextBox Width="150"
                                                 Margin="0,0,10,0"
                                                 Text="{Binding AssemblyTerminalObjectName}"
                                                 Style="{StaticResource ReadOnlyTextBoxStyle}"/>
                                        <Button Content="选安装面"
                                                Padding="10,2"
                                                Margin="0,0,10,0"
                                                Command="{Binding PickAssemblyInstallationCommand}"
                                                IsEnabled="{Binding CanPickAssemblyInstallation}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                        <Button Content="重选起点"
                                                Padding="10,2"
                                                Command="{Binding RepositionRailStartPointCommand}"
                                                IsEnabled="{Binding CanRepositionRailStartPoint}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                        <Button Content="取消装配"
                                                Padding="10,2"
                                                Margin="10,0,0,0"
                                                Command="{Binding CancelRailAssemblyWorkflowCommand}"
                                                IsEnabled="{Binding CanCancelRailAssemblyWorkflow}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                    </WrapPanel>
                                    <Label Grid.Column="0"
                                           Grid.Row="2"
                                           Margin="0,6,0,0"
                                           Content="安装法向偏移:"
                                           Style="{StaticResource ParameterLabelStyle}"
                                           VerticalAlignment="Center"/>
                                    <StackPanel Grid.Column="1"
                                                Grid.Row="2"
                                                Grid.ColumnSpan="3"
                                                Orientation="Horizontal"
                                                Margin="6,6,0,0"
                                                VerticalAlignment="Center">
                                        <Button Content="-"
                                                Width="24"
                                                Height="24"
                                                Padding="0"
                                                Command="{Binding DecreaseSelectedRailNormalOffsetCommand}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                        <TextBox Width="84"
                                                 Margin="6,0"
                                                 HorizontalContentAlignment="Center"
                                                 Text="{Binding SelectedRailNormalOffsetInMeters, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                                                 Style="{StaticResource ParameterInputStyle}"/>
                                        <Button Content="+"
                                                Width="24"
                                                Height="24"
                                                Padding="0"
                                                Command="{Binding IncreaseSelectedRailNormalOffsetCommand}"
                                                Style="{StaticResource SecondaryButtonStyle}"/>
                                        <Label Content="米"
                                               Margin="6,0,0,0"
                                               Style="{StaticResource UnitLabelStyle}"
                                               VerticalAlignment="Center"/>
                                    </StackPanel>
                                 </Grid>
                             </StackPanel>
                         </StackPanel>
                    </Expander>
                </StackPanel>
            </Border>

            <!-- 区域5: 路径文件管理 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,10,0,0" Padding="10">
                <StackPanel>
                    <Label Content="路径文件管理" Style="{StaticResource SectionHeaderStyle}"/>

                    <!-- 文件操作按钮 -->
                    <StackPanel Orientation="Horizontal">
                        <Button Content="导入"
                                Command="{Binding ImportPathCommand}"
                                Style="{StaticResource SecondaryButtonStyle}"/>
                        <Button Content="导出"
                                Command="{Binding SaveAsPathCommand}"
                                Style="{StaticResource SecondaryButtonStyle}"
                                IsEnabled="{Binding CanExecuteSaveAsPath}"/>
                        <Button Content="导出全部"
                                Command="{Binding ExportPathCommand}"
                                Style="{StaticResource SecondaryButtonStyle}"
                                IsEnabled="{Binding CanExecuteExportPath}"/>
                        <Button Content="生成导航地图"
                                Click="OnGenerateNavigationMapButtonClick"
                                Style="{StaticResource SecondaryButtonStyle}"
                                IsEnabled="{Binding CanExecuteSaveAsPath}"/>
                    </StackPanel>

                </StackPanel>
            </Border>

            <!-- 区域6: 可视化设置 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,10,0,0" Padding="10">
                <StackPanel>
                    <Label Content="可视化设置" Style="{StaticResource SectionHeaderStyle}"/>

                    <!-- 网格可视化开关 -->
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Grid.Column="0"
                               Content="网格可视化:"
                               Style="{StaticResource ParameterLabelStyle}"
                               VerticalAlignment="Center"/>

                        <StackPanel Grid.Column="1"
                                    Orientation="Horizontal"
                                    VerticalAlignment="Center"
                                    Margin="5,0,0,0">
                            <CheckBox Content="通行"
                                      IsChecked="{Binding ShowWalkableGrid}"
                                      VerticalAlignment="Center"
                                      ToolTip="显示可通行的网格点"/>
                            <CheckBox Content="障碍物"
                                      IsChecked="{Binding ShowObstacleGrid}"
                                      VerticalAlignment="Center"
                                      ToolTip="显示障碍物网格点"/>
                            <CheckBox Content="未知"
                                      IsChecked="{Binding ShowUnknownGrid}"
                                      VerticalAlignment="Center"
                                      ToolTip="显示未知区域网格点"/>
                            <CheckBox Content="门"
                                      IsChecked="{Binding ShowDoorGrid}"
                                      VerticalAlignment="Center"
                                      ToolTip="显示门网格点（50%透明绿色）"/>
                        </StackPanel>
                    </Grid>

                    <!-- 路径可视化设置 - 三个独立开关 -->
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Grid.Column="0"
                               Content="路径可视化:"
                               Style="{StaticResource ParameterLabelStyle}"
                               VerticalAlignment="Center"/>

                        <StackPanel Grid.Column="1"
                                    Orientation="Horizontal"
                                    VerticalAlignment="Center"
                                    Margin="5,0,0,0">
                            <!-- 控制点连线开关 -->
                            <CheckBox Content="控制点"
                                      IsChecked="{Binding ShowControlVisualization}"
                                      VerticalAlignment="Center"
                                      Margin="0,0,10,0"
                                      ToolTip="显示控制点连线"/>
                            <!-- 路径线/地面连线开关 -->
                            <CheckBox Content="路径线"
                                      IsChecked="{Binding ShowPathLines}"
                                      IsEnabled="{Binding CanUsePathLines}"
                                      VerticalAlignment="Center"
                                      Margin="0,0,10,0"
                                      Opacity="{Binding CanUsePathLines, Converter={StaticResource BoolToOpacityConverter}}"
                                      ToolTip="显示路径线/地面连线（仅地面路径可用）"/>
                            <!-- 通行空间开关 -->
                            <CheckBox Content="通行空间"
                                      IsChecked="{Binding ShowObjectSpace}"
                                      VerticalAlignment="Center"
                                      ToolTip="显示通行空间（矩形通道）"/>
                        </StackPanel>
                    </Grid>

                    <!-- 网格点类型设置 -->
                    <Grid Margin="0,5,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Label Grid.Column="0"
                               Content="网格点类型:"
                               Style="{StaticResource ParameterLabelStyle}"
                               VerticalAlignment="Center"/>

                        <StackPanel Grid.Column="1"
                                    Orientation="Horizontal"
                                    VerticalAlignment="Center"
                                    Margin="5,0,0,0">
                            <RadioButton Content="正方形"
                                         GroupName="GridPointType"
                                         IsChecked="{Binding IsRectanglePointType}"
                                         VerticalAlignment="Center"
                                         ToolTip="显示立方体网格点"/>
                            <RadioButton Content="圆"
                                         GroupName="GridPointType"
                                         IsChecked="{Binding IsCirclePointType}"
                                         VerticalAlignment="Center"
                                         ToolTip="显示圆形网格点"/>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Border>
        </StackPanel>
    </ScrollViewer>
</UserControl>
