public void LoadSampleProjects()
        {
            foreach (KeyValuePair<string,string> pair in sampleProjectNames)
              {
            string projectFileName = pair.Key;
            string projectName = pair.Value;

            string path = "Resources/SampleProjects/";
            path += projectFileName;

            var resourceStream = ResourceLoader.GetResourceStream(ResourceScope.Core, path);
            CatrobatZip.UnzipCatrobatPackageIntoIsolatedStorage(resourceStream, CatrobatContext.ProjectsPath + "/" + projectName);

            using (IStorage storage = StorageSystem.GetStorage())
            {
              string xml = storage.ReadTextFile(CatrobatContext.ProjectsPath + "/" + projectName + "/" + Project.ProjectCodePath);

              var project = new Project(xml);
              project.SetProjectName(projectName);

              project.Save();
            }
              }
        }
        internal void RestoreDefaultProject(string projectName)
        {
            using (IStorage storage = StorageSystem.GetStorage())
              {
            string projectCodeFile = ProjectsPath + "/" + projectName;

            if (!storage.FileExists(projectCodeFile))
            {
              Stream stream = ResourceLoader.GetResourceStream(ResourceScope.SampleProjects, DefaultProjectPath);
              CatrobatZip.UnzipCatrobatPackageIntoIsolatedStorage(stream, projectCodeFile);
            }

            string xml = storage.ReadTextFile(projectCodeFile + "/" + Project.ProjectCodePath);
            CurrentProject = new Project(xml);

            CurrentProject.SetProjectName(projectName);
              }
        }
        public void CopyProject(string projectName)
        {
            using (IStorage storage = StorageSystem.GetStorage())
              {
            string sourcePath = ProjectsPath + "/" + projectName;
            string newProjectName = projectName;
            string destinationPath = ProjectsPath + "/" + newProjectName;

            int counter = 1;
            while (storage.DirectoryExists(destinationPath))
            {
              newProjectName = projectName + counter;
              destinationPath = ProjectsPath + "/" + newProjectName;
              counter++;
            }

            storage.CopyDirectory(sourcePath, destinationPath);

            string xml = storage.ReadTextFile(destinationPath + "/" + Project.ProjectCodePath);
            var newProject = new Project(xml);
            newProject.SetProjectName(newProjectName);
            newProject.Save();
              }

              UpdateLocalProjects();
        }
예제 #4
0
        internal void RestoreDefaultProject(string projectName)
        {
            using (IStorage storage = StorageSystem.GetStorage())
              {
            string projectCodeFile = ProjectsPath + "/" + projectName;

            if (!storage.FileExists(projectCodeFile))
            {
            #if SILVERLIGHT
            Stream stream = Application.GetResourceStream(new Uri("/MetroCatData;component/" + DefaultProjectPath, UriKind.Relative)).Stream;
            CatrobatZip.UnzipCatrobatPackageIntoIsolatedStorage(stream, projectCodeFile);
            #else
              // TODO: implement me
            #endif
            }

            string xml = storage.ReadTextFile(projectCodeFile + "/" + Project.ProjectCodePath);
            CurrentProject = new Project(xml);

            CurrentProject.SetProjectName(projectName);
              }
        }