public void chairClick(object sender, RoutedEventArgs e) { Button btn = sender as Button; btn.Background = Brushes.Gray; btn.IsEnabled = false; ChairButton parent = btn.Parent as ChairButton; listChair.Add(new Chair() { posX = parent.posX, posY = parent.posY, classID = parent.classId }); }
public void initData() { int[,] arr = new int[this.chairState.height, this.chairState.width]; foreach (var item in this.chairState.chairBooked) { arr[item.posY - 1, item.posX - 1] = 1; } for (int i = 0; i < this.chairState.height; i++) { for (int j = 0; j < this.chairState.width; j++) { ChairButton newBtn = null; if (arr[i, j] == 1) { newBtn = new ChairButton(j + 1, i + 1, "1", true); newBtn.Margin = new Thickness(5); newBtn.mainBtn.Click += chairClick; } else { string classId = "2"; if (i <= 4) { classId = "1"; } newBtn = new ChairButton(j + 1, i + 1, classId, false); newBtn.Margin = new Thickness(5); newBtn.mainBtn.Click += chairClick; } this.chairPanel.Children.Add(newBtn); } } }