Пример #1
0
        private void SetResearch(GEDCOMResearchRecord value)
        {
            fResearch = value;
            try {
                if (fResearch == null)
                {
                    txtName.Text = "";
                    cmbPriority.SelectedIndex = -1;
                    cmbStatus.SelectedIndex   = -1;
                    txtStartDate.Text         = "";
                    txtStopDate.Text          = "";
                    nudPercent.Value          = 0;
                }
                else
                {
                    txtName.Text = fResearch.ResearchName;
                    cmbPriority.SelectedIndex = (int)fResearch.Priority;
                    cmbStatus.SelectedIndex   = (int)fResearch.Status;
                    txtStartDate.Text         = fResearch.StartDate.GetDisplayString(DateFormat.dfDD_MM_YYYY);
                    txtStopDate.Text          = fResearch.StopDate.GetDisplayString(DateFormat.dfDD_MM_YYYY);
                    nudPercent.Value          = fResearch.Percent;
                }

                fNotesList.ListModel.DataOwner          = fResearch;
                fTasksList.ListModel.DataOwner          = fResearch;
                fCommunicationsList.ListModel.DataOwner = fResearch;
                fGroupsList.ListModel.DataOwner         = fResearch;
            } catch (Exception ex) {
                Logger.LogWrite("ResearchEditDlg.SetResearch(): " + ex.Message);
            }
        }
Пример #2
0
        public override void Setup()
        {
            base.Setup();

            fBase           = new BaseWindowStub();
            fResearchRecord = new GEDCOMResearchRecord(fBase.Context.Tree, fBase.Context.Tree, "", "");

            fDialog          = new ResearchEditDlg(fBase);
            fDialog.Research = fResearchRecord;
            fDialog.Show();
        }
Пример #3
0
        public static bool ModifyResearch(IBaseWindow baseWin, ref GEDCOMResearchRecord researchRec)
        {
            bool result;

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

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

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

                    try {
                        baseWin.Context.LockRecord(researchRec);

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

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

            return(result);
        }
Пример #4
0
        private bool ProcessResearchGroup(bool redo)
        {
            GEDCOMResearchRecord resRec = fObj as GEDCOMResearchRecord;
            GEDCOMGroupRecord    grpRec = fNewVal as GEDCOMGroupRecord;

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

            if (fType == OperationType.otResearchGroupRemove)
            {
                redo = !redo;
            }
            if (redo)
            {
                resRec.AddGroup(grpRec);
            }
            else
            {
                resRec.RemoveGroup(grpRec);
            }
            return(true);
        }
Пример #5
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);
        }
Пример #6
0
        private bool ProcessResearchTask(bool redo)
        {
            GEDCOMResearchRecord resRec  = fObj as GEDCOMResearchRecord;
            GEDCOMTaskRecord     taskRec = fNewVal as GEDCOMTaskRecord;

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

            if (fType == OperationType.otResearchTaskRemove)
            {
                redo = !redo;
            }
            if (redo)
            {
                resRec.AddTask(taskRec);
            }
            else
            {
                resRec.RemoveTask(taskRec);
            }
            return(true);
        }
Пример #7
0
        public void Test_LMResearch()
        {
            var listManager = new ResearchListMan(fContext);

            Assert.IsNotNull(listManager);

            GEDCOMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GEDCOMResearchRecord;

            listManager.Fetch(resRec);

            listManager.QuickFilter = "*";
            Assert.IsTrue(listManager.CheckFilter());
            listManager.QuickFilter = "*resear*";
            Assert.IsTrue(listManager.CheckFilter());
            listManager.QuickFilter = "*xxxx*";
            Assert.IsFalse(listManager.CheckFilter());

            var lvMock = new ListViewMock();

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

            listManager.UpdateItem(0, listItem, resRec);
        }
Пример #8
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");
        }
Пример #9
0
 public override void Fetch(GEDCOMRecord aRec)
 {
     fRec = (aRec as GEDCOMResearchRecord);
 }
Пример #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);
        }
Пример #11
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);
        }
Пример #12
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);
        }