Example #1
0
        public void Test_LMCommunication()
        {
            var listManager = new CommunicationListMan(fContext);

            Assert.IsNotNull(listManager);

            Assert.IsNotNull(listManager.ContentList);

            listManager.ExternalFilter = null;
            Assert.IsNull(listManager.ExternalFilter);

            GEDCOMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GEDCOMCommunicationRecord;

            listManager.Fetch(commRec);

            listManager.QuickFilter = "*";
            Assert.IsTrue(listManager.CheckFilter());
            listManager.QuickFilter = "*commun*";
            Assert.IsTrue(listManager.CheckFilter());
            listManager.QuickFilter = "*alpha*";
            Assert.IsFalse(listManager.CheckFilter());

            var lvMock = new ListViewMock();

            listManager.UpdateColumns(lvMock);
            var listItem = new GKListItem("", null);

            listManager.UpdateItem(0, listItem, commRec);
        }
Example #2
0
        public override void UpdateContents()
        {
            var research = fDataOwner as GEDCOMResearchRecord;

            if (fSheetList == null || research == null)
            {
                return;
            }

            try
            {
                fSheetList.BeginUpdate();
                fSheetList.ClearItems();

                foreach (GEDCOMPointer commPtr in research.Communications)
                {
                    GEDCOMCommunicationRecord corr = commPtr.Value as GEDCOMCommunicationRecord;
                    if (corr == null)
                    {
                        continue;
                    }

                    fSheetList.AddItem(corr, new object[] { corr.CommName,
                                                            GKUtils.GetCorresponderStr(fBaseWin.Context.Tree, corr, false),
                                                            LangMan.LS(GKData.CommunicationNames[(int)corr.CommunicationType]),
                                                            new GEDCOMDateItem(corr.Date) });
                }

                fSheetList.EndUpdate();
            }
            catch (Exception ex)
            {
                Logger.LogWrite("ResCommunicationsSublistModel.UpdateContents(): " + ex.Message);
            }
        }
Example #3
0
        private void ListCommunicationsModify(object sender, ModifyEventArgs eArgs)
        {
            GEDCOMCommunicationRecord comm = eArgs.ItemData as GEDCOMCommunicationRecord;

            if (eArgs.Action == RecordAction.raJump && comm != null)
            {
                AcceptChanges();
                fBase.SelectRecordByXRef(comm.XRef);
                Close();
            }
        }
        public override void Setup()
        {
            base.Setup();

            fBase                = new BaseWindowStub();
            fContext             = fBase.Context;
            fCommunicationRecord = new GEDCOMCommunicationRecord(fContext.Tree, fContext.Tree, "", "");

            fDialog = new CommunicationEditDlg(fBase);
            fDialog.Communication = fCommunicationRecord;
            fDialog.Show();
        }
