public void Update() { var now = DateTime.Now; var schedule = CountdownCalculator.GetSchedule(countdown, now); var progress = CountdownCalculator.GetProgress(schedule, now); if (timeToggled) { Time = CountdownCalculator.GetElapsedTime(schedule, now); Date = schedule.Started; } else { Time = CountdownCalculator.GetRemainingTime(schedule, now); Date = schedule.NextCycle; } ExpirationDate = schedule.NextCycle; RepetitionCount = schedule.NumberOfCycles; Expired = schedule.Expired; DaysRemaining = progress.DaysRemaining; DaysTotal = progress.DaysTotal; ProgressPercentage = progress.ProgressPercentage; }
public static int GetDaysRemaining(this Countdown countdown, DateTime now) { var schedule = CountdownCalculator.GetSchedule(countdown, now); var progress = CountdownCalculator.GetProgress(schedule, now); var daysRemaining = progress.DaysRemaining; return(daysRemaining); }
private static bool UpdateNotification(ToastNotifier notifier, string notificationId, Countdown countdown) { var now = DateTime.Now; var schedule = CountdownCalculator.GetSchedule(countdown, now); var date = schedule.NextCycle; var content = CreateNotificationContent(countdown.Name, countdown.GetImageFileUri(), countdown.Guid); var notification = new ScheduledToastNotification(content, new DateTimeOffset(date)) { Id = notificationId }; if (notification.DeliveryTime > DateTime.Now) { notifier.AddToSchedule(notification); return(true); } return(false); }