Пример #1
0
        /// <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);
        }
Пример #2
0
        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;
        }
Пример #3
0
        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;
        }
Пример #4
0
        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();
        }
Пример #5
0
 public void Remove(string key)
 {
     if (key == AiRoot.LogicNode.Props.Key)
         AiRoot = null;
     else
         AiRoot.AiNodes.AiRemove(key, true);
 }
Пример #6
0
 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);
 }
Пример #7
0
 public void Clear()
 {
     aiRoot = null;
     base.Nodes.Clear();
 }
Пример #8
0
        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();
        }
Пример #9
0
        public void AiUpPos(AiTreeNode node)
        {
            int pos = nodes.IndexOf(node);
            if (pos == 0)
                return;

            nodes.RemoveAt(pos);
            nodes.Insert(pos - 1, node);
        }
Пример #10
0
        public void AiDownPos(AiTreeNode node)
        {
            int pos = nodes.IndexOf(node);
            if (pos == nodes.Count - 1)
                return;

            nodes.RemoveAt(pos);
            nodes.Insert(pos + 1, node);
        }
Пример #11
0
 public AiTreeNode AiAdd(AiTreeNode node)
 {
     nodes.Add(node);
     return node;
 }
Пример #12
0
        public static AiTreeNode AiReplace(AiTreeNode node, PBNodeType nodeType)
        {
            node.LogicNode = NodeFactory.CreateInstance(nodeType);
            node.Refresh();

            return node;
        }
Пример #13
0
        public static AiTreeNode AiNew(PBNodeType nodeType)
        {
            AiTreeNode aiNewNode = new AiTreeNode(NodeFactory.CreateInstance(nodeType));
            aiNewNode.Refresh();

            return aiNewNode;
        }