Example #5
0
        public static bool ModifyCommunication(IBaseWindow baseWin, ref GEDCOMCommunicationRecord commRec)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();
                GEDCOMTree tree = baseWin.Context.Tree;

                using (var dlg = AppHost.Container.Resolve <ICommunicationEditDlg>())
                {
                    dlg.InitDialog(baseWin);

                    bool exists = commRec != null;
                    if (!exists)
                    {
                        commRec = new GEDCOMCommunicationRecord(tree, tree, "", "");
                        commRec.InitNew();
                    }

                    try {
                        baseWin.Context.LockRecord(commRec);

                        dlg.Communication = commRec;
                        result            = AppHost.Instance.ShowModalX(dlg, false);
                    } finally {
                        baseWin.Context.UnlockRecord(commRec);
                    }

                    if (!exists)
                    {
                        if (result)
                        {
                            tree.AddRecord(commRec);
                        }
                        else
                        {
                            commRec.Dispose();
                            commRec = null;
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Example #6
0
        private void SetCommunication(GEDCOMCommunicationRecord value)
        {
            fCommunication = value;
            try
            {
                if (fCommunication == null)
                {
                    txtName.Text = "";
                    cmbCorrType.SelectedIndex = -1;
                    txtDate.Text         = "";
                    txtDir.SelectedIndex = 0;
                    txtCorresponder.Text = "";
                }
                else
                {
                    txtName.Text = fCommunication.CommName;
                    cmbCorrType.SelectedIndex = (int)fCommunication.CommunicationType;
                    txtDate.Text = fCommunication.Date.GetDisplayString(DateFormat.dfDD_MM_YYYY);

                    var corr = fCommunication.GetCorresponder();
                    fTempInd = corr.Corresponder;

                    if (fTempInd != null)
                    {
                        txtDir.SelectedIndex = (int)corr.CommDir;
                        txtCorresponder.Text = GKUtils.GetNameString(fTempInd, true, false);
                    }
                    else
                    {
                        txtDir.SelectedIndex = 0;
                        txtCorresponder.Text = "";
                    }
                }

                fNotesList.ListModel.DataOwner = fCommunication;
                fMediaList.ListModel.DataOwner = fCommunication;
            }
            catch (Exception ex)
            {
                Logger.LogWrite("CommunicationEditDlg.SetCommunication(): " + ex.Message);
            }
        }
Example #7
0
        public override void Modify(object sender, ModifyEventArgs eArgs)
        {
            var research = fDataOwner as GEDCOMResearchRecord;

            if (fBaseWin == null || fSheetList == null || research == null)
            {
                return;
            }

            GEDCOMCommunicationRecord comm = eArgs.ItemData as GEDCOMCommunicationRecord;

            bool result = false;

            switch (eArgs.Action)
            {
            case RecordAction.raAdd:
                comm   = fBaseWin.Context.SelectRecord(GEDCOMRecordType.rtCommunication, null) as GEDCOMCommunicationRecord;
                result = fUndoman.DoOrdinaryOperation(OperationType.otResearchCommunicationAdd, research, comm);
                break;

            case RecordAction.raEdit:
                result = (comm != null && BaseController.ModifyCommunication(fBaseWin, ref comm));
                break;

            case RecordAction.raDelete:
                if (comm != null && AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachCommunicationQuery)))
                {
                    result = fUndoman.DoOrdinaryOperation(OperationType.otResearchCommunicationRemove, research, comm);
                }
                break;
            }

            if (result)
            {
                fBaseWin.Context.Modified = true;
                eArgs.IsChanged           = true;
            }
        }
Example #8
0
        private bool ProcessResearchCommunication(bool redo)
        {
            GEDCOMResearchRecord      resRec  = fObj as GEDCOMResearchRecord;
            GEDCOMCommunicationRecord commRec = fNewVal as GEDCOMCommunicationRecord;

            if (resRec == null || commRec == null)
            {
                return(false);
            }

            if (fType == OperationType.otResearchCommunicationRemove)
            {
                redo = !redo;
            }
            if (redo)
            {
                resRec.AddCommunication(commRec);
            }
            else
            {
                resRec.RemoveCommunication(commRec);
            }
            return(true);
        }
Example #9
0
        public static void FillContext(IBaseContext context)
        {
            // a null result if the record is not defined
            GEDCOMCustomEvent evt = context.CreateEventEx(null, "BIRT", "xxxxx", "xxxxx");

            Assert.IsNull(evt);

            // first individual
            GEDCOMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GEDCOMSex.svMale, true);

            Assert.IsNotNull(iRec);

            evt = iRec.FindEvent("BIRT");
            Assert.IsNotNull(evt);
            evt.Date.ParseString("28 DEC 1990");
            evt.Place.StringValue = "Ivanovo";

            GEDCOMCustomEvent evtd = context.CreateEventEx(iRec, "DEAT", "28 DEC 2010", "Ivanovo");

            Assert.IsNotNull(evtd);

            // second individual, wife
            GEDCOMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GEDCOMSex.svFemale, true);

            evt = iRec2.FindEvent("BIRT");
            Assert.IsNotNull(evt);
            evt.Date.ParseString("17 MAR 1990");
            evt.Place.StringValue = "Ivanovo";

            iRec.AddAssociation("spouse", iRec2);

            // third individual, child
            GEDCOMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GEDCOMSex.svFemale, true);

            evt = iRec3.FindEvent("BIRT");
            Assert.IsNotNull(evt);
            evt.Date.ParseString("11 FEB 2010");
            evt.Place.StringValue = "Ivanovo";

            // their family
            GEDCOMFamilyRecord famRec = context.Tree.CreateFamily();

            Assert.IsNotNull(famRec);
            famRec.AddSpouse(iRec);
            famRec.AddSpouse(iRec2);
            famRec.AddChild(iRec3);

            context.CreateEventEx(famRec, "MARR", "01 JAN 2000", "unknown");

            // individual outside the family
            GEDCOMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GEDCOMSex.svMale, true);

            evt = iRec4.FindEvent("BIRT");
            Assert.IsNotNull(evt);
            evt.Date.ParseString("15 JUN 1989");
            evt.Place.StringValue = "Far Forest";

            evt = context.CreateEventEx(iRec4, "RESI", "12 FEB", "Far Forest");
            Assert.IsNotNull(evt);

            // fifth
            GEDCOMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GEDCOMSex.svFemale, false);

            Assert.IsNotNull(iRec5);

            // group for tests
            GEDCOMGroupRecord groupRec = context.Tree.CreateGroup();

            groupRec.GroupName = "GroupTest";
            Assert.IsNotNull(groupRec, "group1 != null");
            groupRec.AddMember(iRec);

            // location for tests
            GEDCOMLocationRecord locRec = context.Tree.CreateLocation();

            locRec.LocationName = "Test Location";
            locRec.Map.Lati     = 5.11111;
            locRec.Map.Long     = 7.99999;
            Assert.IsNotNull(locRec, "locRec != null");

            // repository for tests
            GEDCOMRepositoryRecord repoRec = context.Tree.CreateRepository();

            repoRec.RepositoryName = "Test repository";
            Assert.IsNotNull(repoRec, "repoRec != null");

            // research for tests
            GEDCOMResearchRecord resRec = context.Tree.CreateResearch();

            resRec.ResearchName = "Test research";
            Assert.IsNotNull(resRec, "resRec != null");

            // source for tests
            GEDCOMSourceRecord srcRec = context.Tree.CreateSource();

            srcRec.FiledByEntry = "Test source";
            Assert.IsNotNull(srcRec, "srcRec != null");
            iRec.AddSource(srcRec, "p1", 0);

            // note for tests
            GEDCOMNoteRecord noteRec = context.Tree.CreateNote();

            noteRec.SetNoteText("Test note");
            Assert.IsNotNull(noteRec, "noteRec != null");
            iRec.AddNote(noteRec);

            // task for tests
            GEDCOMTaskRecord tskRec = context.Tree.CreateTask();

            tskRec.Goal = "Test task";
            Assert.IsNotNull(tskRec, "tskRec != null");

            // media for tests
            GEDCOMMultimediaRecord mediaRec = context.Tree.CreateMultimedia();

            mediaRec.AddTag("FILE", "", null);
            GEDCOMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0];

            fileRef.Title = "Test multimedia";
            fileRef.LinkFile("sample.png");
            Assert.IsNotNull(mediaRec, "mediaRec != null");
            iRec.AddMultimedia(mediaRec);

            // communication for tests
            GEDCOMCommunicationRecord commRec = context.Tree.CreateCommunication();

            commRec.CommName = "Test communication";
            Assert.IsNotNull(commRec, "commRec != null");
        }
