Beispiel #1
0
        private static DirectoryNode CreateDirectoryNodeAndOpenSubNodes(string folderPath)
        {
            var mainNode = new DirectoryNode(folderPath);

            mainNode.Open();
            mainNode.Expand();
            return(mainNode);
        }
        public static DirectoryNode CreateDirectoryNodeAndExpand(string folderPath)
        {
            // Create the node and add child nodes.
            var mainNode = new DirectoryNode(folderPath);

            mainNode.Open();
            mainNode.Expand();
            return(mainNode);
        }
Beispiel #3
0
        /// <summary>
        /// Loads a directory and all sub-directories into the filetree.
        /// </summary>
        /// <param name="folderPath"></param>
        private void LoadWorkspace(string folderPath)
        {
            var mainNode = new DirectoryNode(folderPath);

            mainNode.Open();
            fileTree.Nodes.Add(mainNode);

            mainNode.Expand();

            // Enable rendering of the model if we have directly selected a model file.
            // Nested ones won't render a model
            foreach (var node in mainNode.Nodes)
            {
                if ((node as FileNode)?.Text?.EndsWith("numdlb") == true)
                {
                    fileTree.SelectedNode = node as FileNode;
                }
            }
        }
Beispiel #4
0
    public void Load(string directoryPath)
    {
        if (Directory.Exists(directoryPath) == false)
        {
            throw new DirectoryNotFoundException("Directory Not Found");
        }

        _systemIcons.Clear();
        _imageList.Images.Clear();
        Nodes.Clear();

        //Icon folderIcon = new Icon(typeof(FileSystemTreeView), "icons.folder.ico");
        Icon folderIcon = CodeYogi.Properties.Resources._folder;

        _imageList.Images.Add(folderIcon);
        _systemIcons.Add(FileSystemTreeView.Folder, 0);

        DirectoryNode node = new DirectoryNode(this, new DirectoryInfo(directoryPath));

        node.Expand();
    }
Beispiel #5
0
        /// <summary>
        /// Loads a directory and all sub-directories into the filetree.
        /// </summary>
        /// <param name="folderPath"></param>
        private void LoadWorkspace(string folderPath)
        {
            var mainNode = new DirectoryNode(folderPath);

            mainNode.Open();
            fileTree.Nodes.Add(mainNode);

            mainNode.Expand();

            // Enable rendering of the model if we have directly selected a model file.
            // Nested ones won't render a model
            SkelNode skelNode = null;

            foreach (FileNode node in mainNode.Nodes)
            {
                if (node.Text?.EndsWith("numdlb") == true)
                {
                    fileTree.SelectedNode = node as FileNode;
                }
                else if (skelNode == null && node is SkelNode)
                {
                    skelNode = node as SkelNode;
                }
            }
            if (skelNode == null)
            {
                return;
            }
            foreach (FileNode node in mainNode.Nodes)
            {
                if (node is ScriptNode scriptNode)
                {
                    scriptNode.SkelNode      = skelNode;
                    modelViewport.ScriptNode = scriptNode;
                    //only do this once, there should only be one anyway
                    break;
                }
            }
            ParamNodeContainer.SkelNode = skelNode;
        }
