public Sprite(Project project) { Project = project; scripts = new ScriptList(this); costumes = new CostumeList(this); sounds = new SoundList(this); }
private void initCurrentProject() { var project = new Project { ApplicationVersionCode = 1, ApplicationVersionName = "Version 1", DeviceName = "Device1", ProjectName = "Project1", ScreenHeight = 800, ScreenWidth = 480, PlatformVersion = "7.1.1", Platform = "Windows Phone 7.5" }; // TODO: implement other design data here var sprites = new SpriteList(project); var sprite = new Sprite(project); sprite.Name = "Object 1"; sprite.Costumes = new CostumeList(sprite); var costume = new Costume("Cat", sprite); var image = new byte[0]; //new BitmapImage(new Uri(costume.FileName, UriKind.Relative)); // TODO: fix me //costume.Image = image; sprite.Costumes.Costumes.Add(costume); sprite.Sounds = new SoundList(sprite); var sound = new Sound("Miau_Sound", sprite); sprite.Sounds.Sounds.Add(sound); sprite.Scripts = new ScriptList(sprite); Script startScript = new StartScript(sprite); startScript.Bricks = new BrickList(sprite); var setCostumeBrick = new SetCostumeBrick(sprite); var costumeRef = new CostumeReference(sprite); costumeRef.Costume = costume; //setCostumeBrick.Costume = costumeRef; //TODO: Add more Bricks if you need them sprites.Sprites.Add(sprite); currentProject = project; }
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 SetCurrentProject(string projectName) { if (currentProject != null && currentProject.ProjectName == projectName) return; if (currentProject != null) currentProject.Save(); string projectCodeFile = ProjectsPath + "/" + projectName; try { using (IStorage storage = StorageSystem.GetStorage()) { string xml = storage.ReadTextFile(projectCodeFile + "/" + Project.ProjectCodePath); CurrentProject = new Project(xml); } } catch { throw new Exception("Project not exists"); } }
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(); }
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); } }
public SpriteList(Project project) { this.project = project; Sprites = new ObservableCollection<Sprite>(); }
public Sprite(XElement xElement, Project project) { Project = project; LoadFromXML(xElement); }