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.ComponentModel; 23 using BSLib.Design.MVP.Controls; 24 using Eto.Forms; 25 using GDModel; 26 using GKCore; 27 using GKCore.Controllers; 28 using GKCore.Interfaces; 29 using GKCore.Lists; 30 using GKCore.MVP.Controls; 31 using GKCore.MVP.Views; 32 using GKUI.Components; 33 34 namespace GKUI.Forms 35 { 36 public sealed partial class CommunicationEditDlg : EditorDialog, ICommunicationEditDlg 37 { 38 private readonly CommunicationEditDlgController fController; 39 40 private readonly GKSheetList fNotesList; 41 private readonly GKSheetList fMediaList; 42 43 public GDMCommunicationRecord Communication 44 { 45 get { return fController.Communication; } 46 set { fController.Communication = value; } 47 } 48 49 #region View Interface 50 51 ISheetList ICommunicationEditDlg.NotesList 52 { 53 get { return fNotesList; } 54 } 55 56 ISheetList ICommunicationEditDlg.MediaList 57 { 58 get { return fMediaList; } 59 } 60 61 ITextBox ICommunicationEditDlg.Corresponder 62 { 63 get { return GetControlHandler<ITextBox>(txtCorresponder); } 64 } 65 66 IComboBox ICommunicationEditDlg.CorrType 67 { 68 get { return GetControlHandler<IComboBox>(cmbCorrType); } 69 } 70 71 IDateBox ICommunicationEditDlg.Date 72 { 73 get { return GetControlHandler<IDateBox>(txtDate); } 74 } 75 76 IComboBox ICommunicationEditDlg.Dir 77 { 78 get { return GetControlHandler<IComboBox>(txtDir); } 79 } 80 81 ITextBox ICommunicationEditDlg.Name 82 { 83 get { return GetControlHandler<ITextBox>(txtName); } 84 } 85 86 #endregion 87 CommunicationEditDlg(IBaseWindow baseWin)88 public CommunicationEditDlg(IBaseWindow baseWin) 89 { 90 InitializeComponent(); 91 92 btnAccept.Image = UIHelper.LoadResourceImage("Resources.btn_accept.gif"); 93 btnCancel.Image = UIHelper.LoadResourceImage("Resources.btn_cancel.gif"); 94 btnPersonAdd.Image = UIHelper.LoadResourceImage("Resources.btn_rec_new.gif"); 95 96 fNotesList = new GKSheetList(pageNotes); 97 fMediaList = new GKSheetList(pageMultimedia); 98 99 // SetLocale() 100 btnAccept.Text = LangMan.LS(LSID.LSID_DlgAccept); 101 btnCancel.Text = LangMan.LS(LSID.LSID_DlgCancel); 102 Title = LangMan.LS(LSID.LSID_WinCommunicationEdit); 103 pageNotes.Text = LangMan.LS(LSID.LSID_RPNotes); 104 pageMultimedia.Text = LangMan.LS(LSID.LSID_RPMultimedia); 105 lblTheme.Text = LangMan.LS(LSID.LSID_Theme); 106 lblCorresponder.Text = LangMan.LS(LSID.LSID_Corresponder); 107 lblType.Text = LangMan.LS(LSID.LSID_Type); 108 lblDate.Text = LangMan.LS(LSID.LSID_Date); 109 110 SetToolTip(btnPersonAdd, LangMan.LS(LSID.LSID_PersonAttachTip)); 111 112 fController = new CommunicationEditDlgController(this); 113 fController.Init(baseWin); 114 115 fNotesList.ListModel = new NoteLinksListModel(baseWin, fController.LocalUndoman); 116 fMediaList.ListModel = new MediaLinksListModel(baseWin, fController.LocalUndoman); 117 } 118 btnAccept_Click(object sender, EventArgs e)119 private void btnAccept_Click(object sender, EventArgs e) 120 { 121 DialogResult = fController.Accept() ? DialogResult.Ok : DialogResult.None; 122 } 123 btnCancel_Click(object sender, EventArgs e)124 private void btnCancel_Click(object sender, EventArgs e) 125 { 126 DialogResult = fController.Cancel() ? DialogResult.Cancel : DialogResult.None; 127 } 128 OnClosing(CancelEventArgs e)129 protected override void OnClosing(CancelEventArgs e) 130 { 131 base.OnClosing(e); 132 e.Cancel = fController.CheckChangesPersistence(); 133 } 134 btnPersonAdd_Click(object sender, EventArgs e)135 private void btnPersonAdd_Click(object sender, EventArgs e) 136 { 137 fController.SetPerson(); 138 } 139 } 140 } 141