Beispiel #6
0
        private void InitialiseViews()
        {
            AppDelegate appDelegate = NSApplication.SharedApplication.Delegate as AppDelegate;

            appDelegate.OpenConnectionMenuITem.Hidden = true;
            try
            {
                if (serverNode.IsLoggedIn)
                {
                    InitialiseDefaultOutlineView();
                    var indx = server.FindIndex(x => string.Equals(x.Server, serverNode.Server));
                    if (indx >= 0)
                    {
                        server.RemoveAt(indx);
                    }
                    VMDirSnapInEnvironment.Instance.LocalData.AddServer(serverNode);
                    DirectoryNode baseNode = new DirectoryNode(serverNode.BaseDN, new List <string>()
                    {
                        string.Empty
                    }, serverNode, null);
                    baseNode.IsBaseNode   = true;
                    outlineViewDataSource = new OutlineViewDataSource(baseNode);
                    splitViewController.VmdirOutlineView.DataSource = outlineViewDataSource;
                    baseNode.Expand(serverNode.BaseDN);
                    SetToolBarState(true);
                    InitialiseDefaultTableView();
                    StatusLabel.StringValue = "Logged in : " + serverNode.BindDN;
                }
                else
                {
                    UIErrorHelper.ShowAlert(VMDirConstants.ERR_LOGIN_FAILED, "Login not successful!");
                }
            }
            catch (Exception e)
            {
                CloseConnection();
                UIErrorHelper.ShowAlert(e.Message, "Login not successful!");
            }
        }
        public override void Run()
        {
            TreeNode      selectedNode = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedNode;
            DirectoryNode node         = null;

            while (selectedNode != null && node == null)
            {
                node         = selectedNode as DirectoryNode;
                selectedNode = selectedNode.Parent;
            }
            if (node == null)
            {
                return;
            }
            node.Expand();
            node.Expanding();

            using (NewFileDialog nfd = new NewFileDialog(node.Directory)) {
                if (nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    bool additionalProperties = false;
                    foreach (KeyValuePair <string, FileDescriptionTemplate> createdFile in nfd.CreatedFiles)
                    {
                        FileProjectItem item = CreateNewFile(node, createdFile.Key);

                        if (createdFile.Value.SetProjectItemProperties(item))
                        {
                            additionalProperties = true;
                        }
                    }
                    if (additionalProperties)
                    {
                        node.Project.Save();
                        node.RecreateSubNodes();
                    }
                }
            }
        }
