private void SetDate(GDMCustomDate date) { if (date is GDMDateRange) { GDMDateRange dtRange = date as GDMDateRange; if (dtRange.After.StringValue == "" && dtRange.Before.StringValue != "") { cmbDateType.SelectedIndex = 1; } else if (dtRange.After.StringValue != "" && dtRange.Before.StringValue == "") { cmbDateType.SelectedIndex = 2; } else if (dtRange.After.StringValue != "" && dtRange.Before.StringValue != "") { cmbDateType.SelectedIndex = 3; } txtDate1.NormalizeDate = dtRange.After.GetDisplayString(DateFormat.dfDD_MM_YYYY); txtDate2.NormalizeDate = dtRange.Before.GetDisplayString(DateFormat.dfDD_MM_YYYY); cmbDate1Calendar.SetSelectedTag <GDMCalendar>(dtRange.After.DateCalendar); cmbDate2Calendar.SetSelectedTag <GDMCalendar>(dtRange.Before.DateCalendar); chkBC1.Checked = dtRange.After.YearBC; chkBC2.Checked = dtRange.Before.YearBC; } else if (date is GDMDatePeriod) { GDMDatePeriod dtPeriod = date as GDMDatePeriod; if (dtPeriod.DateFrom.StringValue != "" && dtPeriod.DateTo.StringValue == "") { cmbDateType.SelectedIndex = 4; } else if (dtPeriod.DateFrom.StringValue == "" && dtPeriod.DateTo.StringValue != "") { cmbDateType.SelectedIndex = 5; } else if (dtPeriod.DateFrom.StringValue != "" && dtPeriod.DateTo.StringValue != "") { cmbDateType.SelectedIndex = 6; } txtDate1.NormalizeDate = dtPeriod.DateFrom.GetDisplayString(DateFormat.dfDD_MM_YYYY); txtDate2.NormalizeDate = dtPeriod.DateTo.GetDisplayString(DateFormat.dfDD_MM_YYYY); cmbDate1Calendar.SetSelectedTag <GDMCalendar>(dtPeriod.DateFrom.DateCalendar); cmbDate2Calendar.SetSelectedTag <GDMCalendar>(dtPeriod.DateTo.DateCalendar); chkBC1.Checked = dtPeriod.DateFrom.YearBC; chkBC2.Checked = dtPeriod.DateTo.YearBC; } else if (date is GDMDate) { GDMApproximated approximated = (date as GDMDate).Approximated; switch (approximated) { case GDMApproximated.daExact: cmbDateType.SelectedIndex = 0; break; case GDMApproximated.daAbout: cmbDateType.SelectedIndex = 7; break; case GDMApproximated.daCalculated: cmbDateType.SelectedIndex = 8; break; case GDMApproximated.daEstimated: cmbDateType.SelectedIndex = 9; break; } txtDate1.NormalizeDate = (date as GDMDate).GetDisplayString(DateFormat.dfDD_MM_YYYY); cmbDate1Calendar.SetSelectedTag <GDMCalendar>((date as GDMDate).DateCalendar); chkBC1.Checked = (date as GDMDate).YearBC; } else { cmbDateType.SelectedIndex = 0; txtDate1.NormalizeDate = ""; cmbDate1Calendar.SetSelectedTag <GDMCalendar>(GDMCalendar.dcGregorian); chkBC1.Checked = false; } }
public override void UpdateView() { fView.NotesList.ListModel.DataOwner = fEvent; fView.MediaList.ListModel.DataOwner = fEvent; fView.SourcesList.ListModel.DataOwner = fEvent; var evtName = fEvent.GetTagName(); if (fEvent is GDMFamilyEvent) { SetEventTypes(GKData.FamilyEvents); int idx = GKUtils.GetFamilyEventIndex(evtName); if (idx < 0) { idx = 0; } fView.EventType.SelectedIndex = idx; } else { SetEventTypes(GKData.PersonEvents); int idx = GKUtils.GetPersonEventIndex(evtName); if (idx < 0) { idx = 0; } fView.EventType.SelectedIndex = idx; if (idx >= 0 && GKData.PersonEvents[idx].Kind == PersonEventKind.ekFact) { fView.Attribute.Text = fEvent.StringValue; } } ChangeEventType(); GDMCustomDate date = fEvent.Date.Value; if (date is GDMDateRange) { GDMDateRange dtRange = date as GDMDateRange; if (dtRange.After.StringValue == "" && dtRange.Before.StringValue != "") { fView.EventDateType.SelectedIndex = 1; } else if (dtRange.After.StringValue != "" && dtRange.Before.StringValue == "") { fView.EventDateType.SelectedIndex = 2; } else if (dtRange.After.StringValue != "" && dtRange.Before.StringValue != "") { fView.EventDateType.SelectedIndex = 3; } fView.Date1.NormalizeDate = dtRange.After.GetDisplayString(DateFormat.dfDD_MM_YYYY); fView.Date2.NormalizeDate = dtRange.Before.GetDisplayString(DateFormat.dfDD_MM_YYYY); fView.Date1Calendar.SetSelectedTag <GDMCalendar>(dtRange.After.DateCalendar); fView.Date2Calendar.SetSelectedTag <GDMCalendar>(dtRange.Before.DateCalendar); fView.Date1BC.Checked = dtRange.After.YearBC; fView.Date2BC.Checked = dtRange.Before.YearBC; } else if (date is GDMDatePeriod) { GDMDatePeriod dtPeriod = date as GDMDatePeriod; if (dtPeriod.DateFrom.StringValue != "" && dtPeriod.DateTo.StringValue == "") { fView.EventDateType.SelectedIndex = 4; } else if (dtPeriod.DateFrom.StringValue == "" && dtPeriod.DateTo.StringValue != "") { fView.EventDateType.SelectedIndex = 5; } else if (dtPeriod.DateFrom.StringValue != "" && dtPeriod.DateTo.StringValue != "") { fView.EventDateType.SelectedIndex = 6; } fView.Date1.NormalizeDate = dtPeriod.DateFrom.GetDisplayString(DateFormat.dfDD_MM_YYYY); fView.Date2.NormalizeDate = dtPeriod.DateTo.GetDisplayString(DateFormat.dfDD_MM_YYYY); fView.Date1Calendar.SetSelectedTag <GDMCalendar>(dtPeriod.DateFrom.DateCalendar); fView.Date2Calendar.SetSelectedTag <GDMCalendar>(dtPeriod.DateTo.DateCalendar); fView.Date1BC.Checked = dtPeriod.DateFrom.YearBC; fView.Date2BC.Checked = dtPeriod.DateTo.YearBC; } else if (date is GDMDate) { GDMApproximated approximated = (date as GDMDate).Approximated; switch (approximated) { case GDMApproximated.daExact: fView.EventDateType.SelectedIndex = 0; break; case GDMApproximated.daAbout: fView.EventDateType.SelectedIndex = 7; break; case GDMApproximated.daCalculated: fView.EventDateType.SelectedIndex = 8; break; case GDMApproximated.daEstimated: fView.EventDateType.SelectedIndex = 9; break; } fView.Date1.NormalizeDate = (date as GDMDate).GetDisplayString(DateFormat.dfDD_MM_YYYY); fView.Date1Calendar.SetSelectedTag <GDMCalendar>((date as GDMDate).DateCalendar); fView.Date1BC.Checked = (date as GDMDate).YearBC; } else { fView.EventDateType.SelectedIndex = 0; fView.Date1.NormalizeDate = ""; fView.Date1Calendar.SetSelectedTag <GDMCalendar>(GDMCalendar.dcGregorian); fView.Date1BC.Checked = false; } ChangeDateType(); fView.EventName.Text = fEvent.Classification; fView.Cause.Text = fEvent.Cause; fView.Agency.Text = fEvent.Agency; fTempLocation = (fEvent.Place.Location.Value as GDMLocationRecord); UpdatePlace(); fView.NotesList.UpdateSheet(); fView.MediaList.UpdateSheet(); fView.SourcesList.UpdateSheet(); }