Ejemplo n.º 1
0
        private void PaintAllDayEvents()
        {
            try
            {
                if (_scheduler == null || _scheduler.Events == null)
                {
                    return;
                }

                allDayEvents.Children.Clear();

                double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

                foreach (ClassScheduleModel e in _scheduler.Events.Where(ev => ev.End.Date > ev.Start.Date))
                {
                    int numColumn    = (int)e.Start.Date.Subtract(FirstDay.Date).TotalDays;
                    int numEndColumn = (int)e.End.Date.Subtract(FirstDay.Date).TotalDays + 1;

                    if (numColumn > 7 || numEndColumn <= 0)
                    {
                        continue;
                    }

                    if ((numColumn > 0 && numColumn <= 7) || (numEndColumn > 0 && numEndColumn <= 7))
                    {
                        double marginLeft = (numColumn) * columnWidth;

                        EventUserControl wEvent = new EventUserControl(e, false);
                        wEvent.Width             = columnWidth * (numEndColumn - numColumn);
                        wEvent.Margin            = new Thickness(marginLeft, 0, 0, 0);
                        wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                        {
                            ea.Handled = true;
                            OnEventDoubleClick(sender, new CustomEventArgsClassSchedule(wEvent.Event));
                        });
                        allDayEvents.Children.Add(wEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private void PaintAllEvents(DateTime?date, int?idBranch, int?idLivingroom, int?idWorkout)
        {
            try
            {
                if (_scheduler == null || _scheduler.Events == null)
                {
                    return;
                }

                int idW = idLivingroom ?? 0;

                IEnumerable <ClassScheduleModel> eventList;

                if (idWorkout != null)
                {
                    eventList = _scheduler.Events.Where(ev =>
                                                        ev.Start.Date == ev.End.Date &&
                                                        ev.IdBranchOffice == idBranch &&
                                                        ev.IdParent == idW &&
                                                        ev.IdWorkout == (int)idWorkout).OrderBy(ev => ev.Start);
                }
                else
                {
                    eventList = _scheduler.Events.Where(ev =>
                                                        ev.Start.Date == ev.End.Date &&
                                                        ev.IdBranchOffice == idBranch &&
                                                        ev.IdParent == idW).OrderBy(ev => ev.Start);
                }



                if (date == null)
                {
                    column1.Children.Clear();
                    column2.Children.Clear();
                    column3.Children.Clear();
                    column4.Children.Clear();
                    column5.Children.Clear();
                    column6.Children.Clear();
                    column7.Children.Clear();
                }
                else
                {
                    int numColumn = (int)date.Value.Date.Subtract(FirstDay.Date).TotalDays + 1;
                    ((Canvas)this.FindName("column" + numColumn)).Children.Clear();

                    eventList = idWorkout != null?eventList.Where(ev => ev.Start.Date == date.Value.Date && ev.IdBranchOffice == idBranch && ev.IdParent == idW && ev.IdWorkout == (int)idWorkout).OrderBy(ev => ev.Start) : eventList.Where(ev => ev.Start.Date == date.Value.Date && ev.IdBranchOffice == idBranch && ev.IdParent == idW).OrderBy(ev => ev.Start);
                }

                double columnWidth = EventsGrid.ColumnDefinitions[1].Width.Value;

                // PaintRowsHour((TimeSpan) dS, (TimeSpan) dE);

                PaintRowsHour((int)idBranch);

                foreach (ClassScheduleModel e in eventList)
                {
                    int numColumn = (int)e.Start.Date.Subtract(FirstDay.Date).TotalDays + 1;
                    if (numColumn > 0 && numColumn <= 7)
                    {
                        Canvas sp = (Canvas)this.FindName("column" + numColumn);
                        sp.Width = columnWidth;

                        double oneHourHeight = sp.ActualHeight / 22;


                        var concurrentEvents = new List <ClassScheduleModel>();

                        if (idWorkout != null)
                        {
                            concurrentEvents = _scheduler.Events.Where(e1 => ((e1.Start <= e.Start && e1.End > e.Start) ||
                                                                              (e1.Start > e.Start && e1.Start < e.End)) &&
                                                                       e1.End.Date == e1.Start.Date && e1.IdBranchOffice == idBranch && e1.IdParent == idW && e1.IdWorkout == (int)idWorkout).OrderBy(ev => ev.Start).ToList();
                        }
                        else
                        {
                            concurrentEvents = _scheduler.Events.Where(e1 => ((e1.Start <= e.Start && e1.End > e.Start) ||
                                                                              (e1.Start > e.Start && e1.Start < e.End)) &&
                                                                       e1.End.Date == e1.Start.Date && e1.IdBranchOffice == idBranch && e1.IdParent == idW).OrderBy(ev => ev.Start).ToList();
                        }

                        double marginTop  = oneHourHeight * (e.Start.Hour + (e.Start.Minute / 60.0));
                        double width      = columnWidth / (concurrentEvents.Count());
                        double marginLeft = width * getIndex(e, concurrentEvents);

                        EventUserControl wEvent = new EventUserControl(e, true);
                        wEvent.Width             = width;
                        wEvent.Height            = e.End.Subtract(e.Start).TotalHours *oneHourHeight;
                        wEvent.Margin            = new Thickness(marginLeft, marginTop, 0, 0);
                        wEvent.MouseDoubleClick += ((object sender, MouseButtonEventArgs ea) =>
                        {
                            ea.Handled = true;
                            OnEventDoubleClick(sender, new CustomEventArgsClassSchedule(wEvent.Event));
                        });

                        sp.Children.Add(wEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }