コード例 #1
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
        private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
        {
            var directoryNode = new TreeNodeEx();

            directoryNode.Text    = directoryInfo.Name;
            directoryNode.NodeKey = "dafdsfsueru34324234890f";
            foreach (var directory in directoryInfo.GetDirectories())
            {
                directoryNode.Nodes.Add(CreateDirectoryNode(directory));
            }
            foreach (var file in directoryInfo.GetFiles())
            {
                string name = file.Name;
                string key  = file.Name;

                int index = 1;
                if (fentrys.ContainsKey(file.Name))
                {
                    while (true)
                    {
                        if (fentrys.ContainsKey(file.Name + index.ToString()))
                        {
                            index++;
                        }
                        else
                        {
                            key = file.Name + index;
                            break;
                        }
                    }
                }
                if (entrys.ContainsKey(file.Name))
                {
                    while (true)
                    {
                        if (entrys.ContainsKey(file.Name + index.ToString()))
                        {
                            index++;
                        }
                        else
                        {
                            key = file.Name + index;
                            break;
                        }
                    }
                }
                fentrys.Add(key, file.FullName);

                TreeNodeEx n = new TreeNodeEx();
                n.NodeKey = key;
                n.Text    = name;

                directoryNode.Nodes.Add(n);
            }
            return(directoryNode);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
 TreeNodeEx getKey(TreeNodeEx parent, string text)
 {
     if (parent == null)
     {
         return(null);
     }
     foreach (TreeNodeEx c in parent.Nodes)
     {
         if (c.NodeKey == text)
         {
             return(c);
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] fl = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            foreach (var pathe in fl)
            {
                string g = pathe.Split('\\').Last();
                g = g.Replace(".smod", "");
                g = g.Replace(".zip", "");


                if (pathe.Contains(".smod") || pathe.Contains(".zip"))
                {
                    TreeNodeEx n = new TreeNodeEx();
                    n.Text    = g;
                    n.NodeKey = g;

                    treeView1.Nodes.Add(n);
                    ZipFile f = new ZipFile(pathe);

                    foreach (var c in f.Entries)
                    {
                        string[]      p    = c.FileName.Split('/');
                        List <string> path = p.ToList();

                        for (int i = path.Count - 1; i > 0; i--)
                        {
                            if (path[i] == "" || path[i] == "/" || path[i] == "Thumbs.db")
                            {
                                path.RemoveAt(i);
                            }
                        }

                        string key = "";

                        if (!c.IsDirectory)
                        {
                            if (entrys.ContainsKey(path.Last()))
                            {
                                int index = 1;
                                while (true)
                                {
                                    if (entrys.ContainsKey(path.Last() + index.ToString()))
                                    {
                                        index++;
                                    }
                                    else
                                    {
                                        key = path.Last() + index;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                entrys.Add(path.Last(), c);
                            }
                        }
                        TreeNodeEx parent = null;
                        for (int i = 0; i < path.Count; i++)
                        {
                            if (i == 0)
                            {
                                TreeNodeEx ex = gettoplevelkey(path[i]);
                                if (ex != null)
                                {
                                    parent = ex;
                                }
                            }
                            else
                            {
                                TreeNodeEx ex = getKey(parent, path[i]);
                                if (ex != null)
                                {
                                    parent = ex;
                                }
                            }
                        }

                        TreeNodeEx newnode = new TreeNodeEx();
                        newnode.Text    = path.Last();
                        newnode.NodeKey = !string.IsNullOrEmpty(key) ? key : path.Last();

                        parent.Nodes.Add(newnode);
                    }
                }
                else if (pathe.Contains(".lua"))
                {
                    string[] path  = pathe.Split('\\');
                    string   key   = "";
                    int      index = 1;
                    if (fentrys.ContainsKey(path.Last()))
                    {
                        while (true)
                        {
                            if (fentrys.ContainsKey(path.Last() + index.ToString()))
                            {
                                index++;
                            }
                            else
                            {
                                key = path.Last() + index;
                                break;
                            }
                        }
                    }
                    if (entrys.ContainsKey(path.Last()))
                    {
                        while (true)
                        {
                            if (entrys.ContainsKey(path.Last() + index.ToString()))
                            {
                                index++;
                            }
                            else
                            {
                                key = path.Last() + index;
                                break;
                            }
                        }
                    }
                    fentrys.Add(path.Last(), pathe);

                    TreeNodeEx parent = null;
                    for (int i = 0; i < path.Length; i++)
                    {
                        if (i == 0)
                        {
                            TreeNodeEx ex = gettoplevelkey(path[i]);
                            if (ex != null)
                            {
                                parent = ex;
                            }
                        }
                        else
                        {
                            TreeNodeEx ex = getKey(parent, path[i]);
                            if (ex != null)
                            {
                                parent = ex;
                            }
                        }
                    }

                    TreeNodeEx newnode = new TreeNodeEx();
                    newnode.Text    = path.Last();
                    newnode.NodeKey = !string.IsNullOrEmpty(key) ? key : path.Last();

                    if (parent != null)
                    {
                        parent.Nodes.Add(newnode);
                    }
                    else
                    {
                        this.treeView1.Nodes.Add(newnode);
                    }
                }
                else if (Directory.Exists(pathe))
                {
                    ListDirectory(this.treeView1, pathe);
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog t = new OpenFileDialog();

            t.Multiselect = true;
            var result = t.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                foreach (var ctt in t.FileNames)
                {
                    string g = ctt.Split('\\').Last();
                    g = g.Replace(".smod", "");
                    g = g.Replace(".zip", "");


                    if (ctt.Contains(".smod") || ctt.Contains(".zip"))
                    {
                        ZipFile    f = new ZipFile(ctt);
                        TreeNodeEx n = new TreeNodeEx();
                        n.Text    = g;
                        n.NodeKey = g;

                        treeView1.Nodes.Add(n);

                        foreach (var c in f.Entries)
                        {
                            string[]      p    = c.FileName.Split('/');
                            List <string> path = p.ToList();

                            for (int i = path.Count - 1; i > 0; i--)
                            {
                                if (path[i] == "" || path[i] == "/" || path[i] == "Thumbs.db")
                                {
                                    path.RemoveAt(i);
                                }
                            }

                            string key = "";

                            if (!c.IsDirectory)
                            {
                                if (entrys.ContainsKey(path.Last()))
                                {
                                    int index = 1;
                                    while (true)
                                    {
                                        if (path.Last() == "manifest.json")
                                        {
                                            int fff = 0;
                                        }
                                        if (entrys.ContainsKey(path.Last() + index.ToString()))
                                        {
                                            index++;
                                        }
                                        else
                                        {
                                            key = path.Last() + index;
                                            entrys.Add(key, c);
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    entrys.Add(path.Last(), c);
                                }
                            }
                            TreeNodeEx parent = null;
                            for (int i = 0; i < path.Count; i++)
                            {
                                if (i == 0)
                                {
                                    TreeNodeEx ex = gettoplevelkey(path[i]);
                                    if (ex != null)
                                    {
                                        parent = ex;
                                    }
                                }
                                else
                                {
                                    TreeNodeEx ex = getKey(parent, path[i]);
                                    if (ex != null)
                                    {
                                        parent = ex;
                                    }
                                }
                            }

                            TreeNodeEx newnode = new TreeNodeEx();
                            newnode.Text    = path.Last();
                            newnode.NodeKey = !string.IsNullOrEmpty(key) ? key : path.Last();

                            parent.Nodes.Add(newnode);
                        }
                    }
                    else if (ctt.Contains(".lua"))
                    {
                        string[] path  = ctt.Split('\\');
                        string   key   = "";
                        int      index = 1;
                        if (fentrys.ContainsKey(path.Last()))
                        {
                            while (true)
                            {
                                if (fentrys.ContainsKey(path.Last() + index.ToString()))
                                {
                                    index++;
                                }
                                else
                                {
                                    key = path.Last() + index;
                                    break;
                                }
                            }
                        }
                        if (entrys.ContainsKey(path.Last()))
                        {
                            while (true)
                            {
                                if (entrys.ContainsKey(path.Last() + index.ToString()))
                                {
                                    index++;
                                }
                                else
                                {
                                    key = path.Last() + index;
                                    break;
                                }
                            }
                        }
                        fentrys.Add(path.Last(), ctt);

                        TreeNodeEx parent = null;
                        for (int i = 0; i < path.Length; i++)
                        {
                            if (i == 0)
                            {
                                TreeNodeEx ex = gettoplevelkey(path[i]);
                                if (ex != null)
                                {
                                    parent = ex;
                                }
                            }
                            else
                            {
                                TreeNodeEx ex = getKey(parent, path[i]);
                                if (ex != null)
                                {
                                    parent = ex;
                                }
                            }
                        }

                        TreeNodeEx newnode = new TreeNodeEx();
                        newnode.Text    = path.Last();
                        newnode.NodeKey = !string.IsNullOrEmpty(key) ? key : path.Last();

                        if (parent != null)
                        {
                            parent.Nodes.Add(newnode);
                        }
                        else
                        {
                            this.treeView1.Nodes.Add(newnode);
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
 int getindexof(TreeNodeEx parentnode, string text)
 {
     return(parentnode.Nodes.IndexOfKey(text));
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: Tarasmetal/lua-unminifier
 bool has(TreeNodeEx parentnode, string text)
 {
     return(parentnode.Nodes.IndexOfKey(text) > -1);
 }