void CreateNewLevel(object sender, MouseButtonEventArgs e) { // int LevelsCount = this.game._levels.Count; ShootEmUpMaker.Level NewLevel = new ShootEmUpMaker.Level() { _number = LevelsCount + 1 }; NewLevel._name = String.Format("Level #{0}", NewLevel._number); this.game._levels.Add(NewLevel); // Add level item to the view this.AddLevelObject(NewLevel); // Update create level button and game name text this.UpdateGameNameTextBlock(); if (this.game._levels.Count > 0) { this.CreateNewLevelButton.Text = "Add another level..."; } // Scroll down the PanelSwitcherViewer this.PanelSwitcherViewer.ScrollToBottom(); }
void LevelTextBlockMouseDown(object sender, MouseButtonEventArgs e) { // Hide all the panels foreach (UIElement x in this.Panels.Children) { x.Visibility = Visibility.Hidden; } // Show the concerned panel this.LevelPanel.Visibility = Visibility.Visible; // Bind level object content to the panel TextBlock LevelTextBlock = (TextBlock)sender; ShootEmUpMaker.Level lvl = this.game._levels.Find(l => l._name.Equals(LevelTextBlock.Text)); this.LevelPanel.DataContext = lvl; }
void AddLevelObject(ShootEmUpMaker.Level Level) { // Add a the level to the panel switcher TextBlock NewLevelTextBlock = new TextBlock() { Height = 160, FontSize = 18 }; NewLevelTextBlock.Text = Level._name; NewLevelTextBlock.ToolTip = String.Format("Click here to edit level #{0}", Level._number); NewLevelTextBlock.Cursor = Cursors.Hand; NewLevelTextBlock.FontWeight = FontWeights.Thin; NewLevelTextBlock.TextWrapping = TextWrapping.Wrap; NewLevelTextBlock.Margin = new Thickness(5, 5, 5, 5); NewLevelTextBlock.Padding = new Thickness(10, 20, 10, 20); NewLevelTextBlock.VerticalAlignment = VerticalAlignment.Center; NewLevelTextBlock.Background = new SolidColorBrush(Color.FromRgb(65, 65, 65)); NewLevelTextBlock.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)); this.PanelSwitcher.Children.Insert(this.PanelSwitcher.Children.Count - 1, NewLevelTextBlock); NewLevelTextBlock.MouseDown += LevelTextBlockMouseDown; }
void CreateNewLevel(object sender, MouseButtonEventArgs e) { // int LevelsCount = this.game._levels.Count; ShootEmUpMaker.Level NewLevel = new ShootEmUpMaker.Level() { _number = LevelsCount + 1 }; NewLevel._name = String.Format("Level #{0}", NewLevel._number); this.game._levels.Add(NewLevel); // Add level item to the view this.AddLevelObject(NewLevel); // Update create level button and game name text this.UpdateGameNameTextBlock(); if (this.game._levels.Count > 0) this.CreateNewLevelButton.Text = "Add another level..."; // Scroll down the PanelSwitcherViewer this.PanelSwitcherViewer.ScrollToBottom(); }