示例#1
0
		internal ProfileDate UpdateFromProfile()
		{
			if (_ProfileCode < 0 || _ProfileCode > ProfileCode.Max)
				_ProfileCode = 0;

			if (_ProfileCode == 0)
				return this;

			Profile profile = App.Model.ProfileHolder.Profile;
			if (_ProfileCode == ProfileCode.StartOfPlan)
				_JulianDay = profile.StartProfileDate.JulianDay;
			else
			if (_ProfileCode == ProfileCode.EndOfPlan)
				_JulianDay = profile.EndProfileDate.JulianDay;
			else
			if (_ProfileCode >= ProfileCode.MeBirth && _ProfileCode <= ProfileCode.MeDeath)
			{
				if (profile.Me.BirthDate != 0)
				{
					int age = _ProfileCode - ProfileCode.MeBirth;
					_JulianDay = profile.Me.BirthDate + JulianDate.YearsToDays(
						age != ProfileCode.Death ? age : profile.Me.LifeExpectancy);
				}
			}
			else
			if (_ProfileCode >= ProfileCode.SpouseBirth && _ProfileCode <= ProfileCode.SpouseDeath)
			{
				if (profile.IncludeSpouse && profile.Spouse.BirthDate != 0)
				{
					int age = _ProfileCode - ProfileCode.SpouseBirth;
					_JulianDay = profile.Spouse.BirthDate + JulianDate.YearsToDays(
						age != ProfileCode.Death ? age : 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[(int)dependent] : null);
				if (person != null && person.BirthDate != 0)
				{
					int age = _ProfileCode - ProfileCode.DependentBirth(dependent);
					_JulianDay = person.BirthDate + JulianDate.YearsToDays(
						age != ProfileCode.Death ? age : person.LifeExpectancy);
				}
			}

			return this;
		}
示例#2
0
		private void OnListSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			ListBox listBox = sender as ListBox;
			bool showAgeControls = (listBox.SelectedIndex > 0);
			x_PlanControls.SetVisible(!showAgeControls);
			x_AgeControls.SetVisible(showAgeControls);

			ListBoxItem listBoxItem = listBox.SelectedItem as ListBoxItem;
			if (listBoxItem != null && (listBoxItem.Tag is ProfileCode))
				_ListItemProfileCode = listBoxItem.Tag as ProfileCode;
			else
				_ListItemProfileCode = 0;

			if (!showAgeControls && _ProfileDate != null)
			{
				x_Calendar.DisplayDate = _ProfileDate.JulianDay.ToDateTime();
				x_Calendar.SelectedDate = x_Calendar.DisplayDate;
			}
		}
示例#3
0
		public void Init()
		{
			_JulianDay = DateTime.Now.ToJulian();
			_ProfileCode = 0;
		}