/// <summary> /// 移除特定对象的第一个匹配项。 /// </summary> /// <returns>如果成功移除 node,则为 true;否则为 false。</returns> public bool RemoveTreeNode(UIComp_TreeNodeBase node) { if (node == null) { return(false); } bool ret = treeNodes.Remove(node); if (!ret) { // 迭代所有子节点 foreach (UIComp_TreeNodeBase child in treeNodes) { ret = child.RemoveTreeNode(node); if (ret) { break; } } } if (ret) { OnTreeNodesChanged(new TreeNodeEventArg(this)); } return(ret); }
public override UIComp_TreeNodeBase GetNodeAtPoint(Vector2 point) { foreach (UIComp_TreeNodeBase node in treeNodes) { UIComp_TreeNodeBase ret = node.GetNodeAtPoint(point); if (ret != null) { return(ret); } } return(null); }
/// <summary> /// 插入一个新的元素 /// </summary> public UIComp_TreeNodeBase InsertTreeNode(int position, UIComp_TreeNodeBase item) { if (item == null) { throw new InvalidRequestException("Invalid insert item"); } if (position < 0 || position >= treeNodes.Count) { treeNodes.Add(item); } else { treeNodes.Insert(position, item); } OnTreeNodesChanged(new TreeNodeEventArg(item)); return(item); }
public override UIComp_TreeNodeBase GetNodeAtPoint(Vector2 point) { if (IsHit(point)) { return(this); } // 迭代所有子项 if (expand) { foreach (UIComp_TreeNodeBase node in treeNodes) { UIComp_TreeNodeBase ret = node.GetNodeAtPoint(point); if (ret != null) { return(ret); } } } return(null); }
public UIComp_TreeNode(Window owner, UIComp_TreeNodeBase parent) : base(owner) { this.parentNode = parent; this.expand = true; this.indentation = DefaultIndentation; this.nodeIcon = new UIComp_DrawTextureAtlas(owner); this.nodeText = new UIComp_DrawText(owner); this.nodeIcon.ResourceAtlasLocation = new NexusEngine.NResourceLoc(@"engine_data:/ui/Atlas/engine_data1.txa"); this.nodeIcon.AtlasItemName = "0"; this.nodeIcon.Height = new UIDim(0, DefaultTreeNodeIconHeight); this.nodeIcon.Width = new UIDim(0, DefaultTreeNodeIconHeight); this.nodeText.TextFormat = DrawTextFormat.Left | DrawTextFormat.VerticalCenter | DrawTextFormat.NoClip; this.nodeText.Height = new UIDim(0, DefaultTreeNodeTextHeight); this.nodeText.Width = new UIDim(0, DefaultTreeNodeTextHeight); this.nodeText.TextChanged += new EventHandler <GUIEventArgs>(nodeText_TextChanged); this.nodeText.Text = "Tree Item"; CacheOwnerData(); }
protected UIComp_TreeNodeBase(Window owner, UIComp_TreeNodeBase parent) : base(owner) { this.parentNode = parent; }
} //default ctor not valid - we want to enforce initializing our data protected UIComp_TreeNodeBase(Window owner) : base(owner) { this.parentNode = null; }