示例#1
0
        public static FileObject <PerhapsProject>[] GetRecentProjects()
        {
            if (cachedRecentProjects != null)
            {
                return(cachedRecentProjects);
            }

            FileObject <RecentProjectsContainer> recentProjectsFile =
                new FileObject <RecentProjectsContainer>(recentProjFilePath);

            if (recentProjectsFile.Load())
            {
                List <FileObject <PerhapsProject> > loaded = new List <FileObject <PerhapsProject> >();
                Deque <string> paths = recentProjectsFile.Object.recentProjectPaths;

                for (int i = 0; i < paths.Count; i++)
                {
                    FileObject <PerhapsProject> file = new FileObject <PerhapsProject>(paths[i]);

                    if (file.Load())
                    {
                        loaded.Add(file);
                    }
                }

                cachedRecentProjects = loaded.ToArray();
                recentProjectsFile.Save();
            }
            else
            {
                cachedRecentProjects = new FileObject <PerhapsProject> [0];
            }

            return(cachedRecentProjects);
        }
示例#2
0
        static void AppendRecentProject(string path)
        {
            FileObject <RecentProjectsContainer> container =
                new FileObject <RecentProjectsContainer>(recentProjFilePath);

            if (!container.Load())
            {
                container.Object = new RecentProjectsContainer();
            }

            container.Object.recentProjectPaths.AddFront(path);
            container.Object.recentProjectPaths = container.Object.recentProjectPaths.Distinct().ToDeque();

            container.Save();
        }
示例#3
0
        public static bool CreateProject(string directoryPath, string projectTitle)
        {
            PerhapsProject proj = new PerhapsProject();

            proj.ProjectTitle = projectTitle;

            string project_path = $"{directoryPath}\\{projectTitle}{projectFileExtension}";
            FileObject <PerhapsProject> projFile = new FileObject <PerhapsProject>(project_path, proj);

            if (!projFile.Save())
            {
                Console.WriteLine("ProjectManager error: " + projFile.ErrorString);

                return(false);
            }

            AppendRecentProject(project_path);

            CurrentProjectFile = projFile;
            return(true);
        }