protected void RetrieveCurrentFeed(SettingsViewModel currentSettings, ActivityScheduleViewModel currentBabiesSchedule) { if (currentBabiesSchedule.CurrentlyFeeding) { currentSettings.InProgressFeedActivityId = currentBabiesSchedule.LastFeed.Id; DefaultViewModel.CurrentFeed = currentBabiesSchedule.LastFeed; var activityDuration = (DateTime.Now - currentBabiesSchedule.LastFeed.StartDate); string currentFeedStatus = activityDuration.Hours > 0 ? string.Format(resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYBUTTONHOURS), activityNameFeed, Math.Floor(activityDuration.TotalHours), activityDuration.Minutes) : string.Format(resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYBUTTONMINUTES), activityNameFeed, Math.Floor(activityDuration.TotalMinutes)); DefaultViewModel.CreateFeedText = currentBabiesSchedule.LastFeed.EndTime == null ? currentFeedStatus : activityNameFeed; } else { DefaultViewModel.CurrentFeed = null; DefaultViewModel.CreateFeedText = activityNameFeed; } }
protected string GetNextActivityFromSchedule(BabyViewModel currentBaby, ActivityScheduleViewModel currentBabiesSchedule) { if (currentBabiesSchedule.LastFeed == null && currentBabiesSchedule.LastSleep == null && currentBabiesSchedule.LastChange == null) { return(resourceLoader.GetString(Constants.RESOURCEKEY_BLURB_WELCOMETOFEEDTIME)); } DefaultViewModel.NextScheduledActivities.Add(Tuple.Create(activityNameFeed, currentBabiesSchedule.NextFeedDueAt, currentBabiesSchedule.CurrentlyFeeding)); DefaultViewModel.NextScheduledActivities.Add(Tuple.Create(activityNameSleep, currentBabiesSchedule.NextSleepDueAt, currentBabiesSchedule.CurrentlySleeping)); DefaultViewModel.NextScheduledActivities.Add(Tuple.Create(resourceLoader.GetString(Constants.RESOURCEKEY_ACTIVITYNAME_CHANGE), currentBabiesSchedule.NextChangeDueAt, false)); var nextActivity = DefaultViewModel.NextScheduledActivities .Where(i => i.Item2 != null && !i.Item3) .MinBy(i => i.Item2); var nextActivityDueIn = nextActivity.Item2 - DateTime.Now; var nextActivityBuilder = new StringBuilder(currentBaby.GivenName); nextActivityBuilder.AppendFormat(resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYDUETO), nextActivity.Item1); if (nextActivityDueIn > TimeSpan.Zero) { string dueInFormat = nextActivityDueIn.Hours > 0 ? resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYINHOURS) : resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYINMINUTES); nextActivityBuilder.AppendFormat(CultureInfo.CurrentCulture, dueInFormat, nextActivityDueIn.Duration()); } else { string dueAgoFormat = nextActivityDueIn.Hours > 0 ? resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYAGOHOURS) : resourceLoader.GetString(Constants.RESOURCEKEY_FORMAT_ACTIVITYAGOMINUTES); nextActivityBuilder.AppendFormat(CultureInfo.CurrentCulture, dueAgoFormat, nextActivityDueIn.Duration()); } return(nextActivityBuilder.ToString()); }
public ActivitySchedulePage() { this.InitializeComponent(); vm = new ActivityScheduleViewModel(); }