Beispiel #8
0
        protected IEnumerable <FileProjectItem> AddNewItems()
        {
            DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;

            if (node == null)
            {
                return(null);
            }
            node.Expand();
            node.Expanding();

            FileTemplateResult result = SD.UIService.ShowNewFileDialog(node.Project, node.Directory);

            if (result != null)
            {
                node.RecreateSubNodes();
                return(result.NewFiles.Select(node.Project.FindFile).Where(f => f != null).ToArray());
            }
            else
            {
                return(null);
            }
        }
        protected IEnumerable <FileProjectItem> AddNewItems()
        {
            DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;

            if (node == null)
            {
                return(null);
            }
            node.Expand();
            node.Expanding();

            List <FileProjectItem> addedItems = new List <FileProjectItem>();

            using (NewFileDialog nfd = new NewFileDialog(node.Directory)) {
                if (nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    bool additionalProperties = false;
                    foreach (KeyValuePair <string, FileDescriptionTemplate> createdFile in nfd.CreatedFiles)
                    {
                        FileProjectItem item = node.AddNewFile(createdFile.Key);
                        addedItems.Add(item);

                        if (createdFile.Value.SetProjectItemProperties(item))
                        {
                            additionalProperties = true;
                        }
                    }
                    if (additionalProperties)
                    {
                        node.Project.Save();
                        node.RecreateSubNodes();
                    }
                }
            }

            return(addedItems.AsReadOnly());
        }
        public override void Run()
        {
            ProjectBrowserPad.Instance.BringToFront();
            DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;

            if (node == null)
            {
                return;
            }
            node.Expanding();
            node.Expand();

            using (FolderBrowserDialog dlg = new FolderBrowserDialog()) {
                dlg.SelectedPath        = node.Directory;
                dlg.ShowNewFolderButton = false;
                if (dlg.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    string folderName       = dlg.SelectedPath;
                    string copiedFolderName = Path.Combine(node.Directory, Path.GetFileName(folderName));
                    if (!FileUtility.IsEqualFileName(folderName, copiedFolderName))
                    {
                        if (FileUtility.IsBaseDirectory(folderName, node.Directory))
                        {
                            MessageService.ShowError("Cannot copy " + folderName + " to " + copiedFolderName);
                            return;
                        }
                        if (Directory.Exists(copiedFolderName))
                        {
                            MessageService.ShowError("Cannot copy " + folderName + " to " + copiedFolderName + ": target already exists.");
                            return;
                        }
                        int res = MessageService.ShowCustomDialog(
                            "${res:ProjectComponent.ContextMenu.ExistingFolder}",
                            "${res:ProjectComponent.ContextMenu.ExistingFolder.CopyQuestion}",
                            0, 1,
                            "${res:ProjectComponent.ContextMenu.AddExistingFiles.Copy}",
                            "${res:Global.CancelButtonText}");
                        if (res != 0)
                        {
                            return;
                        }
                        if (!FileService.CopyFile(folderName, copiedFolderName, true, false))
                        {
                            return;
                        }
                    }
                    // ugly HACK to get IncludeDirectoryNode to work properly
                    AbstractProjectBrowserTreeNode.ShowAll = true;
                    try {
                        node.RecreateSubNodes();
                        DirectoryNode newNode = node.AllNodes.OfType <DirectoryNode>()
                                                .FirstOrDefault(dir => FileUtility.IsEqualFileName(copiedFolderName, dir.Directory));
                        if (newNode != null)
                        {
                            newNode.Expanding();
                            IncludeFileInProject.IncludeDirectoryNode(newNode, true);
                        }
                    } finally {
                        AbstractProjectBrowserTreeNode.ShowAll = false;
                    }
                    node.RecreateSubNodes();
                }
            }
        }
        protected IEnumerable <FileProjectItem> AddExistingItems()
        {
            DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;

            if (node == null)
            {
                return(null);
            }
            node.Expanding();
            node.Expand();

            List <FileProjectItem> addedItems = new List <FileProjectItem>();

            using (OpenFileDialog fdiag = new OpenFileDialog()) {
                fdiag.AddExtension = true;
                string[] fileFilters = (string[])(AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter").BuildChildItems(this)).ToArray(typeof(string));

                fdiag.InitialDirectory = node.Directory;
                fdiag.FilterIndex      = GetFileFilterIndex(node.Project, fileFilters);
                fdiag.Filter           = String.Join("|", fileFilters);
                fdiag.Multiselect      = true;
                fdiag.CheckFileExists  = true;
                fdiag.Title            = StringParser.Parse("${res:ProjectComponent.ContextMenu.AddExistingFiles}");

                if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    List <KeyValuePair <string, string> > fileNames = new List <KeyValuePair <string, string> >(fdiag.FileNames.Length);
                    foreach (string fileName in fdiag.FileNames)
                    {
                        fileNames.Add(new KeyValuePair <string, string>(fileName, ""));
                    }
                    bool addedDependentFiles = false;
                    foreach (string fileName in fdiag.FileNames)
                    {
                        foreach (string additionalFile in FindAdditionalFiles(fileName))
                        {
                            if (!fileNames.Exists(delegate(KeyValuePair <string, string> pair) {
                                return(FileUtility.IsEqualFileName(pair.Key, additionalFile));
                            }))
                            {
                                addedDependentFiles = true;
                                fileNames.Add(new KeyValuePair <string, string>(additionalFile, Path.GetFileName(fileName)));
                            }
                        }
                    }



                    string copiedFileName = Path.Combine(node.Directory, Path.GetFileName(fileNames[0].Key));
                    if (!FileUtility.IsEqualFileName(fileNames[0].Key, copiedFileName))
                    {
                        int res = MessageService.ShowCustomDialog(
                            fdiag.Title, "${res:ProjectComponent.ContextMenu.AddExistingFiles.Question}",
                            0, 2,
                            "${res:ProjectComponent.ContextMenu.AddExistingFiles.Copy}",
                            "${res:ProjectComponent.ContextMenu.AddExistingFiles.Link}",
                            "${res:Global.CancelButtonText}");
                        if (res == 1)
                        {
                            // Link
                            foreach (KeyValuePair <string, string> pair in fileNames)
                            {
                                string          fileName        = pair.Key;
                                string          relFileName     = FileUtility.GetRelativePath(node.Project.Directory, fileName);
                                FileNode        fileNode        = new FileNode(fileName, FileNodeStatus.InProject);
                                FileProjectItem fileProjectItem = new FileProjectItem(node.Project, node.Project.GetDefaultItemType(fileName), relFileName);
                                fileProjectItem.SetEvaluatedMetadata("Link", Path.Combine(node.RelativePath, Path.GetFileName(fileName)));
                                fileProjectItem.DependentUpon = pair.Value;
                                addedItems.Add(fileProjectItem);
                                fileNode.ProjectItem = fileProjectItem;
                                fileNode.InsertSorted(node);
                                ProjectService.AddProjectItem(node.Project, fileProjectItem);
                            }
                            node.Project.Save();
                            if (addedDependentFiles)
                            {
                                node.RecreateSubNodes();
                            }
                            return(addedItems.AsReadOnly());
                        }
                        if (res == 2)
                        {
                            // Cancel
                            return(addedItems.AsReadOnly());
                        }
                        // only continue for res==0 (Copy)
                    }
                    bool replaceAll = false;
                    foreach (KeyValuePair <string, string> pair in fileNames)
                    {
                        copiedFileName = Path.Combine(node.Directory, Path.GetFileName(pair.Key));
                        if (!replaceAll && File.Exists(copiedFileName) && !FileUtility.IsEqualFileName(pair.Key, copiedFileName))
                        {
                            ReplaceExistingFile res = ShowReplaceExistingFileDialog(fdiag.Title, Path.GetFileName(pair.Key), true);
                            if (res == ReplaceExistingFile.YesToAll)
                            {
                                replaceAll = true;
                            }
                            else if (res == ReplaceExistingFile.No)
                            {
                                continue;
                            }
                            else if (res == ReplaceExistingFile.Cancel)
                            {
                                break;
                            }
                        }
                        FileProjectItem item = CopyFile(pair.Key, node, true);
                        if (item != null)
                        {
                            addedItems.Add(item);
                            item.DependentUpon = pair.Value;
                        }
                    }
                    node.Project.Save();
                    if (addedDependentFiles)
                    {
                        node.RecreateSubNodes();
                    }
                }
            }

            return(addedItems.AsReadOnly());
        }
