/// <summary>
        /// Mets à jour l'arbre avec les éléments du projet.
        /// </summary>
        public void RefreshTree()
        {
            this.Nodes.Clear();
            this.Nodes.Add("project", m_projectNode.Name, 0);

            foreach (string str in m_projectNode.SourceFiles)
            {
                ProjectTreeNode node = new ProjectTreeNode();
                node.Text               = System.IO.Path.GetFileName(str);
                node.File               = m_projectNode.GetFullFilename(str);
                node.Name               = node.Text;
                node.ImageIndex         = 1;
                node.SelectedImageIndex = 1;
                if (str == m_projectNode.MainFile)
                {
                    node.Text += " (main)";
                }
                this.Nodes["project"].Nodes.Add(node);
            }

            Nodes["project"].Expand();
        }
Exemple #2
0
        /// <summary>
        /// Crée une map nom de fichier (par rapport au dossier contenant le main file) / contenu en mémoire pour une compilation
        /// à la volée (afin de vérifier les erreurs).
        /// </summary>
        /// <returns></returns>
        Dictionary <string, string> MapFilesInMemory()
        {
            Dictionary <string, string> files = new Dictionary <string, string>();
            string mainFilePath = m_project.GetFullFilename(m_project.MainFile);
            string baseDir      = Path.GetDirectoryName(mainFilePath);

            foreach (string file in m_project.SourceFiles)
            {
                // Chemin absolu
                string absolutePath       = m_project.GetFullFilename(file);
                string dirName            = Path.GetDirectoryName(m_project.GetFullFilename(m_project.MainFile));
                string relativeToMainfile = m_project.GetFilenameRelativeTo(dirName + "\\", absolutePath);

                // Si le fichier est déjà ouvert.
                var    page = GetPageByFullFilename(absolutePath);
                string content;
                if (page == null)
                {
                    if (File.Exists(absolutePath))
                    {
                        content = File.ReadAllText(absolutePath, Encoding.UTF8);
                    }
                    else
                    {
                        content = "(file does not exist anymore)";
                    }
                }

                else
                {
                    content = page.Editor.Text;
                }

                files.Add(relativeToMainfile, content);
            }
            return(files);
        }