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 BSLib.Design.MVP;
22 
23 namespace GKCore.MVP
24 {
25     /// <summary>
26     ///
27     /// </summary>
28     public abstract class EditorController<TModel, TView> : DialogController<TView>, IController<TModel, TView>
29         where TModel : class
30         where TView : IView
31     {
32         protected TModel fModel;
33 
34         public TModel Model
35         {
36             get { return fModel; }
37             set {
38                 if (fModel != value) {
39                     SetModel(value);
40                 }
41             }
42         }
43 
EditorController(TView view)44         protected EditorController(TView view) : base(view)
45         {
46         }
47 
SetModel(TModel value)48         protected virtual void SetModel(TModel value)
49         {
50             fModel = value;
51             UpdateView();
52         }
53     }
54 }
55