1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 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.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Drawing;
|
---|
26 | using System.Data;
|
---|
27 | using System.Text;
|
---|
28 | using System.Windows.Forms;
|
---|
29 | using HeuristicLab.MainForm;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Core.Views {
|
---|
32 | /// <summary>
|
---|
33 | /// The base class for visual representation of operators (contains description view, variable view,
|
---|
34 | /// variable info view,...).
|
---|
35 | /// </summary>
|
---|
36 | [Content(typeof(OperatorBase), true)]
|
---|
37 | public partial class OperatorBaseView : ItemViewBase {
|
---|
38 | /// <summary>
|
---|
39 | /// Gets or sets the operator to represent visually.
|
---|
40 | /// </summary>
|
---|
41 | /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
|
---|
42 | /// No own data storage present.</remarks>
|
---|
43 | public IOperator Operator {
|
---|
44 | get { return (IOperator)Item; }
|
---|
45 | set {base.Item = value; }
|
---|
46 | }
|
---|
47 |
|
---|
48 | /// <summary>
|
---|
49 | /// Initializes a new instance of <see cref="OperatorBaseView"/> with caption "Operator".
|
---|
50 | /// </summary>
|
---|
51 | public OperatorBaseView() {
|
---|
52 | InitializeComponent();
|
---|
53 | Caption = "Operator";
|
---|
54 | }
|
---|
55 | /// <summary>
|
---|
56 | /// Initializes a new instance of <see cref="OperatorBaseView"/>
|
---|
57 | /// with the given operator <paramref name="op"/>.
|
---|
58 | /// </summary>
|
---|
59 | /// <remarks>Calls <see cref="OperatorBaseView()"/>.</remarks>
|
---|
60 | /// <param name="op">The operator to represent visually.</param>
|
---|
61 | public OperatorBaseView(IOperator op)
|
---|
62 | : this() {
|
---|
63 | Operator = op;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /// <summary>
|
---|
67 | /// Removes event handlers in all children.
|
---|
68 | /// </summary>
|
---|
69 | protected override void RemoveItemEvents() {
|
---|
70 | operatorBaseVariableInfosView.Operator = null;
|
---|
71 | operatorBaseVariablesView.Operator = null;
|
---|
72 | operatorBaseDescriptionView.Operator = null;
|
---|
73 | base.RemoveItemEvents();
|
---|
74 | }
|
---|
75 | /// <summary>
|
---|
76 | /// Adds event handlers in all children.
|
---|
77 | /// </summary>
|
---|
78 | protected override void AddItemEvents() {
|
---|
79 | base.AddItemEvents();
|
---|
80 | operatorBaseVariableInfosView.Operator = Operator;
|
---|
81 | operatorBaseVariablesView.Operator = Operator;
|
---|
82 | operatorBaseDescriptionView.Operator = Operator;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /// <summary>
|
---|
86 | /// Updates all controls with the latest data of the model.
|
---|
87 | /// </summary>
|
---|
88 | /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
|
---|
89 | protected override void UpdateControls() {
|
---|
90 | base.UpdateControls();
|
---|
91 | if (Operator == null) {
|
---|
92 | Caption = "Operator";
|
---|
93 | tabControl.Enabled = false;
|
---|
94 | } else {
|
---|
95 | Caption = Operator.Name + " (" + Operator.GetType().Name + ")";
|
---|
96 | tabControl.Enabled = true;
|
---|
97 | }
|
---|
98 | }
|
---|
99 | }
|
---|
100 | }
|
---|