public DirectoryNode(String directory, FileBrowserTree projectExplorer)
 {
     this.projectExplorer = projectExplorer;
     this.ImageResource   = "EditorFileIcon/FolderIcon";
     ListedChildren       = false;
     changePath(directory);
 }
Exemple #2
0
        public ProjectExplorer(EditorController editorController, TypeControllerManager typeControllerManager)
            : base("Medical.GUI.ProjectExplorer.ProjectExplorer.layout")
        {
            this.editorController            = editorController;
            editorController.ProjectChanged += editorController_ProjectChanged;
            this.typeControllerManager       = typeControllerManager;
            typeControllerManager.FilesystemWatcherCreated   += typeControllerManager_FilesystemWatcherCreated;
            typeControllerManager.FilesystemWatcherDisposing += typeControllerManager_FilesystemWatcherDisposing;

            windowTitle = window.Caption;
            menuBar     = window.findWidget("MenuBar") as MenuBar;

            fileBrowser = new FileBrowserTree((ScrollView)window.findWidget("FileTableScroll"));
            fileBrowser.FileSelected     += new FileBrowserEvent(fileBrowser_FileSelected);
            fileBrowser.NodeContextEvent += new FileBrowserNodeContextEvent(fileBrowser_NodeContextEvent);

            //File Menu
            MenuItem    fileMenuItem = menuBar.addItem("File", MenuItemType.Popup);
            MenuControl fileMenu     = menuBar.createItemPopupMenuChild(fileMenuItem);

            fileMenu.ItemAccept += new MyGUIEvent(fileMenu_ItemAccept);
            newProject           = fileMenu.addItem("New Project");
            openProject          = fileMenu.addItem("Open Project");
            closeProject         = fileMenu.addItem("Close Project");
            saveAll              = fileMenu.addItem("Save All");

            this.Resized += new EventHandler(ProjectExplorer_Resized);
        }
Exemple #3
0
        void fileBrowser_NodeContextEvent(FileBrowserTree tree, string path, bool isDirectory, bool isTopLevel)
        {
            ContextMenu contextMenu = new ContextMenu();

            if (isDirectory)
            {
                contextMenu.add(new ContextMenuItem("Create Directory", path, delegate(ContextMenuItem item)
                {
                    InputBox.GetInput("Directory Name", "Please enter a name for the directory.", true, delegate(String result, ref String errorPrompt)
                    {
                        editorController.ResourceProvider.createDirectory(item.UserObject.ToString(), result);
                        return(true);
                    });
                }));

                contextMenu.add(new ContextMenuItem("Add Item", path, delegate(ContextMenuItem item)
                {
                    AddItemDialog.AddItem(editorController.ItemTemplates, (itemTemplate) =>
                    {
                        try
                        {
                            ((ProjectItemTemplate)itemTemplate).createItem(path, editorController);
                        }
                        catch (Exception e)
                        {
                            MessageBox.show(String.Format("Error creating item.\n{0}", e.Message), "Error Creating Item", MessageBoxStyle.IconError | MessageBoxStyle.Ok);
                        }
                    });
                }));

                contextMenu.add(new ContextMenuItem("Import Files", path, delegate(ContextMenuItem item)
                {
                    FileOpenDialog fileDialog = new FileOpenDialog(MainWindow.Instance, "Choose files to import.", "", "", "", true);
                    fileDialog.showModal((result, paths) =>
                    {
                        if (result == NativeDialogResult.OK)
                        {
                            editorController.importFiles(paths, item.UserObject.ToString());
                        }
                    });
                }));

                contextMenu.add(new ContextMenuItem("Explore To", path, item =>
                {
                    OtherProcessManager.openLocalURL(editorController.ResourceProvider.getFullFilePath(item.UserObject.ToString()));
                }));
            }
            if (!isTopLevel)
            {
                contextMenu.add(new ContextMenuItem("Rename", path, delegate(ContextMenuItem item)
                {
                    InputBox.GetInput("Rename", String.Format("Please enter a new name for {0}.", item.UserObject.ToString()), true, delegate(String result, ref String errorPrompt)
                    {
                        String originalExtension = Path.GetExtension(item.UserObject.ToString());
                        String targetName        = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(item.UserObject.ToString()), result), originalExtension);
                        if (editorController.ResourceProvider.exists(targetName))
                        {
                            errorPrompt = String.Format("A file named {0} already exists. Please enter another name.", targetName);
                            return(false);
                        }

                        editorController.ResourceProvider.move(path, targetName);
                        return(true);
                    });
                }));
                contextMenu.add(new ContextMenuItem("Delete", path, delegate(ContextMenuItem item)
                {
                    MessageBox.show(String.Format("Are you sure you want to delete {0}?", item.UserObject.ToString()), "Delete?", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, delegate(MessageBoxStyle result)
                    {
                        if (result == MessageBoxStyle.Yes)
                        {
                            editorController.ResourceProvider.delete(item.UserObject.ToString());
                        }
                    });
                }));
            }
            tree.showContextMenu(contextMenu);
        }
Exemple #4
0
 void fileBrowser_FileSelected(FileBrowserTree tree, string path)
 {
     editorController.openEditor(path);
 }