Example #1
0
 private void MoveNode(TreeNode from, TreeNode to)
 {
     if (from is Skin && to is Skin)
         MoveNode(from, to.GetParentCollection(), to);
     else if (from is Skin && to is FolderNode)
         MoveNode(from, to.Nodes, to);
     else if (from is FolderNode && to is Skin)
         MoveNode(from, to.GetParentCollection(), to);
     else if (from is FolderNode && to is FolderNode)
         MoveNode(from, to.Nodes, to);
     else if ((from is Skin || from is FolderNode) && to == null)
         MoveNode(from, Nodes, to);
 }
Example #2
0
        private void ImportSkin(string fileName, string folderLocation, TreeNode parentNode)
        {
            string name = Path.GetFileNameWithoutExtension(fileName);

            while (File.Exists(folderLocation + name + ".png"))
                name += " (New)";

            File.Copy(fileName, folderLocation + name + ".png");

            var skin = new Skin(folderLocation + name + ".png");

            if (parentNode != null)
            {
                if (!(parentNode is Skin))
                    parentNode.Nodes.Add(skin);
                else
                    parentNode.GetParentCollection().Add(skin);
            }
            else
                treeView1.Nodes.Add(skin);

            skin.SetImages();
            treeView1.SelectedNode = skin;
        }
Example #3
0
        private bool DropValid(TreeNode node, TreeNode selectedNode)
        {
            if (selectedNode == null && !Editor.HasOneRoot)
                return false;
            else if (node is Skin && selectedNode is Skin)
            {
                if (node.GetParentCollection() == selectedNode.GetParentCollection())
                    return false;
            }
            else if (node is Skin && selectedNode is FolderNode)
            {
                if (node.Parent == selectedNode)
                    return false;
            }
            else if (node is FolderNode && selectedNode is Skin)
            {
                if (selectedNode.GetNodeChain().Contains(node))
                    return false;
            }
            else if (node is FolderNode && selectedNode is FolderNode)
            {
                if (selectedNode.GetNodeChain().Contains(node))
                    return false;
            }
            else if ((node is Skin || node is FolderNode) && selectedNode == null)
            {
                if (node.Parent == null)
                    return false;
            }

            return true;
        }