Ejemplo n.º 1
0
        public override bool Accept()
        {
            try {
                fEvent.Place.StringValue    = fView.Place.Text;
                fEvent.Place.Location.Value = fTempLocation;
                fEvent.Classification       = fView.EventName.Text;
                fEvent.Cause  = fView.Cause.Text;
                fEvent.Agency = fView.Agency.Text;

                GEDCOMCustomDate dt = AssembleDate();
                if (dt == null)
                {
                    throw new ArgumentNullException("dt");
                }

                fEvent.Date.ParseString(dt.StringValue);

                int eventType = fView.EventType.SelectedIndex;
                if (fEvent is GEDCOMFamilyEvent)
                {
                    fEvent.SetName(GKData.FamilyEvents[eventType].Sign);
                }
                else
                {
                    fEvent.SetName(GKData.PersonEvents[eventType].Sign);
                    if (GKData.PersonEvents[eventType].Kind == PersonEventKind.ekFact)
                    {
                        fEvent.StringValue = fView.Attribute.Text;
                    }
                    else
                    {
                        fEvent.StringValue = "";
                    }
                }

                if (fEvent is GEDCOMIndividualEvent)
                {
                    if (GKData.PersonEvents[eventType].Kind == PersonEventKind.ekFact)
                    {
                        GEDCOMIndividualAttribute attr = new GEDCOMIndividualAttribute(fEvent.Owner, fEvent.Parent, "", "");
                        attr.Assign(fEvent);
                        fEvent = attr;
                    }
                }

                CommitChanges();

                return(true);
            } catch (Exception ex) {
                Logger.LogWrite("EventEditController.Accept(): " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void AcceptChanges()
        {
            fEvent.Place.StringValue    = txtEventPlace.Text;
            fEvent.Place.Location.Value = fLocation;
            fEvent.Classification       = txtEventName.Text;
            fEvent.Cause  = txtEventCause.Text;
            fEvent.Agency = txtEventOrg.Text;

            GEDCOMCustomDate dt = AssembleDate();

            if (dt == null)
            {
                throw new ArgumentNullException("dt");
            }

            fEvent.Date.ParseString(dt.StringValue);

            if (fEvent is GEDCOMFamilyEvent)
            {
                fEvent.SetName(GKData.FamilyEvents[cmbEventType.SelectedIndex].Sign);
            }
            else
            {
                int id = cmbEventType.SelectedIndex;
                fEvent.SetName(GKData.PersonEvents[id].Sign);
                if (GKData.PersonEvents[id].Kind == PersonEventKind.ekFact)
                {
                    fEvent.StringValue = txtAttribute.Text;
                }
                else
                {
                    fEvent.StringValue = "";
                }
            }

            if (fEvent is GEDCOMIndividualEvent)
            {
                int id = cmbEventType.SelectedIndex;
                if (GKData.PersonEvents[id].Kind == PersonEventKind.ekFact)
                {
                    GEDCOMIndividualAttribute attr = new GEDCOMIndividualAttribute(fEvent.Owner, fEvent.Parent, "", "");
                    attr.Assign(fEvent);
                    fEvent = attr;
                }
            }

            CommitChanges();
        }