void AddDetail(bool isNewDay) { #region Time Validation imgUp.IsVisible = imgDown.IsVisible = true; if (_hourToShow > _startHour) { if ((_hourToShow >= _endHour) || (_hourToShow >= _endHour - (_rowsToShow - 1))) { _hourToShow = _endHour - (_rowsToShow - 1); imgDown.IsVisible = false; } } else { _hourToShow = _startHour; imgUp.IsVisible = false; } #endregion bool createRows = isNewDay; bool createColumns = isNewDay; gridDetail.Children.Clear(); for (int row = 0; row < _rowsToShow; row++) { #region ViewValidation GetHour(_hourToShow, sbTimeStart); GetHour(_hourToShow + 1, sbTimeStart, true); #endregion if (createRows) { gridDetail.RowDefinitions.Add(new RowDefinition { Height = 50 }); } for (int column = 0; column <= _binding.Pitches.Count; column++) { #region Detail if (column == 0) { if (createColumns) { gridDetail.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60) }); } gridDetail.Children.Add(new Button { Text = sbTimeStart.ToString(), Style = (Style)Resources["titleButton"], FontSize = _fontSize }, column, row); } else { if (createColumns) { gridDetail.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); } var result = _binding.ValidateBusyTime(_binding.Pitches[column - 1].Id, _hourToShow); Button button = null; if (result != null && (result.Status != ReservationStatus.None && result.Status != ReservationStatus.CancelPlace)) { if (result.Source == 1) { DateTime dtButton = new DateTime(dpDate.Date.Year, dpDate.Date.Month, dpDate.Date.Day, _hourToShow, _place.FormatHour, 0); result.Place = _place; result.Pitch.PitchType = _pitchType; button = new Button { Style = GetStyle(result.Status), Command = _binding.ReservationSummaryCommand }; button.CommandParameter = new CommandWrapper { Button = button, Reservation = result }; } else { button = new Button { Style = (Style)Resources["blockButton"] }; } gridDetail.Children.Add(button, column, row); } else { if (dpDate.Date.Date < DateTime.Now.Date) { button = new Button { Style = (Style)Resources["notAvailableButton"] }; } else { DateTime dtButton = new DateTime(dpDate.Date.Year, dpDate.Date.Month, dpDate.Date.Day, _hourToShow, _place.FormatHour, 0); ReservationModel reservation = new ReservationModel { Place = _place, Pitch = new PitchModel { Id = _binding.Pitches[column - 1].Id, PitchType = _pitchType }, Date = dtButton }; button = new Button { Style = (Style)Resources["availableButton"], Command = _binding.ReservationCommand }; button.CommandParameter = new CommandWrapper { Button = button, Reservation = reservation }; } gridDetail.Children.Add(button, column, row); } } #endregion } createColumns = false; _hourToShow++; } }