private static void GetBackReferences(GDMRecord inRecord, GDMRecord subject, List <BackReference> list) { try { if (subject is GDMSourceRecord) { int num = inRecord.SourceCitations.Count; for (int i = 0; i < num; i++) { if (inRecord.SourceCitations[i].XRef == subject.XRef) { list.Add(new BackReference(inRecord.RecordType, inRecord.XRef, "")); } } var recordWithEvents = inRecord as GDMRecordWithEvents; if (recordWithEvents != null) { GDMRecordWithEvents evsRec = recordWithEvents; num = evsRec.Events.Count; for (int i = 0; i < num; i++) { var evt = evsRec.Events[i]; int num2 = evt.SourceCitations.Count; for (int k = 0; k < num2; k++) { if (evt.SourceCitations[k].XRef == subject.XRef) { list.Add(new BackReference(inRecord.RecordType, inRecord.XRef, evt.GetTagName())); } } } } } } catch (Exception ex) { Logger.WriteError("GMHelper.GetBackReferences()", ex); } }
private void CollectData() { int num = fBase.Context.Tree.RecordsCount; for (int i = 0; i < num; i++) { GDMRecordWithEvents rec = fBase.Context.Tree[i] as GDMRecordWithEvents; if (rec == null) { continue; } int eventsCount = rec.Events.Count; for (int k = 0; k < eventsCount; k++) { GDMCustomEvent evt = rec.Events[k]; UDN udn = evt.Date.GetUDN(); if (!udn.IsEmpty()) { fEvents.Add(new EventRecord(evt, rec)); } } } }
private bool ProcessRecordEvent(bool redo) { GDMRecordWithEvents rwe = fObj as GDMRecordWithEvents; GDMCustomEvent evt = fNewVal as GDMCustomEvent; if (rwe == null || evt == null) { return(false); } if (fType == OperationType.otRecordEventRemove) { redo = !redo; } if (redo) { rwe.AddEvent(evt); } else { rwe.Events.Extract(evt); // bugfix(no delete!) } return(true); }
public EventRecord(GDMCustomEvent evt, GDMRecordWithEvents record) { Event = evt; Record = record; }
public override void Modify(object sender, ModifyEventArgs eArgs) { var dataOwner = fDataOwner as IGEDCOMStructWithLists; if (fBaseWin == null || fSheetList == null || dataOwner == null) { return; } GDMCustomEvent evt = eArgs.ItemData as GDMCustomEvent; GDMRecordWithEvents record = dataOwner as GDMRecordWithEvents; bool result = false; try { switch (eArgs.Action) { case RecordAction.raAdd: case RecordAction.raEdit: using (var dlgEventEdit = AppHost.ResolveDialog <IEventEditDlg>(fBaseWin)) { bool exists = (evt != null); GDMCustomEvent newEvent; if (evt != null) { newEvent = evt; } else { if (record is GDMIndividualRecord) { newEvent = new GDMIndividualEvent(record); } else { newEvent = new GDMFamilyEvent(record); } } dlgEventEdit.Event = newEvent; result = AppHost.Instance.ShowModalX(dlgEventEdit, true); if (!result) { if (!exists) { newEvent.Dispose(); } } else { newEvent = dlgEventEdit.Event; if (!exists) { result = fUndoman.DoOrdinaryOperation(OperationType.otRecordEventAdd, record, newEvent); } else { if (record is GDMIndividualRecord && newEvent != evt) { fUndoman.DoOrdinaryOperation(OperationType.otRecordEventRemove, record, evt); result = fUndoman.DoOrdinaryOperation(OperationType.otRecordEventAdd, record, newEvent); } } evt = newEvent; fBaseWin.Context.CollectEventValues(evt); } } break; case RecordAction.raDelete: if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_RemoveEventQuery))) { result = fUndoman.DoOrdinaryOperation(OperationType.otRecordEventRemove, record, evt); evt = null; } break; case RecordAction.raMoveUp: case RecordAction.raMoveDown: { int idx = record.Events.IndexOf(evt); switch (eArgs.Action) { case RecordAction.raMoveUp: record.Events.Exchange(idx - 1, idx); break; case RecordAction.raMoveDown: record.Events.Exchange(idx, idx + 1); break; } result = true; } break; } } catch (Exception ex) { Logger.LogWrite("EventsListModel.Modify(): " + ex.Message); result = false; } if (result) { if (eArgs.Action == RecordAction.raAdd) { eArgs.ItemData = evt; } fBaseWin.Context.Modified = true; eArgs.IsChanged = true; } }
private void SetEvent(GDMRecordWithEvents record, string evName, string date) { int[] val = new int[3]; GDMCustomEvent evt = fBase.Context.CreateEventEx(record, evName, "", ""); try { string prefix = ""; if (date.IndexOf("п.") == 0) { prefix = "AFT "; date = date.Remove(0, 2); } else if (date.IndexOf("после") == 0) { prefix = "AFT "; date = date.Remove(0, 5); } else if (date.IndexOf("до") == 0) { prefix = "BEF "; date = date.Remove(0, 2); } else if (date.IndexOf("ок.") == 0) { prefix = "ABT "; date = date.Remove(0, 3); } else if (date.IndexOf("около") == 0) { prefix = "ABT "; date = date.Remove(0, 5); } date = date.Trim(); string tmp = ""; string[] toks = date.Split('.'); if (toks.Length > 3) { throw new ImporterException("date failed"); } string ym = ""; for (int i = 0; i < toks.Length; i++) { tmp = toks[i]; int x = tmp.IndexOf("/"); if (x >= 0) { ym = tmp.Substring(x + 1, tmp.Length - x - 1); tmp = tmp.Remove(x, ym.Length + 1); } val[i] = int.Parse(tmp); } if (toks.Length != 1) { if (toks.Length != 2) { if (toks.Length == 3) { tmp = val[0].ToString() + " " + GEDCOMConsts.GEDCOMMonthArray[val[1] - 1] + " " + val[2].ToString(); } } else { tmp = GEDCOMConsts.GEDCOMMonthArray[val[0] - 1] + " " + val[1].ToString(); } } else { tmp = val[0].ToString(); } tmp = prefix + tmp; if (ym != "") { tmp = tmp + "/" + ym; } evt.Date.ParseString(tmp); } catch (Exception) { fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_ParseError_DateInvalid) + " \"" + date + "\""); } }