private void Service_PlaceSeats(object sender, GetBookedSeatsCompletedEventArgs e) { SingletonQuery.QueryClient.GetBookedSeatsCompleted -= this.Service_PlaceSeats; if (e.Error == null) { Seat[,] seats = new Seat[ROWS, POSITIONS]; ObservableCollection<Seat> gotBookedSeats = e.Result; foreach (var gotBookedSeat in gotBookedSeats) { seats[gotBookedSeat.Row, gotBookedSeat.Position] = gotBookedSeat; } for (int row = 1; row < ROWS; row++) { for (int position = 1; position < POSITIONS; position++) { int currentRow = 11 - row; Button btnSeat = new Button(); btnSeat.Margin = new Thickness(-10, -10, -10, -10); btnSeat.Tag = string.Format("row{0}position{1}", row, position); btnSeat.Width = 90; btnSeat.Height = 90; Grid.SetRow(btnSeat, currentRow); Grid.SetColumn(btnSeat, position); btnSeat.BorderBrush = null; if (seats[row, position] == null) { btnSeat.Background = freeSeat.Background; btnSeat.Click += this.btnSeat_Click; } else { btnSeat.Background = bookedSeat.Background; } this.seatsContainer.Children.Add(btnSeat); } } for (int index = 1; index < ROWS; index++) { TextBlock lblRow = new TextBlock(); lblRow.Foreground = new SolidColorBrush(Colors.Yellow); lblRow.HorizontalAlignment = HorizontalAlignment.Center; lblRow.VerticalAlignment = VerticalAlignment.Center; lblRow.Text = index.ToString(); Grid.SetRow(lblRow, ROWS - index); Grid.SetColumn(lblRow, 0); this.seatsContainer.Children.Add(lblRow); TextBlock lblPosition = new TextBlock(); lblPosition.Foreground = new SolidColorBrush(Colors.Yellow); lblPosition.HorizontalAlignment = HorizontalAlignment.Center; lblPosition.Text = index.ToString(); Grid.SetRow(lblPosition, 0); Grid.SetColumn(lblPosition, index); this.seatsContainer.Children.Add(lblPosition); } TextBlock caption = new TextBlock(); caption.Foreground = new SolidColorBrush(Colors.Yellow); caption.Text = "Cols Rows"; caption.FontSize = 10; caption.TextWrapping = TextWrapping.Wrap; Grid.SetRow(caption, 0); Grid.SetColumn(caption, 0); this.seatsContainer.Children.Add(caption); } }
private void Service_PlaceSeats(object sender, GetBookedSeatsCompletedEventArgs e) { SingletonQuery.QueryClient.GetBookedSeatsCompleted -= this.Service_PlaceSeats; if (e.Error == null) { Seat[,] seats = new Seat[ROWS, POSITIONS]; ObservableCollection <Seat> gotBookedSeats = e.Result; foreach (var gotBookedSeat in gotBookedSeats) { seats[gotBookedSeat.Row, gotBookedSeat.Position] = gotBookedSeat; } for (int row = 1; row < ROWS; row++) { for (int position = 1; position < POSITIONS; position++) { int currentRow = 11 - row; Button btnSeat = new Button(); btnSeat.Margin = new Thickness(-10, -10, -10, -10); btnSeat.Tag = string.Format("row{0}position{1}", row, position); btnSeat.Width = 90; btnSeat.Height = 90; Grid.SetRow(btnSeat, currentRow); Grid.SetColumn(btnSeat, position); btnSeat.BorderBrush = null; if (seats[row, position] == null) { btnSeat.Background = freeSeat.Background; btnSeat.Click += this.btnSeat_Click; } else { btnSeat.Background = bookedSeat.Background; } this.seatsContainer.Children.Add(btnSeat); } } for (int index = 1; index < ROWS; index++) { TextBlock lblRow = new TextBlock(); lblRow.Foreground = new SolidColorBrush(Colors.Yellow); lblRow.HorizontalAlignment = HorizontalAlignment.Center; lblRow.VerticalAlignment = VerticalAlignment.Center; lblRow.Text = index.ToString(); Grid.SetRow(lblRow, ROWS - index); Grid.SetColumn(lblRow, 0); this.seatsContainer.Children.Add(lblRow); TextBlock lblPosition = new TextBlock(); lblPosition.Foreground = new SolidColorBrush(Colors.Yellow); lblPosition.HorizontalAlignment = HorizontalAlignment.Center; lblPosition.Text = index.ToString(); Grid.SetRow(lblPosition, 0); Grid.SetColumn(lblPosition, index); this.seatsContainer.Children.Add(lblPosition); } TextBlock caption = new TextBlock(); caption.Foreground = new SolidColorBrush(Colors.Yellow); caption.Text = "Cols Rows"; caption.FontSize = 10; caption.TextWrapping = TextWrapping.Wrap; Grid.SetRow(caption, 0); Grid.SetColumn(caption, 0); this.seatsContainer.Children.Add(caption); } }