private void LoadSchedule() { ScheduleGrid.BorderStyle = BorderStyle.None; ScheduleGrid.Rows.Insert(0); List <Worker> todayWorker = Enterprise.Personal.FindAll(date => date.TimeTable.Data.ContainsKey(monthCalendar.SelectionStart)); ScheduleGrid.ColumnsCount = todayWorker.Count + 1; ScheduleGrid[0, 0] = new SourceGrid.Cells.ColumnHeader(string.Empty); for (int i = 1; i <= todayWorker.Count; i++) { ScheduleGrid[0, i] = new SourceGrid.Cells.ColumnHeader($"{todayWorker[i - 1].About.Name}"); } ScheduleGrid.FixedRows = 1; int j = 1; try { for (TimeSpan i = Enterprise.TimeTable[(Days)IndexDay() + 1][0]; i < Enterprise.TimeTable[(Days)IndexDay() + 1][1]; i = i + DateTime.Parse("00:30:00").TimeOfDay) { ScheduleGrid.Rows.Insert(j); ScheduleGrid[j, 0] = new SourceGrid.Cells.RowHeader($"{i} - {(i + DateTime.Parse("00:30:00").TimeOfDay)}"); for (int k = 1; k < ScheduleGrid.ColumnsCount; k++) { if (todayWorker[k - 1].TimeTable.Data[monthCalendar.SelectionStart.Date].End <= i || todayWorker[k - 1].TimeTable.Data[monthCalendar.SelectionStart.Date].Start > i) { ScheduleGrid[j, k] = new SourceGrid.Cells.Cell("Не работает", typeof(string)); ScheduleGrid[j, k].ToolTipText = string.Empty; } else { ScheduleGrid[j, k] = new SourceGrid.Cells.Cell(string.Empty, typeof(string)); ScheduleGrid[j, k].ToolTipText = string.Empty; } } j++; } } catch (ArgumentOutOfRangeException) { ScheduleGrid.Rows.RemoveRange(0, ScheduleGrid.Rows.Count); } finally { ScheduleGrid.AutoSizeCells(); } }
public ScheduleGridDropBehavior(ScheduleGrid panel) { _scheduleGrid = panel; }