<!--
NavisworksTransport 类别设置页签视图 - 参考分层管理页签的设计风格

功能改进：
1. 参考分层管理页签的布局风格和UI组织方式
2. 将模型选择的提示和通知移动到类别属性区域中
3. 提供完整的物流属性设置功能，包括物流类型、可通行性、优先级、限制值等
4. 增加插件默认宽度到480像素以容纳更多内容
5. 保持与Navisworks 2026风格一致的设计

设计原则：简化操作流程、整合相关功能、与Navisworks 2026风格一致
-->
<UserControl x:Class="NavisworksTransport.UI.WPF.Views.ModelSettingsView"
             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="700" 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:IndexConverter x:Key="IndexConverter"/>
            <converters:EditableNumberConverter x:Key="EditableNumberConverter"/>
        </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}"/>
                    
                    <!-- 模型选择状态显示 -->
                    <Grid Margin="0,5,0,15">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        
                        <TextBlock Grid.Row="0" 
                                   Text="{Binding SelectedModelsText}" 
                                   FontWeight="SemiBold" 
                                   Foreground="#FF2B579A"
                                   Margin="0,0,0,5"/>
                    </Grid>
                    
                    <!-- 类别属性设置 -->
                    <GroupBox Header="物流属性" Margin="0,5,0,0">
                        <StackPanel Margin="10">
                            <!-- 第一行：物流类型和可通行性 -->
                            <Grid Margin="0,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="140"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="100"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                
                                <Label Grid.Column="0" Content="物流类型:" Style="{StaticResource ParameterLabelStyle}"/>
                                <ComboBox Grid.Column="1" 
                                          ItemsSource="{Binding AvailableCategories}" 
                                          SelectedItem="{Binding SelectedCategory}"
                                          Margin="5,2" IsEnabled="{Binding IsNotProcessing}"
                                          ToolTip="选择物流元素的类型"/>
                                
                                <Label Grid.Column="2" Content="可通行:" VerticalAlignment="Center" Margin="15,0,0,0"/>
                                <CheckBox Grid.Column="3" 
                                          IsChecked="{Binding IsTraversable}"
                                          VerticalAlignment="Center" Margin="5,2"
                                          ToolTip="是否允许物流运输通过此区域"/>
                            </Grid>
                            
                            <!-- 第二行：优先级 -->
                            <Grid Margin="0,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="140"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                
                                <Label Grid.Column="0" Content="优先级:" Style="{StaticResource ParameterLabelStyle}"/>
                                <ComboBox Grid.Column="1" 
                                          ItemsSource="{Binding PriorityLevels}"
                                          SelectedItem="{Binding Priority}"
                                          Margin="5,2" IsEnabled="{Binding IsNotProcessing}"
                                          ToolTip="1-5级，5为最高优先级"/>
                                <TextBlock Grid.Column="2" 
                                           Text="(1-5级，5为最高优先级)" 
                                           Style="{StaticResource StatusTextStyle}" 
                                           VerticalAlignment="Center"
                                           Margin="10,0,0,0"/>
                            </Grid>
                            
                            <!-- 第三行：限制尺寸 -->
                            <Grid Margin="0,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="80"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="80"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                
                                <Label Grid.Column="0" Content="限宽:" Style="{StaticResource ParameterLabelStyle}"/>
                                <TextBox Grid.Column="1"
                                         Text="{Binding WidthLimit, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}" 
                                         Style="{StaticResource ParameterInputStyle}"
                                         ToolTip="通行宽度限制（米）"/>
                                <Label Grid.Column="2" Content="米" Style="{StaticResource UnitLabelStyle}"/>
                                
                                <Label Grid.Column="3" Content="限高:" VerticalAlignment="Center" Margin="15,0,0,0"/>
                                <TextBox Grid.Column="4"
                                         Text="{Binding HeightLimit, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}" 
                                         Style="{StaticResource ParameterInputStyle}"
                                         ToolTip="通行高度限制（米）"/>
                                <Label Grid.Column="5" Content="米" Style="{StaticResource UnitLabelStyle}"/>
                            </Grid>
                            
                            <!-- 第四行：限速 -->
                            <Grid Margin="0,0,0,15">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="80"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                
                                <Label Grid.Column="0" Content="限速:" Style="{StaticResource ParameterLabelStyle}"/>
                                <TextBox Grid.Column="1"
                                         Text="{Binding SpeedLimit, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.0###, ValidatesOnExceptions=True, NotifyOnValidationError=True}" 
                                         Style="{StaticResource ParameterInputStyle}"
                                         ToolTip="速度限制（米/秒）"/>
                                <Label Grid.Column="2" Content="米/秒" Style="{StaticResource UnitLabelStyle}" Width="40"/>
                                <TextBlock Grid.Column="3" 
                                           Text="推荐值：通道 0.8m/s，电梯 0.5m/s，楼梯 0.3m/s" 
                                           Style="{StaticResource StatusTextStyle}" 
                                           VerticalAlignment="Center"
                                           Margin="10,0,0,0"/>
                            </Grid>
                            
                            <!-- 操作按钮区域 -->
                            <StackPanel Orientation="Horizontal" 
                                        HorizontalAlignment="Center" 
                                        Margin="0,5,0,5">
                                <Button Content="设置属性" 
                                        Style="{StaticResource ActionButtonStyle}"
                                        Command="{Binding SetLogisticsAttributeCommand}"
                                        IsEnabled="{Binding CanSetLogisticsAttribute}"
                                        ToolTip="为选中的模型应用上述物流属性"/>
                                <Button Content="清除属性" 
                                        Style="{StaticResource ActionButtonStyle}"
                                        Command="{Binding ClearLogisticsAttributeCommand}"
                                        IsEnabled="{Binding CanClearLogisticsAttribute}"
                                        ToolTip="清除选中模型的物流属性"/>
                                <Button Content="重置默认值" 
                                        Style="{StaticResource SecondaryButtonStyle}"
                                        Command="{Binding ResetToDefaultsCommand}"
                                        ToolTip="将所有参数重置为推荐的默认值"/>
                            </StackPanel>
                        </StackPanel>
                    </GroupBox>
                </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="10,5,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="120"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        
                        <TextBlock Grid.Column="0" Text="按类型筛选:" VerticalAlignment="Center" Margin="0,0,5,0"/>
                        <ComboBox Grid.Column="1"
                                  ItemsSource="{Binding AvailableCategoryFilters}" 
                                  SelectedItem="{Binding SelectedCategoryFilter}"
                                  ToolTip="按物流类型筛选显示"/>
                        <Button Grid.Column="3" 
                                Content="刷新" 
                                Style="{StaticResource SecondaryButtonStyle}"
                                Command="{Binding RefreshLogisticsModelsCommand}"
                                ToolTip="重新扫描模型中的所有物流元素"/>
                    </Grid>
                    
                    <!-- 物流模型列表 -->
                    <GroupBox Header="已设置物流属性的模型" Margin="0,10,0,0" MinHeight="200">
                        <ListView ItemsSource="{Binding FilteredLogisticsModels}" 
                                  SelectedItem="{Binding SelectedLogisticsModel}"
                                  Margin="5">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Header="序号" Width="40">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Converter={StaticResource IndexConverter}}" 
                                                           HorizontalAlignment="Center"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="模型名称" DisplayMemberBinding="{Binding Name}" Width="140"/>
                                    <GridViewColumn Header="物流类型" DisplayMemberBinding="{Binding Category}" Width="80"/>
                                    <GridViewColumn Header="属性详情" DisplayMemberBinding="{Binding Attributes}" Width="180"/>
                                    <GridViewColumn Header="可见" Width="50">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding IsVisible, Mode=OneWay}"
                                                          HorizontalAlignment="Center"
                                                          Command="{Binding DataContext.ToggleModelVisibilityCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                          CommandParameter="{Binding}"
                                                          ToolTip="点击切换模型显示/隐藏状态"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </GroupBox>
                </StackPanel>
            </Border>
            
            <!-- 区域3: 可见性控制 -->
            <Border BorderBrush="#FFD4E7FF" BorderThickness="1" CornerRadius="0" Margin="0,0,0,15" Padding="12">
                <StackPanel>
                    <Label Content="显示模式控制" Style="{StaticResource SectionHeaderStyle}"/>
                    
                    <!-- 可见性控制选项 -->
                    <Grid Margin="0,5,0,15">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        
                        <CheckBox Grid.Row="0" 
                                  Content="仅显示物流元素" 
                                  IsChecked="{Binding IsLogisticsOnlyMode}" 
                                  ToolTip="开启后只显示已设置物流属性的元素，关闭后显示所有元素"
                                  FontWeight="Bold"
                                  Margin="0,5"/>
                        
                        <TextBlock Grid.Row="1" 
                                   Text="提示：开启此选项可提高大模型性能，隐藏非物流相关元素。物流模型列表会自动更新。" 
                                   Style="{StaticResource StatusTextStyle}" 
                                   Margin="0,5,0,0"/>
                    </Grid>
                </StackPanel>
            </Border>
            
        </StackPanel>
    </ScrollViewer>
</UserControl>
