Exemplo n.º 1
0
        public ModelViewSchedule(List <Lesson> list,
                                 Schedule sch)
        {
            DateTime today      = DateTime.Today;
            int      nowDayWeek = (int)today.DayOfWeek - 1;
            // определяем дату на Понедельник
            DateTime monday = today.AddDays(-nowDayWeek);

            //------------------------
            Days = new List <DayView>();
            for (int i = 0; i < 7; i++)
            {
                var lessonsDay =
                    list.Where(l => l.DayOfWeek - 1 == i)
                    .Select(l => new LessonView(l, sch))
                    .ToList();
                if (lessonsDay.Count() > 0)
                {
                    var day = new DayView()
                    {
                        Lessons = lessonsDay,
                        Name    = week[i],
                        Date    = monday.AddDays(i)
                                  .ToShortDateString()
                    };
                    Days.Add(day);
                }
            }
        }
Exemplo n.º 2
0
 public DayDescriptionControl(DayView day)
 {
     InitializeComponent();
     // выставляем день недели
     this.labelDayOfWeek.Content = day.Name;
     // выставляем дату
     this.labelDate.Content = day.Date;
     // выставляем занятия
     this.panelLessons.Children.Clear();
     foreach (var l in day.Lessons)
     {
         var lessonCtrl = new LessonDescriptionControl();
         lessonCtrl.labelCabinet.Content = l.Cabinet;
         lessonCtrl.labelDiscipline.Text = l.Discipline;
         lessonCtrl.labelTeacher.Content = l.Teacher;
         lessonCtrl.labelN.Content       = l.N;
         lessonCtrl.textBlockTime.Text   = l.Time;
         lessonCtrl.Margin = new Thickness(4);
         panelLessons.Children.Add(lessonCtrl);
     }
 }