/// <summary> /// ���ڵ��ƶ���aiParent���� /// </summary> /// <param name="aiParent"></param> public void Move(AiTreeNode aiParent) { AiTreeNode parent = Parent as AiTreeNode; // �������Ǹ��ڵ㣬���� if (parent == aiParent) return; // �Լ���aiParent·���ϵ����Ƚڵ㣬���� AiTreeNode destParent = aiParent as AiTreeNode; while (destParent != null) { if (destParent == this) return; destParent = destParent.Parent as AiTreeNode; } parent.AiNodes.AiRemove(Name, false); aiParent.AiNodes.AiAdd(this); }
private void treeView_BTree_DragOver(object sender, DragEventArgs e) { if (dragMoveNode != null) dragMoveNode.BackColor = Color.White; Point point = ((AiTreeView)sender).PointToClient(new Point(e.X, e.Y)); AiTreeNode moveNode = (AiTreeNode)((AiTreeView)sender).GetNodeAt(point); moveNode.BackColor = Color.Gray; dragMoveNode = moveNode; }
private void treeView_BTree_DragDrop(object sender, DragEventArgs e) { AiTreeNode treeNode;; if (e.Data.GetDataPresent(typeof(AiTreeNode))) { // �Ϸŵ�Ŀ��ڵ� AiTreeNode targetTreeNode; // ��ȡ��ǰ������������� // ����һ��λ�õ�ı��������浱ǰ�������������� Point point = ((AiTreeView)sender).PointToClient(new Point(e.X, e.Y)); // ���������ȡ�ô��������λ�õĽڵ� targetTreeNode = (AiTreeNode)((AiTreeView)sender).GetNodeAt(point); // ��ȡ���϶��Ľڵ� treeNode = (AiTreeNode)e.Data.GetData(typeof(AiTreeNode)); // �ж��϶��Ľڵ���Ŀ��ڵ��Ƿ���ͬһ��,ͬһ�����账�� if (treeNode.Name != targetTreeNode.Name) { treeNode.Move(targetTreeNode); targetTreeNode.ExpandAll(); } } if (dragMoveNode != null) dragMoveNode.BackColor = Color.White; dragMoveNode = null; }
private void selectedNodeChange(AiTreeNode newSelected) { if (newSelected != null) { �½��ڵ�ToolStripMenuItem.Text = "�½��ڵ�"; �滻�ڵ�ToolStripMenuItem.Enabled = true; ɾ���ڵ�ToolStripMenuItem.Enabled = true; ���ƽڵ�ToolStripMenuItem.Enabled = true; ���ƽڵ�ToolStripMenuItem.Enabled = true; } else { �½��ڵ�ToolStripMenuItem.Text = "�½����ڵ�"; �滻�ڵ�ToolStripMenuItem.Enabled = false; ɾ���ڵ�ToolStripMenuItem.Enabled = false; ���ƽڵ�ToolStripMenuItem.Enabled = false; ���ƽڵ�ToolStripMenuItem.Enabled = false; } // if (newSelected == selectedNode) // return; selectedNode = newSelected; if (selectedNode != null) { propertyGrid1.SelectedObject = newSelected.LogicNode.Props; if (newSelected.LogicNode.TreeNode != null) propertyGrid1.SelectedObject = selectedNode.LogicNode.TreeNode.Props; selectedNode.ExpandAll(); } else { propertyGrid1.SelectedObject = null; } propertyGrid1.ExpandAllGridItems(); propertyGrid1.Refresh(); }
public void Remove(string key) { if (key == AiRoot.LogicNode.Props.Key) AiRoot = null; else AiRoot.AiNodes.AiRemove(key, true); }
public void RootReplace(PBNodeType nodeType) { TreeProperties treeProps = AiRoot.LogicNode.TreeNode.Props; AiTreeNode newRoot = AiTreeNodeCollection.AiReplace(AiRoot, nodeType); aiRoot = newRoot; aiRoot.LogicNode.TreeNode = new NodeDef.Tree(aiRoot.LogicNode, treeProps); }
public void Clear() { aiRoot = null; base.Nodes.Clear(); }
public void LoadProtoBuf(string path) { Clear(); PBTree tree; using (FileStream file = File.OpenRead(path)) { tree = Serializer.Deserialize<PBTree>(file); } Node.sIDMax = 0; AiRoot = AiTreeNodeCollection.AiNew(tree.root.type); AiRoot.LogicNode.Props.LoadProtoBuf(tree.root); AiRoot.LogicNode.TreeNode.Props.LoadProtoBuf(tree); AiRoot.AiNodes.LoadProtoBuf(tree.root); // �ָ��ϴ����node id Node.sIDCounter = Node.sIDMax; Refresh(); }
public void AiUpPos(AiTreeNode node) { int pos = nodes.IndexOf(node); if (pos == 0) return; nodes.RemoveAt(pos); nodes.Insert(pos - 1, node); }
public void AiDownPos(AiTreeNode node) { int pos = nodes.IndexOf(node); if (pos == nodes.Count - 1) return; nodes.RemoveAt(pos); nodes.Insert(pos + 1, node); }
public AiTreeNode AiAdd(AiTreeNode node) { nodes.Add(node); return node; }
public static AiTreeNode AiReplace(AiTreeNode node, PBNodeType nodeType) { node.LogicNode = NodeFactory.CreateInstance(nodeType); node.Refresh(); return node; }
public static AiTreeNode AiNew(PBNodeType nodeType) { AiTreeNode aiNewNode = new AiTreeNode(NodeFactory.CreateInstance(nodeType)); aiNewNode.Refresh(); return aiNewNode; }