1 /* 2 * "GEDKeeper", the personal genealogical database editor. 3 * Copyright (C) 2009-2021 by Sergey V. Zhdanovskih. 4 * 5 * This file is part of "GEDKeeper". 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 using System.Collections.Generic; 22 using BSLib.Design.MVP.Controls; 23 using GDModel; 24 using GKCore.Interfaces; 25 using GKCore.MVP; 26 using GKCore.MVP.Views; 27 using GKCore.Tools; 28 29 namespace GKCore.Controllers 30 { 31 /// <summary> 32 /// 33 /// </summary> 34 public class FragmentSearchController : DialogController<IFragmentSearchDlg> 35 { FragmentSearchController(IFragmentSearchDlg view)36 public FragmentSearchController(IFragmentSearchDlg view) : base(view) 37 { 38 } 39 UpdateView()40 public override void UpdateView() 41 { 42 } 43 CheckGroups()44 public void CheckGroups() 45 { 46 IProgressController progress = AppHost.Progress; 47 List<List<GDMRecord>> treeFragments = TreeTools.SearchTreeFragments(fBase.Context.Tree, progress); 48 49 fView.LogChart.Clear(); 50 fView.GroupsTree.BeginUpdate(); 51 try { 52 fView.GroupsTree.Clear(); 53 54 int num = treeFragments.Count; 55 for (int i = 0; i < num; i++) { 56 var groupRecords = treeFragments[i]; 57 58 int cnt = groupRecords.Count; 59 int groupNum = (i + 1); 60 ITVNode groupItem = fView.GroupsTree.AddNode(null, 61 groupNum.ToString() + " " + LangMan.LS(LSID.LSID_Group).ToLower() + " (" + cnt.ToString() + ")", null); 62 63 for (int j = 0; j < cnt; j++) { 64 var iRec = (GDMIndividualRecord)groupRecords[j]; 65 66 string pn = GKUtils.GetNameString(iRec, true, false); 67 if (iRec.Patriarch) { 68 pn = "(*) " + pn; 69 } 70 pn = string.Join(" ", pn, "[", iRec.XRef, "]"); 71 72 fView.GroupsTree.AddNode(groupItem, pn, iRec); 73 } 74 75 fView.GroupsTree.Expand(groupItem); 76 fView.LogChart.AddFragment(cnt); 77 } 78 } finally { 79 treeFragments.Clear(); 80 fView.GroupsTree.EndUpdate(); 81 } 82 } 83 GetSelectedPerson()84 public GDMIndividualRecord GetSelectedPerson() 85 { 86 return fView.GroupsTree.GetSelectedData() as GDMIndividualRecord; 87 } 88 SelectPerson()89 public void SelectPerson() 90 { 91 GDMIndividualRecord iRec = GetSelectedPerson(); 92 if (iRec == null) return; 93 94 fView.Close(); 95 fBase.SelectRecordByXRef(iRec.XRef); 96 } 97 ShowDetails()98 public void ShowDetails() 99 { 100 GDMIndividualRecord iRec = GetSelectedPerson(); 101 if (iRec == null) return; 102 103 BaseController.ViewRecordInfo(fBase, iRec); 104 } 105 } 106 } 107