public override DataObject Copy(Sprite parent) { var newStartScript = new StartScript(parent); if (bricks != null) newStartScript.bricks = bricks.Copy(parent) as BrickList; return newStartScript; }
public void AddScriptBrick(DataObject scriptBrick, int firstViewIndex, int lastViewIndex) { //if (this.Count == lastViewIndex + 1 && GetAtIndex(lastViewIndex) is Script && ) //{ // lastViewIndex++; //} if (scriptBrick is Brick) // Add brick at last visible end of a script { Brick brick = scriptBrick as Brick; int scriptEndIndex = -1; int scriptBeginIndex = 0; Script lastFullScript = null; foreach (Script script in scripts) { scriptBeginIndex = scriptEndIndex + 1; scriptEndIndex += script.Bricks.Bricks.Count + 1; if (scriptEndIndex > lastViewIndex && scriptBeginIndex >= firstViewIndex) break; lastFullScript = script; } if (lastFullScript == null) { StartScript startScript = new StartScript(selectedSprite); scripts.Add(startScript); lastFullScript = startScript; OnScriptAdded(startScript, IndexOf(startScript)); } lastFullScript.Bricks.Bricks.Add(brick); //OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); // TODO: make faster and use method below instead OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, scriptBrick, IndexOf(scriptBrick))); } else if (scriptBrick is Script) // Add script at end of all { Script script = scriptBrick as Script; scripts.Add(script); //OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); // TODO: make faster and use method below instead OnScriptAdded((Script)scriptBrick, IndexOf(scriptBrick)); } // }
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; }