1 /* 2 * "GEDKeeper", the personal genealogical database editor. 3 * Copyright (C) 2009-2018 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; 22 using System.Windows.Forms; 23 using BSLib.Design.MVP.Controls; 24 using GDModel; 25 using GKCore; 26 using GKCore.Controllers; 27 using GKCore.Interfaces; 28 using GKCore.MVP.Views; 29 using GKUI.Components; 30 31 namespace GKUI.Forms 32 { 33 public partial class ParentsEditDlg : EditorDialog, IParentsEditDlg 34 { 35 private readonly ParentsEditDlgController fController; 36 37 public GDMChildToFamilyLink Link 38 { 39 get { return fController.Link; } 40 set { fController.Link = value; } 41 } 42 43 public GDMIndividualRecord Person 44 { 45 get { return fController.Person; } 46 set { fController.Person = value; } 47 } 48 49 #region View Interface 50 51 ITextBox IParentsEditDlg.Father 52 { 53 get { return GetControlHandler<ITextBox>(txtFather); } 54 } 55 56 ITextBox IParentsEditDlg.Mother 57 { 58 get { return GetControlHandler<ITextBox>(txtMother); } 59 } 60 61 ITextBox IParentsEditDlg.ChildName 62 { 63 get { return GetControlHandler<ITextBox>(txtChildName); } 64 } 65 66 IComboBox IParentsEditDlg.LinkageTypeCombo 67 { 68 get { return GetControlHandler<IComboBox>(cmbLinkageType); } 69 } 70 71 #endregion 72 ParentsEditDlg(IBaseWindow baseWin)73 public ParentsEditDlg(IBaseWindow baseWin) 74 { 75 InitializeComponent(); 76 77 btnAccept.Image = UIHelper.LoadResourceImage("Resources.btn_accept.gif"); 78 btnCancel.Image = UIHelper.LoadResourceImage("Resources.btn_cancel.gif"); 79 btnParentsEdit.Image = UIHelper.LoadResourceImage("Resources.btn_rec_edit.gif"); 80 btnFatherAdd.Image = UIHelper.LoadResourceImage("Resources.btn_rec_new.gif"); 81 btnFatherDelete.Image = UIHelper.LoadResourceImage("Resources.btn_rec_edit.gif"); 82 btnMotherAdd.Image = UIHelper.LoadResourceImage("Resources.btn_rec_new.gif"); 83 btnMotherDelete.Image = UIHelper.LoadResourceImage("Resources.btn_rec_edit.gif"); 84 85 SetLocale(); 86 87 fController = new ParentsEditDlgController(this); 88 fController.Init(baseWin); 89 } 90 SetLocale()91 public void SetLocale() 92 { 93 btnAccept.Text = LangMan.LS(LSID.LSID_DlgAccept); 94 btnCancel.Text = LangMan.LS(LSID.LSID_DlgCancel); 95 Title = LangMan.LS(LSID.LSID_WinPersonEdit); 96 lblChildName.Text = LangMan.LS(LSID.LSID_Name); 97 lblParents.Text = LangMan.LS(LSID.LSID_Parents); 98 lblLinkageType.Text = LangMan.LS(LSID.LSID_LinkageType); 99 100 SetToolTip(btnParentsEdit, LangMan.LS(LSID.LSID_ParentsEditTip)); 101 SetToolTip(btnFatherAdd, LangMan.LS(LSID.LSID_FatherAddTip)); 102 SetToolTip(btnFatherDelete, LangMan.LS(LSID.LSID_FatherDeleteTip)); 103 SetToolTip(btnMotherAdd, LangMan.LS(LSID.LSID_MotherAddTip)); 104 SetToolTip(btnMotherDelete, LangMan.LS(LSID.LSID_MotherDeleteTip)); 105 } 106 SetParentsAvl(bool avail)107 public void SetParentsAvl(bool avail) 108 { 109 btnParentsEdit.Enabled = avail; 110 } 111 SetFatherAvl(bool avail)112 public void SetFatherAvl(bool avail) 113 { 114 btnFatherAdd.Enabled = !avail; 115 btnFatherDelete.Enabled = avail; 116 } 117 SetMotherAvl(bool avail)118 public void SetMotherAvl(bool avail) 119 { 120 btnMotherAdd.Enabled = !avail; 121 btnMotherDelete.Enabled = avail; 122 } 123 btnAccept_Click(object sender, EventArgs e)124 private void btnAccept_Click(object sender, EventArgs e) 125 { 126 DialogResult = fController.Accept() ? DialogResult.OK : DialogResult.None; 127 } 128 btnCancel_Click(object sender, EventArgs e)129 private void btnCancel_Click(object sender, EventArgs e) 130 { 131 DialogResult = fController.Cancel() ? DialogResult.Cancel : DialogResult.None; 132 } 133 OnFormClosing(FormClosingEventArgs e)134 protected override void OnFormClosing(FormClosingEventArgs e) 135 { 136 base.OnFormClosing(e); 137 e.Cancel = fController.CheckChangesPersistence(); 138 } 139 btnFatherAdd_Click(object sender, EventArgs e)140 private void btnFatherAdd_Click(object sender, EventArgs e) 141 { 142 fController.AddFather(); 143 } 144 btnFatherDelete_Click(object sender, EventArgs e)145 private void btnFatherDelete_Click(object sender, EventArgs e) 146 { 147 fController.DeleteFather(); 148 } 149 btnMotherAdd_Click(object sender, EventArgs e)150 private void btnMotherAdd_Click(object sender, EventArgs e) 151 { 152 fController.AddMother(); 153 } 154 btnMotherDelete_Click(object sender, EventArgs e)155 private void btnMotherDelete_Click(object sender, EventArgs e) 156 { 157 fController.DeleteMother(); 158 } 159 btnParentsEdit_Click(object sender, EventArgs e)160 private void btnParentsEdit_Click(object sender, EventArgs e) 161 { 162 fController.EditParents(); 163 } 164 } 165 } 166