async void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item == null || !(e.Item is LessonInfo))
            {
                return;
            }

            LessonInfo selectedLesson = (LessonInfo)e.Item;

            //Deselect Item
            ((ListView)sender).SelectedItem = null;

            await Navigation.PushAsync(new LessonSettingsPage(selectedLesson, timetable.EventTypes(selectedLesson.Lesson.ID).ToList()));
        }
Ejemplo n.º 2
0
        private string GetStatistics()
        {
            IEnumerable <Event> events = timetableInfo.Events.Where(e => e.Lesson == LessonInfo.Lesson);

            var statForTypes = timetableInfo.EventTypes(LessonInfo.Lesson.ID).OrderBy(et => et.ShortName).Select(et =>
            {
                var eventsWithType = events.Where(e => e.Type == et).ToList();
                return($"{et.ShortName}:\n" +
                       $"- {LN.EventsTotal} {eventsWithType.Count}, {eventsWithType.Count(e => e.Start > DateTime.Now)} {LN.EventsLeft}\n" +
                       $"- {LN.NextEvent}: {eventsWithType.FirstOrDefault(e => e.Start > DateTime.Now)?.Start.ToShortDateString() ?? "-" }\n" +
                       $"- {LN.Teachers}: {string.Join(", ", eventsWithType.SelectMany(e => e.Teachers).Distinct().Select(t => t.ShortName).OrderBy(tn => tn).DefaultIfEmpty("-"))}");
            });

            return(string.Join("\n", statForTypes));
        }