private async void Settings_Loaded(object sender, RoutedEventArgs e) { await Task.Run(() => { var dfi = DateTimeFormatInfo.CurrentInfo; var cal = dfi.Calendar; var pomodoros = _itemRepository.GetPomodoros() .Select( x => new { week = cal.GetWeekOfYear(x.DateTime, CalendarWeekRule.FirstFullWeek, dfi.FirstDayOfWeek), x }); var max = pomodoros.Max(x => x.x.Count); foreach (var pomodoro in pomodoros.GroupBy(x => x.week)) { var week = pomodoro.Select(x => x.x.ToPomodoroViewModel(GetLevelFromCount(x.x.Count, max))); Dispatcher.Invoke(() => { WeekStackPanel.Children.Add(new PomodoroWeek(week)); }); } Dispatcher.Invoke(() => { var weekShift = DayOfWeek.Monday - CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek; MondayTextBlock.Margin = new Thickness(0, 12 * weekShift - 1, 0, 12); DayPanel.Visibility = Visibility.Visible; LoadingPanel.Visibility = Visibility.Collapsed; }); }); }
private async void Settings_Loaded(object sender, RoutedEventArgs e) { await Task.Run(() => { DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; var pomodoros = _itemRepository.GetPomodoros() .Select( x => new { week = cal.GetWeekOfYear(x.DateTime, dfi.CalendarWeekRule, dfi.FirstDayOfWeek), x }); int max = pomodoros.Max(x => x.x.Count); foreach (var pomodoro in pomodoros.GroupBy(x => x.week)) { var week = pomodoro.Select(x => x.x.ToPomodoroViewModel(GetLevelFromCount(x.x.Count, max))); Dispatcher.Invoke(() => { WeekStackPanel.Children.Add(new PomodoroWeek(week)); }); } Dispatcher.Invoke(() => { DayPanel.Visibility = Visibility.Visible; LoadingPanel.Visibility = Visibility.Collapsed; }); }); }
private void ResetTicking() { TimerFlush.Stop(this); _stopWatch.Reset(); _dispacherTime.Stop(); CurrentTimeValue = "00:00"; _period = 0; _isBreak = false; _isBreakLong = false; _isWork = true; ProgressValue = .0; ProgressState = "None"; _ticks = 0; var lastDay = _itemRepository.GetPomodoros().Last(); if (lastDay.DateTime == DateTime.Now.Date) { _period = lastDay.Count % 4; } CurrentPeriod.Text = _period != 0 ? _period.ToString() : ""; }