Beispiel #1
0
        //角色列表部分==================================================================================================
        //(角色列表)加入新单元
        public void addActorElement()
        {
            if (currentActorFolder == null)
            {
                return;
            }
            String name = "角色" + currentActorFolder.Count();
            SmallDialog_WordEdit txtDialog = new SmallDialog_WordEdit("新建角色", name);

            txtDialog.ShowDialog();
            name = txtDialog.getValue();
            form_MA.historyManager.ReadyHistory(HistoryType.Actor);
            MActor element = new MActor(currentActorFolder);

            element.name = name;
            currentActorFolder.Add(element);
            updateTreeNode_ActorFolder();
            setCurrentActor(currentActorFolder.GetSonID(element), true, 1);
            form_MA.historyManager.AddHistory(HistoryType.Actor);
        }
Beispiel #2
0
        private void treeView_Animation_DragDrop(object sender, DragEventArgs e)
        {
            //得到拖放数据,并转换为TreeNode型
            TreeNode theNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
            TreeView theTree = (TreeView)sender;
            //得到鼠标进入TreeNode,而拖放目标targetNode
            TreeNode targetNode = theTree.GetNodeAt(treeView_Animation.PointToClient(new Point(e.X, e.Y)));

            if (targetNode != null && !targetNode.Equals(theNode.Parent) &&
                ((theNode.Level == 1 && targetNode.Level == 0) || (theNode.Level == 2 && targetNode.Level == 1)))
            {
                form_MA.historyManager.ReadyHistory(HistoryType.Actor);
                //先调整数据
                if (theNode.Level == 1)
                {
                    MActorFolder folderSrc  = (MActorFolder)actorsManager[theNode.Parent.Index];
                    MActor       actor      = folderSrc[theNode.Index];
                    MActorFolder folderDest = (MActorFolder)actorsManager[targetNode.Index];
                    folderSrc.RemoveAt(theNode.Index);
                    folderDest.Add(actor);
                }
                else if (theNode.Level == 2)
                {
                    MActorFolder folderSrc  = (MActorFolder)actorsManager[theNode.Parent.Parent.Index];
                    MActor       actorSrc   = folderSrc[theNode.Parent.Index];
                    MAction      actionSrc  = actorSrc[theNode.Index];
                    MActorFolder folderDest = (MActorFolder)actorsManager[targetNode.Parent.Index];
                    MActor       actorDest  = folderDest[targetNode.Index];
                    actorSrc.RemoveAt(theNode.Index);
                    actorDest.Add(actionSrc);
                }
                //调整UI
                TreeNode targetParent = targetNode.Parent;
                //删除拖放的TreeNode
                theNode.Remove();
                //添加到目标TreeView下
                targetNode.Nodes.Add(theNode);
                theTree.SelectedNode = targetNode;

                form_MA.historyManager.AddHistory(HistoryType.Actor);
            }
        }