Beispiel #12
0
    public void AddDirectoryNode(string directoryPath, TreeNode node)
    {
        DirectoryNode _node = new DirectoryNode(node, new DirectoryInfo(directoryPath));

        _node.Expand();
    }
Beispiel #13
0
        /// <summary>
        /// Initialisiert den ExplorerTreeView; Falls dieser vorher schon einmal initialisiert wurde, wird die bisherige Anzeige gelöscht und der Baum mit den aktuellen Eigenschaften neu aufgebaut.
        /// </summary>
        public void InitTree()
        {
            if (de.coe.components.License.LicCheck.CheckKeyForRegKey(msLicense) != "48404A4F4D")
            {
                throw new Exception(Properties.Resources.LicInvalid);
            }
            else
            {
                moSystemIcons.Clear();
                moImageList.Images.Clear();
                Nodes.Clear();
                AddDefaultIcons();//Icons laden
                this.SelectedImageIndex = 7;
                //Hauptknoten erzeugen
                DirectoryNode soNode = new DirectoryNode(this, msRootName);
                //Laufwerke hinzufügen
                foreach (DriveInfo soInfo in DriveInfo.GetDrives())
                {
                    int  siIndex     = 6;
                    bool mbShowDrive = true;
                    switch (soInfo.DriveType)
                    {
                    case DriveType.Fixed:
                        siIndex = 2;
                        if (mbHideHdd == true)
                        {
                            mbShowDrive = false;
                        }
                        break;

                    case DriveType.Network:
                        siIndex = 3;
                        if (mbHideNetwork == true)
                        {
                            mbShowDrive = false;
                        }
                        break;

                    case DriveType.Removable:
                        if (soInfo.Name.Substring(0, 1) == "A" | soInfo.Name.Substring(0, 1) == "B")
                        {
                            siIndex = 1;
                            if (mbHideFloppy == true)
                            {
                                mbShowDrive = false;
                            }
                        }
                        else
                        {
                            siIndex = 4;
                        }
                        break;

                    case DriveType.CDRom:
                        siIndex = 5;
                        if (mbHideCDRom == true)
                        {
                            mbShowDrive = false;
                        }
                        break;
                    }
                    if (mbShowDrive == true)
                    {
                        DirectoryNode soDrive = new DirectoryNode(soNode, new DirectoryInfo(soInfo.Name), siIndex);
                    }
                }
                soNode.SelectedImageIndex = 7;
                soNode.Expand();
            }
        }