feat: MaxFullDisplayDepth 改为从配置文件读取,支持实时生效
- SystemConfig 新增 AliasTreeConfig,含 MaxFullDisplayDepth 属性(默认 2) - ConfigManager 添加 [alias_tree] 段的 TOML 解析和写入 - default_config.toml 添加 [alias_tree] 配置项 - AliasTreeControl 构造时读取配置 + 订阅 CategoryConfigurationChanged 实时重建
This commit is contained in:
parent
d670ae5c3c
commit
a5f9e4da24
@ -84,6 +84,11 @@ width_limit_meters = 3.0
|
||||
# ZUp: 强制使用 Z-Up 坐标系(Navisworks 默认)
|
||||
# YUp: 强制使用 Y-Up 坐标系(常见于 Revit 导出)
|
||||
type = "AutoDetect"
|
||||
|
||||
[alias_tree]
|
||||
# 别名树完整展示的最大层级深度(0 = 仅根节点)
|
||||
# 默认值 2,即展示根节点 + 两层子节点
|
||||
max_full_display_depth = 2
|
||||
|
||||
# 自定义物流类别
|
||||
# 用于扩展内置类别,只需填写类别名称
|
||||
|
||||
@ -492,6 +492,16 @@ namespace NavisworksTransport.Core.Config
|
||||
}
|
||||
}
|
||||
|
||||
// 别名树配置(可选)
|
||||
if (model.ContainsKey("alias_tree"))
|
||||
{
|
||||
var aliasTree = model["alias_tree"] as TomlTable;
|
||||
if (aliasTree != null)
|
||||
{
|
||||
config.AliasTree.MaxFullDisplayDepth = GetIntValueWithDefault(aliasTree, "max_full_display_depth", 2, missingItems);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载自定义类别配置(可选)
|
||||
if (model.ContainsKey("custom_category"))
|
||||
{
|
||||
@ -540,6 +550,7 @@ namespace NavisworksTransport.Core.Config
|
||||
Animation = new AnimationConfig(),
|
||||
Logistics = new LogisticsConfig(),
|
||||
CoordinateSystem = new CoordinateSystemConfig(),
|
||||
AliasTree = new AliasTreeConfig(),
|
||||
CustomCategories = new List<CustomCategoryConfigItem>()
|
||||
};
|
||||
}
|
||||
@ -714,6 +725,15 @@ namespace NavisworksTransport.Core.Config
|
||||
}
|
||||
}
|
||||
|
||||
if (model.ContainsKey("alias_tree"))
|
||||
{
|
||||
var aliasTree = model["alias_tree"] as TomlTable;
|
||||
if (aliasTree != null && config.AliasTree != null)
|
||||
{
|
||||
aliasTree["max_full_display_depth"] = config.AliasTree.MaxFullDisplayDepth;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新自定义类别配置
|
||||
// 注意:由于Tomlyn对数组的处理限制,自定义类别通过专门的API管理
|
||||
// 这里不直接操作TOML模型,而是在保存前通过模板合并
|
||||
|
||||
@ -43,6 +43,11 @@ namespace NavisworksTransport.Core.Config
|
||||
/// </summary>
|
||||
public CoordinateSystemConfig CoordinateSystem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 别名树配置
|
||||
/// </summary>
|
||||
public AliasTreeConfig AliasTree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义类别列表
|
||||
/// </summary>
|
||||
@ -310,4 +315,15 @@ namespace NavisworksTransport.Core.Config
|
||||
public string Type { get; set; } = "AutoDetect";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 别名树配置
|
||||
/// </summary>
|
||||
public class AliasTreeConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 别名树完整展示的最大层级深度(0 = 仅根节点,默认 2)
|
||||
/// </summary>
|
||||
public int MaxFullDisplayDepth { get; set; } = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NavisworksTransport.Core.AliasTree;
|
||||
using NavisworksTransport.Core.Config;
|
||||
using NavisworksTransport.UI.WPF.ViewModels;
|
||||
using NavisworksTransport.Utils;
|
||||
using System;
|
||||
@ -47,6 +48,12 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 从配置文件读取初始值
|
||||
MaxFullDisplayDepth = ConfigManager.Instance.Current.AliasTree?.MaxFullDisplayDepth ?? 2;
|
||||
|
||||
// 订阅配置变更,实时生效
|
||||
ConfigManager.Instance.CategoryConfigurationChanged += OnAliasTreeConfigChanged;
|
||||
|
||||
// 将 AliasTreeView 的 items 源指向根节点集合
|
||||
var rootNodes = new System.Collections.ObjectModel.ObservableCollection<AliasNodeViewModel>();
|
||||
AliasTreeView.ItemsSource = rootNodes;
|
||||
@ -130,11 +137,25 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
/// </summary>
|
||||
public void Cleanup()
|
||||
{
|
||||
ConfigManager.Instance.CategoryConfigurationChanged -= OnAliasTreeConfigChanged;
|
||||
UnhookSelectionEvents();
|
||||
_dataStore = null;
|
||||
_nodeMap.Clear();
|
||||
}
|
||||
|
||||
private void OnAliasTreeConfigChanged(object sender, Tuple<ConfigCategory, ConfigurationChangedEventArgs> args)
|
||||
{
|
||||
var config = ConfigManager.Instance.Current;
|
||||
int newDepth = config.AliasTree?.MaxFullDisplayDepth ?? 2;
|
||||
if (MaxFullDisplayDepth != newDepth)
|
||||
{
|
||||
MaxFullDisplayDepth = newDepth;
|
||||
LogManager.Info($"[别名树] 配置变更: MaxFullDisplayDepth={newDepth}");
|
||||
_built = false;
|
||||
RebuildTree();
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 选择事件(双向联动)
|
||||
// ============================================================
|
||||
|
||||
Loading…
Reference in New Issue
Block a user