private void InitializeTodaysActivity() { var path = GetPathForDate(DateTime.Now); if (File.Exists(path)) { try { this.TodaysActivity = DailyActivity.Deserialize(path); } catch (Exception) { } } if (this.TodaysActivity == null) { this.TodaysActivity = new DailyActivity(); } }
private void SetDateRange(DateTime start, DateTime end) { start = start.Date; end = end.Date.AddDays(1).AddTicks(-1); var now = DateTime.Now; if (end.Date > now.Date) { end = now.Date.AddDays(1).AddTicks(-1); } if (start > end) { start = end; } if (this.StartTime == start && this.EndTime == end) { return; } this.StartTime = start.Date; this.EndTime = end.Date.AddDays(1).AddTicks(-1); List <DailyActivity> dailyActivities = new List <DailyActivity>(); // Don't include today in the list of things to load because we already have it loaded var endDate = this.EndTime; if (endDate.Date == now.Date) { endDate = endDate.AddDays(-1); } for (var currentDate = this.StartTime.Date; currentDate <= endDate; currentDate = currentDate.AddDays(1)) { var path = GetPathForDate(currentDate); if (File.Exists(path)) { try { dailyActivities.Add(DailyActivity.Deserialize(path)); } catch (Exception) { } } } // Add today's data if needed if (this.EndTime.Date == now.Date) { dailyActivities.Add(this.TodaysActivity); } this.aggragateDailyActivity.SetDailyActivities(dailyActivities); this.Dispatcher.Invoke(() => { UpdateLayout(); AutoFitTimeline(); }); }