1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab 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 | * HeuristicLab 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 HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Core.Views;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Clients.OKB.Administration {
|
---|
29 | [View("NamedOKBItem View")]
|
---|
30 | [Content(typeof(NamedOKBItem), true)]
|
---|
31 | [Content(typeof(INamedOKBItem), false)]
|
---|
32 | public partial class NamedOKBItemView : OKBItemView {
|
---|
33 | public new INamedOKBItem Content {
|
---|
34 | get { return (INamedOKBItem)base.Content; }
|
---|
35 | set { base.Content = value; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public NamedOKBItemView() {
|
---|
39 | InitializeComponent();
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override void OnContentChanged() {
|
---|
43 | base.OnContentChanged();
|
---|
44 | if (Content == null) {
|
---|
45 | nameTextBox.Text = string.Empty;
|
---|
46 | descriptionTextBox.Text = string.Empty;
|
---|
47 | toolTip.SetToolTip(descriptionTextBox, string.Empty);
|
---|
48 | if (ViewAttribute.HasViewAttribute(this.GetType()))
|
---|
49 | this.Caption = ViewAttribute.GetViewName(this.GetType());
|
---|
50 | else
|
---|
51 | this.Caption = "NamedOKBItem View";
|
---|
52 | } else {
|
---|
53 | nameTextBox.Text = Content.Name;
|
---|
54 | descriptionTextBox.Text = Content.Description;
|
---|
55 | toolTip.SetToolTip(descriptionTextBox, Content.Description);
|
---|
56 | Caption = Content.Name;
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | protected override void SetEnabledStateOfControls() {
|
---|
61 | base.SetEnabledStateOfControls();
|
---|
62 | nameTextBox.Enabled = Content != null;
|
---|
63 | nameTextBox.ReadOnly = ReadOnly;
|
---|
64 | descriptionTextBox.Enabled = Content != null;
|
---|
65 | descriptionTextBox.ReadOnly = ReadOnly;
|
---|
66 | }
|
---|
67 |
|
---|
68 | protected override void OnContentPropertyChanged(string propertyName) {
|
---|
69 | switch (propertyName) {
|
---|
70 | case "Name":
|
---|
71 | nameTextBox.Text = Content.Name;
|
---|
72 | Caption = Content.Name;
|
---|
73 | break;
|
---|
74 | case "Description":
|
---|
75 | descriptionTextBox.Text = Content.Description;
|
---|
76 | toolTip.SetToolTip(descriptionTextBox, Content.Description);
|
---|
77 | break;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | protected virtual void nameTextBox_TextChanged(object sender, EventArgs e) {
|
---|
82 | if (nameTextBox.Text != Content.Name)
|
---|
83 | Content.Name = nameTextBox.Text;
|
---|
84 | }
|
---|
85 | protected virtual void descriptionTextBox_TextChanged(object sender, EventArgs e) {
|
---|
86 | if (descriptionTextBox.Text != Content.Description)
|
---|
87 | Content.Description = descriptionTextBox.Text;
|
---|
88 | }
|
---|
89 |
|
---|
90 | protected void descriptionTextBox_DoubleClick(object sender, EventArgs e) {
|
---|
91 | using (TextDialog dialog = new TextDialog("Description of " + Content.Name, descriptionTextBox.Text, ReadOnly)) {
|
---|
92 | if (dialog.ShowDialog(this) == DialogResult.OK)
|
---|
93 | Content.Description = dialog.Content;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|