Example #10
0
        public void Test_ShowXInfo()
        {
            StringList summary = new StringList();

            summary.Clear();
            GKUtils.ShowFamilyInfo(fContext, null, null);
            GEDCOMFamilyRecord famRec = fContext.Tree.XRefIndex_Find("F1") as GEDCOMFamilyRecord;

            GKUtils.ShowFamilyInfo(fContext, famRec, summary);

            summary.Clear();
            GKUtils.ShowGroupInfo(null, null);
            GEDCOMGroupRecord grpRec = fContext.Tree.XRefIndex_Find("G1") as GEDCOMGroupRecord;

            GKUtils.ShowGroupInfo(grpRec, summary);

            summary.Clear();
            GKUtils.ShowMultimediaInfo(null, null);
            GEDCOMMultimediaRecord mmRec = fContext.Tree.XRefIndex_Find("O1") as GEDCOMMultimediaRecord;

            GKUtils.ShowMultimediaInfo(mmRec, summary);

            summary.Clear();
            GKUtils.ShowNoteInfo(null, null);
            GEDCOMNoteRecord noteRec = fContext.Tree.XRefIndex_Find("N1") as GEDCOMNoteRecord;

            GKUtils.ShowNoteInfo(noteRec, summary);

            summary.Clear();
            GKUtils.ShowPersonInfo(fContext, null, null);
            GEDCOMIndividualRecord indRec = fContext.Tree.XRefIndex_Find("I1") as GEDCOMIndividualRecord;

            GKUtils.ShowPersonInfo(fContext, indRec, summary);

            summary.Clear();
            GKUtils.ShowSourceInfo(null, null);
            GEDCOMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GEDCOMSourceRecord;

            GKUtils.ShowSourceInfo(srcRec, summary);

            summary.Clear();
            GKUtils.ShowRepositoryInfo(null, null);
            GEDCOMRepositoryRecord repRec = fContext.Tree.XRefIndex_Find("R1") as GEDCOMRepositoryRecord;

            GKUtils.ShowRepositoryInfo(repRec, summary);

            summary.Clear();
            GKUtils.ShowResearchInfo(null, null);
            GEDCOMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GEDCOMResearchRecord;

            GKUtils.ShowResearchInfo(resRec, summary);

            summary.Clear();
            GKUtils.ShowTaskInfo(null, null);
            GEDCOMTaskRecord taskRec = fContext.Tree.XRefIndex_Find("TK1") as GEDCOMTaskRecord;

            GKUtils.ShowTaskInfo(taskRec, summary);

            summary.Clear();
            GKUtils.ShowCommunicationInfo(null, null);
            GEDCOMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GEDCOMCommunicationRecord;

            GKUtils.ShowCommunicationInfo(commRec, summary);

            summary.Clear();
            GKUtils.ShowLocationInfo(null, null);
            GEDCOMLocationRecord locRec = fContext.Tree.XRefIndex_Find("L1") as GEDCOMLocationRecord;

            GKUtils.ShowLocationInfo(locRec, summary);
        }
