protected override void OnNavigatedFrom(NavigationEventArgs e) { if (this.currentLevel != null) { this.currentLevel.Stop(); this.currentLevel = null; } }
private void NextLevel() { if (this.currentLevel != null) { this.currentLevel.Completed -= this.HandleLevelCompleted; this.LayoutRoot.Children.Remove(this.currentLevel); } ++this.levelIndex; if (this.levelIndex < this.levels.Count) { this.currentLevel = (Level)Activator.CreateInstance(this.levels[this.levelIndex].LevelType); this.currentLevel.Completed += this.HandleLevelCompleted; this.LayoutRoot.Children.Add(this.currentLevel); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); string levelName = null; this.NavigationContext.QueryString.TryGetValue("Level", out levelName); LevelInfo selectedLevel = null; foreach (LevelInfo levelInfo in LevelInfo.AllLevels) { if (levelInfo.Title == levelName) selectedLevel = levelInfo; } this.currentLevel = (Level)Activator.CreateInstance(selectedLevel.LevelType); this.currentLevel.Completed += this.HandleLevelCompleted; this.LayoutRoot.Children.Add(this.currentLevel); }