Esempio n. 1
0
        public ExamViewModel(Exam exam, WellknownData schedule)
        {
            ShortName = exam.ShortName;
            StartTime = exam.StartTime.LocalDateTime;
            EndTime   = exam.EndTime.LocalDateTime;
            Countdown = (int)(StartTime.GetLocalDate() - DateTimeOffset.Now.Date).TotalDays;
            EquivalentStartSession = FindEqivalentSession(StartTime.TimeOfDay, schedule);
            EquivalentEndSession   = FindEqivalentSession(EndTime.TimeOfDay, schedule);
            Week          = exam.Week;
            DayOfWeek     = exam.DayOfWeek;
            ShortLocation = exam.ShortLocation;
            Seating       = exam.Seating;

            ILocalizationService locService = Application.Current.GetService <ILocalizationService>();

            TimeRangeDisplay = locService.Format("ScheduleSummaryTimeRangeFormat", StartTime.ToLocalTime().TimeOfDay, EndTime.ToLocalTime().TimeOfDay);
            if (Countdown < 0)
            {
                CountdownDisplay = locService.GetString("ScheduleSummaryExamCountdownEnded");
            }
            else if (Countdown < 3)
            {
                CountdownDisplay = locService.GetString($"ScheduleSummaryExamCountdown{Countdown}");
            }
            else
            {
                CountdownDisplay = locService.Format("ScheduleSummaryExamCountdownFormat", Countdown);
            }
        }
Esempio n. 2
0
        public TermViewModel(Term term, ILocalizationService locService)
        {
            string termNotation = locService.GetString($"TermNumberNotation{term.TermNumber}");

            DisplayName       = locService.Format("TermDisplayNameFormat", term.BeginningYear, term.EndingYear, termNotation);
            GradePoint        = term.GradePoint;
            GradePointDisplay = locService.Format("TermGradePointFormat", term.GradePoint);
            Courses           = term.Courses.Select(x => new CourseViewModel(x)).ToList();
        }
Esempio n. 3
0
        public ScheduleEntryViewModel(ScheduleEntry entry, DateTimeOffset date, WellknownData schedule)
        {
            Name         = entry.Name;
            Lecturer     = entry.Lecturer;
            Room         = entry.Room;
            DayOfWeek    = entry.DayOfWeek;
            StartSession = Math.Min(entry.StartSession, schedule.Schedule.Count);
            EndSession   = Math.Min(entry.EndSession, schedule.Schedule.Count);

            TimeSpan startTime = schedule.Schedule[StartSession - 1].StartOffset;
            TimeSpan endTime   = schedule.Schedule[EndSession - 1].EndOffset;

            LocalStartTime = date.Add(startTime);
            LocalEndTime   = date.Add(endTime);
            ILocalizationService locService = Application.Current.GetService <ILocalizationService>();

            TimeRangeDisplay     = locService.Format("ScheduleSummaryTimeRangeFormat", LocalStartTime.TimeOfDay, LocalEndTime.TimeOfDay);
            TimeRangeRoomDisplay = locService.Format("ScheduleSummaryTimeRangeRoomFormat", LocalStartTime.TimeOfDay, LocalEndTime.TimeOfDay, Room);
        }
Esempio n. 4
0
        public ScheduleDayViewModel(int weekNumber, DateTimeOffset date, IEnumerable <ScheduleEntry> entries, WellknownData schedule)
        {
            ILocalizationService locService = Application.Current.GetService <ILocalizationService>();

            LocalDate        = date;
            LocalDateDisplay = locService.Format("ScheduleTableDayDisplayFormat", date);
            WeekNumber       = weekNumber;
            DayOfWeek        = date.DayOfWeek == System.DayOfWeek.Sunday ? 7 : (int)date.DayOfWeek;
            DayOfWeekDisplay = locService.GetString($"ScheduleTableDayOfWeek{DayOfWeek}Header");
            IsToday          = date == DateTimeOffset.Now.GetLocalDate();
            Entries          = entries.OrderBy(x => x.StartSession).Select(x => new ScheduleEntryViewModel(x, date, schedule)).ToList();
            Initialized      = true;

            ConsolidatedEntries = new List <ScheduleConsolidationViewModel>();
            for (int i = 0; i < Entries.Count; i++)
            {
                ScheduleEntryViewModel         currentEntry  = Entries[i];
                ScheduleConsolidationViewModel consolidation = new ScheduleConsolidationViewModel(currentEntry);
                for (int j = i; j < Entries.Count; j++)
                {
                    ScheduleEntryViewModel potentialConflict = Entries[j];
                    if (potentialConflict.StartSession > currentEntry.EndSession)
                    {
                        break;
                    }
                    else
                    {
                        consolidation.Conflicts.Add(potentialConflict);
                    }
                }
                if (consolidation.ConflictCount > 1)
                {
                    consolidation.ConflictCountDisplay = locService.Format("ScheduleTableConflictDescriptionFormat", consolidation.ConflictCount - 1);
                }
                ConsolidatedEntries.Add(consolidation);
                i += consolidation.ConflictCount;
            }
        }
Esempio n. 5
0
        public ScoreSetViewModel(ScoreSet scoreSet)
        {
            ILocalizationService locService = Application.Current.GetService <ILocalizationService>();

            GradePoint        = scoreSet.GradePoint;
            GradePointDisplay = locService.Format("OverallGradePointFormat", scoreSet.GradePoint);
            HasTerms          = scoreSet.Terms.Count > 0;
            Terms             = new CollectionViewSource()
            {
                IsSourceGrouped = true,
                ItemsPath       = new PropertyPath("Courses"),
                Source          = scoreSet.Terms.Reverse <Term>().Select(x => new TermViewModel(x, locService)).ToList()
            };
        }