Example #11
0
 public override void Fetch(GEDCOMRecord aRec)
 {
     fRec = (aRec as GEDCOMCommunicationRecord);
 }
Example #12
0
        public static bool EditRecord(IBaseWindow baseWin, GEDCOMRecord rec)
        {
            bool result = false;

            switch (rec.RecordType)
            {
            case GEDCOMRecordType.rtIndividual:
                GEDCOMIndividualRecord ind = rec as GEDCOMIndividualRecord;
                result = ModifyIndividual(baseWin, ref ind, null, TargetMode.tmNone, GEDCOMSex.svNone);
                break;

            case GEDCOMRecordType.rtFamily:
                GEDCOMFamilyRecord fam = rec as GEDCOMFamilyRecord;
                result = ModifyFamily(baseWin, ref fam, TargetMode.tmNone, null);
                break;

            case GEDCOMRecordType.rtNote:
                GEDCOMNoteRecord note = rec as GEDCOMNoteRecord;
                result = ModifyNote(baseWin, ref note);
                break;

            case GEDCOMRecordType.rtMultimedia:
                GEDCOMMultimediaRecord mmRec = rec as GEDCOMMultimediaRecord;
                result = ModifyMedia(baseWin, ref mmRec);
                break;

            case GEDCOMRecordType.rtSource:
                GEDCOMSourceRecord src = rec as GEDCOMSourceRecord;
                result = ModifySource(baseWin, ref src);
                break;

            case GEDCOMRecordType.rtRepository:
                GEDCOMRepositoryRecord rep = rec as GEDCOMRepositoryRecord;
                result = ModifyRepository(baseWin, ref rep);
                break;

            case GEDCOMRecordType.rtGroup:
                GEDCOMGroupRecord grp = rec as GEDCOMGroupRecord;
                result = ModifyGroup(baseWin, ref grp);
                break;

            case GEDCOMRecordType.rtResearch:
                GEDCOMResearchRecord rsr = rec as GEDCOMResearchRecord;
                result = ModifyResearch(baseWin, ref rsr);
                break;

            case GEDCOMRecordType.rtTask:
                GEDCOMTaskRecord tsk = rec as GEDCOMTaskRecord;
                result = ModifyTask(baseWin, ref tsk);
                break;

            case GEDCOMRecordType.rtCommunication:
                GEDCOMCommunicationRecord comm = rec as GEDCOMCommunicationRecord;
                result = ModifyCommunication(baseWin, ref comm);
                break;

            case GEDCOMRecordType.rtLocation:
                GEDCOMLocationRecord loc = rec as GEDCOMLocationRecord;
                result = ModifyLocation(baseWin, ref loc);
                break;
            }

            return(result);
        }
