123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections.Generic;
- using UniRx;
- using UnityEngine;
- namespace QFramework
- {
- /// <summary>
- /// 树形节点表
- /// </summary>
- public class TreeNodeList
- {
- //节点表
- public ReactiveCollection<TreeNodeItem> TreeNodeItems = new ReactiveCollection<TreeNodeItem>();
- //所有节点字典
- public List<TreeNodeItem> treeNodeItems = new List<TreeNodeItem>();
- /// <summary>
- /// 添加节点
- /// </summary>
- /// <param name="content">内容</param>
- /// <param name="parent">父节点名称</param>
- /// <param name="layer">层级</param>
- public void AddTreeNode(TreeNodeItem treeNodeData)
- {
- if (string.IsNullOrEmpty(treeNodeData.ParentName.Value))
- {
- treeNodeData.ShowHidden.Value = true;
- treeNodeItems.Add(treeNodeData);
- TreeNodeItems.Add(treeNodeData);
- }
- else
- {
- TreeNodeItem tmpItem = treeNodeItems.Find(t => t.Content.Value == treeNodeData.ParentName.Value);
- if (tmpItem != null)
- {
- tmpItem.ChildTreeNodeList.TreeNodeItems.Add(treeNodeData);
- treeNodeItems.Add(treeNodeData);
- }
- }
- }
- }
- public class TreeNodeItem
- {
- /// <summary>
- /// 内容
- /// </summary>
- public StringReactiveProperty Content = new StringReactiveProperty(string.Empty);
- /// <summary>
- /// 父节点名称
- /// </summary>
- public StringReactiveProperty ParentName = new StringReactiveProperty(string.Empty);
- /// <summary>
- /// 子节点列表
- /// </summary>
- public TreeNodeList ChildTreeNodeList = new TreeNodeList();
- /// <summary>
- /// 层级
- /// </summary>
- public IntReactiveProperty Layer = new IntReactiveProperty(0);
- /// <summary>
- /// 是否展开
- /// </summary>
- public BoolReactiveProperty ExPanded = new BoolReactiveProperty(false);
- /// <summary>
- /// 显示或隐藏
- /// </summary>
- public BoolReactiveProperty ShowHidden = new BoolReactiveProperty(true);
- /// <summary>
- /// 位置
- /// </summary>
- public Vector3 position { get; set; }
- /// <summary>
- /// 转角
- /// </summary>
- public Vector3 rotation { get; set; }
- public int id { get; set; }
- public string index { get; set; }
- /// <summary>
- /// 设备唯一编码
- /// </summary>
- public int equipmentUniqueID { get; set; }
- public string gropName { get; set; }
- }
- }
|