Esempio n. 1
0
        public void FillCell(Shift shift, bool isFirstElement, bool isLastElement)
        {
            Color color = Colors.RoyalBlue;

            if (shift.GetType() == typeof(ScheduleShift))
            {
                ScheduleShift scheduleShift = (ScheduleShift)shift;
                color = scheduleShift.IsForSale ? Colors.Red : Colors.RoyalBlue;
            }


            ShiftElement shiftElement = null;

            if (isFirstElement)
            {
                shiftElement = new ShiftElement(shift, color);
                Grid.SetRowSpan(this, 2);

                // Border.BorderThickness = new Thickness(0.1, 0.1, 0.1, 0);
            }
            else if (isLastElement)
            {
                shiftElement = new ShiftElement(shift, color, true);
                //Border.BorderThickness = new Thickness(0.1, 0, 0.1, 0.1);
            }
            else // Middle Element
            {
                shiftElement = new ShiftElement(shift, color, false);
                // Border.BorderThickness = new Thickness(0.1, 0, 0.1, 0);
            }
            TimeCellGrid.ColumnDefinitions.Add(new ColumnDefinition());
            TimeCellGrid.Children.Add(shiftElement);
            Grid.SetColumn(shiftElement, ShiftsInCell.Count);
            ShiftsInCell.Add(shift);
        }
Esempio n. 2
0
 public void AddButtom(ShiftElement shiftElement)
 {
     shiftElement.ElementBorder.Effect = null;
     ElementGrid.Children.Add(shiftElement);
     Grid.SetRow(shiftElement, 3);
 }
Esempio n. 3
0
        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);
            }
        }