Example #13
0
        public static GEDCOMRecord AddRecord(IBaseWindow baseWin, GEDCOMRecordType rt, Target target)
        {
            bool         result = false;
            GEDCOMRecord rec    = null;

            switch (rt)
            {
            case GEDCOMRecordType.rtIndividual:
            {
                // FIXME: legacy code, checkit
                if (target == null)
                {
                    target            = new Target();
                    target.TargetMode = TargetMode.tmParent;
                }

                GEDCOMIndividualRecord indivRec = null;
                result = ModifyIndividual(baseWin, ref indivRec, target.TargetIndividual, target.TargetMode, target.NeedSex);
                rec    = indivRec;
                break;
            }

            case GEDCOMRecordType.rtFamily:
            {
                if (target == null)
                {
                    target = new Target();
                }

                TargetMode famTarget = (target.TargetMode != TargetMode.tmFamilyChild) ? TargetMode.tmNone : target.TargetMode;

                GEDCOMFamilyRecord fam = null;
                result = ModifyFamily(baseWin, ref fam, famTarget, target.TargetIndividual);
                rec    = fam;
                break;
            }

            case GEDCOMRecordType.rtNote:
            {
                GEDCOMNoteRecord note = null;
                result = ModifyNote(baseWin, ref note);
                rec    = note;
                break;
            }

            case GEDCOMRecordType.rtMultimedia:
            {
                GEDCOMMultimediaRecord mmRec = null;
                result = ModifyMedia(baseWin, ref mmRec);
                rec    = mmRec;
                break;
            }

            case GEDCOMRecordType.rtSource:
            {
                GEDCOMSourceRecord src = null;
                result = ModifySource(baseWin, ref src);
                rec    = src;
                break;
            }

            case GEDCOMRecordType.rtRepository:
            {
                GEDCOMRepositoryRecord rep = null;
                result = ModifyRepository(baseWin, ref rep);
                rec    = rep;
                break;
            }

            case GEDCOMRecordType.rtGroup:
            {
                GEDCOMGroupRecord grp = null;
                result = ModifyGroup(baseWin, ref grp);
                rec    = grp;
                break;
            }

            case GEDCOMRecordType.rtResearch:
            {
                GEDCOMResearchRecord rsr = null;
                result = ModifyResearch(baseWin, ref rsr);
                rec    = rsr;
                break;
            }

            case GEDCOMRecordType.rtTask:
            {
                GEDCOMTaskRecord tsk = null;
                result = ModifyTask(baseWin, ref tsk);
                rec    = tsk;
                break;
            }

            case GEDCOMRecordType.rtCommunication:
            {
                GEDCOMCommunicationRecord comm = null;
                result = ModifyCommunication(baseWin, ref comm);
                rec    = comm;
                break;
            }

            case GEDCOMRecordType.rtLocation:
            {
                GEDCOMLocationRecord loc = null;
                result = ModifyLocation(baseWin, ref loc);
                rec    = loc;
                break;
            }
            }

            return((result) ? rec : null);
        }