Exemple #1
0
        public void deleteSelectedNode()
        {
            Invoke(new NoArgFunction(() =>
            {
                TreeNode node = FileTree.SelectedNode;
                if (node != null && node is LibraryTreeNode)
                {
                    LibraryTreeNode libNode = (LibraryTreeNode)node;

                    DialogResult confirmResult = MessageBox.Show("Are you sure you want to delete this?",
                                                                 "Delete Confirmation",
                                                                 MessageBoxButtons.YesNo,
                                                                 MessageBoxIcon.Warning,
                                                                 MessageBoxDefaultButton.Button2);


                    if (confirmResult == DialogResult.Yes)
                    {
                        try
                        {
                            FileDescriptor fDesc = FileManager.Instance.lookUpFileByPath <FileDescriptor>(libNode.FilePath);
                            fireDeleteFileEvent(new PropertyChangeRequestEventArgs(fDesc));
                            FileManager.Instance.removeFileDescriptor(fDesc);
                        }
                        catch (WhiskeyException e)
                        {
                        }
                        FileTree.Nodes.Remove(libNode);
                    }
                }
            }));
        }
Exemple #2
0
        public void populate()
        {
            string[] filePaths = Directory.GetFiles(FilePath);
            foreach (string path in filePaths)
            {
                LibraryTreeNode node = new LibraryTreeNode(getFileNameWithoutExtension(path), clearExtraSlashes(path));

                if (path.EndsWith(".mgfx"))
                {
                    continue;
                }

                int index = AssetManager.indexOf(AssetManager.FILE_ICON_FILE);
                if (path.EndsWith(".state"))
                {
                    index = AssetManager.indexOf(AssetManager.FILE_ICON_FILE_LEVEL);
                }
                if (path.EndsWith(".cs"))
                {
                    index = AssetManager.indexOf(AssetManager.FILE_ICON_FILE_TYPE);

                    if (path.ToLower().StartsWith(WhiskeyEditor.Backend.Managers.ProjectManager.Instance.ActiveProject.PathSrcScripts.ToLower()) || path.StartsWith(WhiskeyEditor.compile_types.CoreTypes.corePathScripts))
                    {
                        index = AssetManager.indexOf(AssetManager.FILE_ICON_FILE_SCRIPT);
                    }
                }
                if (path.EndsWith(".png"))
                {
                    index = AssetManager.indexOf(AssetManager.FILE_ICON_FILE_PICTURE);
                }

                node.ImageIndex         = index;
                node.SelectedImageIndex = index;

                node.IsFile = true;
                Nodes.Add(node);
            }

            string[] dirPaths = Directory.GetDirectories(FilePath);
            foreach (string dir in dirPaths)
            {
                LibraryTreeNode node = new LibraryTreeNode(getFileName(dir), dir);
                node.IsFile             = false;
                node.ImageIndex         = AssetManager.indexOf(AssetManager.FILE_ICON_FLDR);
                node.SelectedImageIndex = AssetManager.indexOf(AssetManager.FILE_ICON_FLDR);;

                Nodes.Add(node);
                node.populate();
            }
        }
Exemple #3
0
        private void configureControls()
        {
            FileTree.NodeMouseDoubleClick += (s, a) =>
            {
                LibraryTreeNode node = (LibraryTreeNode)a.Node;
                if (node.IsFile)
                {
                    SelectionChanged(this, new LibrarySelectionEventArgs(node));
                }
            };

            FileTree.NodeMouseClick += (s, a) =>
            {
                LibraryTreeNode node = (LibraryTreeNode)a.Node;
                if (node.IsFile && a.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    ClickedOnNode(this, new LibrarySelectionEventArgs(node));
                }

                if (a.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    FileTree.SelectedNode = a.Node;
                    if (node.IsFile)
                    {
                        fileNodeMenu.Width = 300;
                        fileNodeMenu.Show(this, a.Location, ToolStripDropDownDirection.Right);
                    }
                    else
                    {
                        string path = node.FilePath.Replace(ProjectManager.Instance.ActiveProject.PathBase, "");
                        setPathOfActions(path);
                        folderNodeMenu.Show(this, a.Location, ToolStripDropDownDirection.Right);
                    }
                }
            };
        }
Exemple #4
0
 public LibrarySelectionEventArgs(LibraryTreeNode node)
 {
     Selected = node;
 }
Exemple #5
0
        public void refreshContent()
        {
            if (this.IsHandleCreated)
            {
                this.Invoke(new NoArgFunction(() =>
                {
                    FileTree.Nodes.Clear();

                    Project p = ProjectManager.Instance.ActiveProject;

                    LibraryTreeNode root = new LibraryTreeNode(p.Name, p.PathBase);

                    //PROPERTIES
                    LibraryTreeNode nodeProp    = new LibraryTreeNode("Properties", p.FileSettingsPath, true);
                    nodeProp.ImageIndex         = AssetManager.indexOf(AssetManager.FILE_ICON_FILE);
                    nodeProp.SelectedImageIndex = AssetManager.indexOf(AssetManager.FILE_ICON_FILE);
                    root.Nodes.Add(nodeProp);

                    //SOURCE-Objects
                    LibraryTreeNode nodeObjects = new LibraryTreeNode("Objects", p.PathSrcObjects);
                    nodeObjects.populate();
                    root.Nodes.Add(nodeObjects);

                    //SOURCE-Scripts
                    LibraryTreeNode nodeScripts = new LibraryTreeNode("Scripts", p.PathSrcScripts);
                    nodeScripts.populate();
                    root.Nodes.Add(nodeScripts);

                    //LEVELS
                    LibraryTreeNode nodeLvl = new LibraryTreeNode("Levels", p.PathStates);
                    nodeLvl.populate();
                    root.Nodes.Add(nodeLvl);

                    //MEDIA
                    LibraryTreeNode nodeArt = new LibraryTreeNode("Media", p.PathMedia);
                    nodeArt.populate();
                    root.Nodes.Add(nodeArt);

                    //CORE-TYPES

                    LibraryTreeNode nodeCoreTypes = new LibraryTreeNode("Shared Objects", WhiskeyEditor.compile_types.CoreTypes.corePathTypes);
                    nodeCoreTypes.populate();
                    root.Nodes.Add(nodeCoreTypes);

                    LibraryTreeNode nodeCoreScripts = new LibraryTreeNode("Shared Scripts", WhiskeyEditor.compile_types.CoreTypes.corePathScripts);
                    nodeCoreScripts.populate();
                    root.Nodes.Add(nodeCoreScripts);

                    FileTree.Nodes.Add(root);


                    //open everything
                    root.ExpandAll();

                    //close common scripts
                    // nodeCoreScripts.Collapse();


                    //fileTree.Update();
                }));
            }
            else
            {
                this.HandleCreated += (s, a) => { refreshContent(); };
            }
        }