public void LoadTimeCells() { if (60 % TemplateScheduleCalendar.INCREMENT == 0) { TimeSpan timeCount = TemplateScheduleCalendar.STARTTIME; int rowCount = 0; while (timeCount <= TemplateScheduleCalendar.ENDTIME.Add(new TimeSpan(0, 60 - TemplateScheduleCalendar.INCREMENT, 0))) { DayColumnGrid.RowDefinitions.Add(new RowDefinition()); TimeCell tempTimeCell = new TimeCell() { Time = timeCount, WeekDay = DayOfWeek }; DayColumnGrid.Children.Add(tempTimeCell); Panel.SetZIndex(tempTimeCell, 100); Grid.SetRow(tempTimeCell, rowCount); TimeCellList.Add(tempTimeCell); rowCount++; timeCount = timeCount.Add(new TimeSpan(0, TemplateScheduleCalendar.INCREMENT, 0)); } } }
public TimeCell GetNextTimeCell(TimeCell timeCell) { TimeCell res = timeCell; int index = TimeCellList.IndexOf(timeCell); if ((index + 1) < TimeCellList.Count) { res = TimeCellList[index + 1]; } return(res); }
public void RenderShifts() { loadedShifts.Clear(); bool isTemplate = false; int zIndex = 600; foreach (Shift shift in Shifts) { //Find the corosponding timecell element TimeCell timeCell = new TimeCell(); if (shift.GetType() == typeof(TemplateShift)) { TemplateShift ts = (TemplateShift)shift; timeCell = FindMatchingTimeCell(ts.StartTime); isTemplate = true; } else if (shift.GetType() == typeof(ScheduleShift)) { ScheduleShift ss = (ScheduleShift)shift; timeCell = FindMatchingTimeCell(new TimeSpan(ss.StartTime.Hour, ss.StartTime.Minute, ss.StartTime.Second)); } //------------------Set rows and columns----------------------- //Find out how many columns the should be in the current timecell int columnAmount = OverlapsWithShiftsInList(shift, Shifts) > 0 ? OverlapsWithShiftsInList(shift, Shifts) + 1 : 1; //Find out which column nr the current shift shall insertes into int columnNr = OverlapsWithShiftsInList(shift, loadedShifts); //Find how many rows the timecell should have int rowCount = (int)(shift.Hours * (60 / TemplateScheduleCalendar.INCREMENT)); //Set the max-rowcount for block of shifts timeCell.MaxRowCount = timeCell.MaxRowCount < rowCount ? rowCount : timeCell.MaxRowCount; //------------------Insert shiftelement------------------------- //Find the right color Color col = Colors.RoyalBlue; if (!isTemplate) { ScheduleShift scheduleShift = (ScheduleShift)shift; if (scheduleShift.IsForSale) { col = Colors.MistyRose; // Mmmmmmm.... Misty Rose } } //Instansiate the shiftelement ShiftElement shiftElement = new ShiftElement(shift, col); shiftElement.RootTimeCell = timeCell; shiftElement.AddButtom(new ShiftElement(shift, col, true)); //shiftElement.SetMouseOver(); //shiftElement.SetMouseLeave(); //Add shiftelement to timecell timeCell.TimeCellGrid.Children.Add(shiftElement); //Add columns timeCell.TimeCellGrid.ColumnDefinitions.Clear(); for (int i = 0; i < columnAmount; i++) { timeCell.TimeCellGrid.ColumnDefinitions.Add(new ColumnDefinition()); } //Add rows for the timeCell timeCell.TimeCellGrid.RowDefinitions.Clear(); for (int i = 0; i < timeCell.MaxRowCount; i++) { timeCell.TimeCellGrid.RowDefinitions.Add(new RowDefinition()); } //Set rowspan for timecell Grid.SetRowSpan(timeCell, timeCell.MaxRowCount); //Set rowspan for shiftelement Grid.SetRowSpan(shiftElement, rowCount); //Set columnspan for timeCell Grid.SetColumnSpan(timeCell, columnAmount); //Set column for shiftelement Grid.SetColumn(shiftElement, columnNr); Panel.SetZIndex(timeCell, zIndex); //zIndex--; //Finally add shift to list of loaded shifts loadedShifts.Add(shift); } }