protected void seatButtonClickEvent(object sender, EventArgs e) { Button button = sender as Button; Console.WriteLine("Button clicked -> " + button.Text); Seat seat = seatController.getSeatManager().getSeat(int.Parse(button.Text)); seat.setValid(!seat.isValid()); button.BackColor = seat.isValid() ? (seat.isPremium() ? Color.Purple : Color.Green) : Color.Red; setEarned(); this.Update(); }
public void addSeats() { int x = 20; int y = 50; int buttonsInRow = 0; for (int i = 0; i < seatController.getSeatManager().getAllSeats().Count; i++) { Seat seat = seatController.getSeatManager().getAllSeats().ElementAt(i); int number = i + 1; Button button = new Button(); button.Width = 30; button.Height = 30; this.Controls.Add(button); button.Text = number + ""; button.Location = new Point(x, y); button.Click += new EventHandler(seatButtonClickEvent); button.MouseHover += new EventHandler(seatHoverEvent); button.BackColor = seat.isValid() ? (seat.isPremium() ? Color.Purple : Color.Green) : Color.Red; button.Show(); buttonsInRow++; if (seatController.getSeatManager().getSeatsPerRow() / 2 == buttonsInRow) { x += 90; } else if (seatController.getSeatManager().getSeatsPerRow() == buttonsInRow) { x = 20; y += 40; buttonsInRow = 0; } else { x += 35; } } Console.WriteLine("Added seats!"); this.Update(); }
public void setEarned() { int earned = 0; for (int i = 0; i < seatController.getSeatManager().getAllSeats().Count; i++) { Seat seat = seatController.getSeatManager().getAllSeats().ElementAt(i); if (!seat.isValid()) { earned += seat.isPremium() ? seatController.getPremiumPrice() : seatController.getPrice(); } } earnedMoney.Text = "Earned money: " + earned + "$"; this.Update(); }