private void OnProfileDateChanged(ProfileDate date) { ProfileDate = date; // Close the popup base.IsDropDownOpen = false; }
private void OnProfileDatePropertyChanged(ProfileDate oldValue, ProfileDate newValue) { if (ProfileDate != null) base.Tag = ProfileDate.GetTextFromProfile(); }
public void OnDropDownOpened(bool recreate, ProfileDate profileDate) { _ProfileDate = profileDate; // If necessary, recreate the listbox names, and bind them to the listbox if (x_AgeRanges.Items.Count <= 0 || recreate) { x_AgeRanges.ItemsSource = CreateAgeRangeItems(); x_AgeRanges.UpdateLayout(); if (x_AgeRanges.Items.Count <= 0) return; } // Make the ListBox selection int index = 0; int age = -1; Control focusControl = null; Profile profile = App.Model.ProfileHolder.Profile; ProfileCode profileCode = 0; if (_ProfileDate != null) profileCode = _ProfileDate.ProfileCode; if (profileCode == 0) focusControl = x_Calendar; else { if (profileCode == ProfileCode.StartOfPlan || profileCode == ProfileCode.EndOfPlan) { index = 0; focusControl = (profileCode == ProfileCode.StartOfPlan ? x_PlanStartDate : x_PlanEndDate); } else if (profileCode >= ProfileCode.MeBirth && profileCode <= ProfileCode.MeDeath) { index = 1; age = profileCode - ProfileCode.MeBirth; } else if (profile != null && profile.IncludeSpouse && profileCode >= ProfileCode.SpouseBirth && profileCode <= ProfileCode.SpouseDeath) { index = 2; age = profileCode - ProfileCode.SpouseBirth; } else if (profile != null && profile.IncludeDependents && profileCode >= ProfileCode.DependentMin && profileCode <= ProfileCode.DependentMax) { int dependent = (profileCode - ProfileCode.DependentMin) / ProfileCode.Range; index = 2 + (profile.IncludeSpouse ? 1 : 0) + dependent; age = profileCode - ProfileCode.DependentBirth(dependent); } } x_AgeRanges.SelectedIndex = Math.Min(index, x_AgeRanges.Items.Count - 1); if (age == 0 || age == ProfileCode.Death) { focusControl = (age == 0 ? x_BirthDate : x_DeathDate); age = -1; } if (focusControl != null) focusControl.FocusEx(); else if (age >= 0) x_AgeControl.Age = age; }
internal string ToRelativeProfileText(JulianDay date) { ProfileCode profileCode = base.Value; if (profileCode < 0 || profileCode > Max) profileCode = 0; JulianDay birthDate = 0; double lifeExpectancy = 0; Profile profile = App.Model.ProfileHolder.Profile; if (profileCode == ProfileCode.MeBirth) { birthDate = profile.Me.BirthDate; lifeExpectancy = profile.Me.LifeExpectancy; } else if (profileCode == ProfileCode.SpouseBirth) { if (profile.IncludeSpouse) { birthDate = profile.Spouse.BirthDate; lifeExpectancy = profile.Spouse.LifeExpectancy; } } else if (profileCode >= ProfileCode.DependentMin && profileCode <= ProfileCode.DependentMax) { int dependent = (profileCode - ProfileCode.DependentMin) / ProfileCode.Range; Person person = (profile.IncludeDependents && dependent < profile.Dependents.Count ? profile.Dependents[dependent] : null); if (person != null) { birthDate = person.BirthDate; lifeExpectancy = person.LifeExpectancy; } } if (birthDate == 0) return null; int daysAlive = (int)date - (int)birthDate; if (daysAlive < 0) return null; //j if (daysAlive > JulianDate.YearsToDays(lifeExpectancy)) //j return null; double age = JulianDate.DaysToYears((uint)daysAlive); profileCode += (int)age; ProfileDate pjd = new ProfileDate() { ProfileCode = profileCode, JulianDay = date }; return pjd.GetTextFromProfile(); }
private void SetProfileDate(ProfileDate profileDate) { _ProfileDate = profileDate; if (DateChanged != null) DateChanged(_ProfileDate); }