Example #1
0
        //(角色文件夹列表)删除单元
        public void deleteActorFolder()
        {
            if (currentActorFolder == null)
            {
                return;
            }
            if (!MessageBox.Show("确定删除角色文件夹 [" + currentActorFolder.name + "]?", "删除角色文件夹", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes))
            {
                return;
            }
            form_MA.historyManager.ReadyHistory(HistoryType.Actor);
            //先删除文件夹中的内容
            while (currentActorFolder.Count() > 0)
            {
                currentActorFolder.RemoveAt(0);
            }
            int index = currentActorFolder.GetID();

            if (actorsManager.RemoveAt(index))
            {
                updateTreeView_Animation();
                int newIndex = index - 1;
                if (newIndex < 0 && actorsManager.Count() > 0)
                {
                    newIndex = 0;
                }
                setCurrentActorFolder(newIndex, true, 0);
            }
            form_MA.historyManager.AddHistory(HistoryType.Actor);
        }
Example #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);
            }
        }