public PageTimetable(DataProvider.Timetable timetable) { InitializeComponent(); this.timetable = timetable; CreateHeader(); int row = 1; foreach (KeyValuePair <string, DataProvider.Timetable.Department> department in timetable.departments) { CreateTextBlock(department.Key, row, 0, TextBlockStyle.Department); row++; foreach (KeyValuePair <string, DataProvider.Timetable.DocInfo> docInfo in department.Value.doctors) { CreateTextBlock(docInfo.Key, row, 0, TextBlockStyle.DoctorName); int column = 1; foreach (KeyValuePair <string, string> schedule in docInfo.Value.timeTable) { CreateTextBlock(DataProvider.ClearTimeString(schedule.Value), row, column, TextBlockStyle.WorkTime); column++; } row++; } } }
private async void TimerUpdateTimetable_Tick(object sender, EventArgs e) { Logging.ToLog("TimetableHandler - Обновление расписания"); pageChairsRoot.ClearPageIndicator(); DataProvider.Timetable timetableInitial = dataProvider.GetTimeTable(); if (timetableInitial.departments.Count == 0) { Logging.ToLog("TimetableHandler - не удалось получить информацию о расписании"); pageChairsRoot.ShowErrorPage(); return; } pageChairsRoot.SetupTitle("Расписание работы сотрудников"); if (!(sender is DispatcherTimer dispatcherTimer)) { return; } dispatcherTimer.Stop(); DataProvider.Timetable timetableToShow = new DataProvider.Timetable(); Dictionary <PageTimetable, Border> pagesTimetable = new Dictionary <PageTimetable, Border>(); int row = 0; Logging.ToLog("MainWindow - Создание страниц расписания"); try { foreach (KeyValuePair <string, DataProvider.Timetable.Department> departmentPair in timetableInitial.departments) { if (row >= 12) { pagesTimetable.Add(new PageTimetable(timetableToShow), PageChairsRoot.CreateIndicator()); row = 0; timetableToShow.departments.Clear(); } timetableToShow.departments.Add(departmentPair.Key, new DataProvider.Timetable.Department()); row++; foreach (KeyValuePair <string, DataProvider.Timetable.DocInfo> docInfoPair in departmentPair.Value.doctors) { timetableToShow.departments[departmentPair.Key].doctors.Add(docInfoPair.Key, docInfoPair.Value); row++; if (row == 13) { pagesTimetable.Add(new PageTimetable(timetableToShow), PageChairsRoot.CreateIndicator()); row = 0; timetableToShow.departments.Clear(); if (!docInfoPair.Equals(departmentPair.Value.doctors.Last())) { timetableToShow.departments.Add(departmentPair.Key, new DataProvider.Timetable.Department()); row++; } } } } } catch (Exception exc) { Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace); return; } if (pagesTimetable.Count > 1) { foreach (Border border in pagesTimetable.Values) { pageChairsRoot.StackPanelPageIndicator.Children.Add(border); } } Logging.ToLog("MainWindow - Отображение страниц расписания"); int currentPageIndex = 0; try { foreach (KeyValuePair <PageTimetable, Border> pagePair in pagesTimetable) { pagesTimetable.Values.ToList()[currentPageIndex].Background = Brushes.Gray; pagesTimetable.Values.ToList()[currentPageIndex].Height = 10; pageChairsRoot.FrameMain.Navigate(pagePair.Key); await PutTaskDelay(); pagesTimetable.Values.ToList()[currentPageIndex].Background = Brushes.LightGray; pagesTimetable.Values.ToList()[currentPageIndex].Height = 5; currentPageIndex++; if (currentPageIndex == pagesTimetable.Count) { currentPageIndex = 0; } } } catch (Exception exc) { Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace); } dispatcherTimer.Start(); }