1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 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 HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Core.Views;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Operators.Views {
|
---|
28 | [View("CheckedMultiOperator View")]
|
---|
29 | [Content(typeof(CheckedMultiOperator<>), true)]
|
---|
30 | public partial class CheckedMultiOperatorView<T> : NamedItemView where T : class, IOperator {
|
---|
31 | public new CheckedMultiOperator<T> Content {
|
---|
32 | get { return (CheckedMultiOperator<T>)base.Content; }
|
---|
33 | set { base.Content = value; }
|
---|
34 | }
|
---|
35 |
|
---|
36 | /// <summary>
|
---|
37 | /// Initializes a new instance of <see cref="CheckedMultiOperatorView"/>.
|
---|
38 | /// </summary>
|
---|
39 | public CheckedMultiOperatorView() {
|
---|
40 | InitializeComponent();
|
---|
41 | }
|
---|
42 |
|
---|
43 | /// <summary>
|
---|
44 | /// Removes the eventhandlers from the underlying <see cref="CheckedMultiOperator"/>.
|
---|
45 | /// </summary>
|
---|
46 | /// <remarks>Calls <see cref="NamedItemView.DeregisterContentEvents"/> of base class <see cref="NamedItemView"/>.</remarks>
|
---|
47 | protected override void DeregisterContentEvents() {
|
---|
48 | Content.BreakpointChanged -= new EventHandler(Content_BreakpointChanged);
|
---|
49 | base.DeregisterContentEvents();
|
---|
50 | }
|
---|
51 |
|
---|
52 | /// <summary>
|
---|
53 | /// Adds eventhandlers to the underlying <see cref="CheckedMultiOperator"/>.
|
---|
54 | /// </summary>
|
---|
55 | /// <remarks>Calls <see cref="NamedItemView.RegisterContentEvents"/> of base class <see cref="NamedItemView"/>.</remarks>
|
---|
56 | protected override void RegisterContentEvents() {
|
---|
57 | base.RegisterContentEvents();
|
---|
58 | Content.BreakpointChanged += new EventHandler(Content_BreakpointChanged);
|
---|
59 | }
|
---|
60 |
|
---|
61 | protected override void OnContentChanged() {
|
---|
62 | base.OnContentChanged();
|
---|
63 | if (Content == null) {
|
---|
64 | breakpointCheckBox.Checked = false;
|
---|
65 | operatorListView.Content = null;
|
---|
66 | parameterCollectionView.Content = null;
|
---|
67 | } else {
|
---|
68 | breakpointCheckBox.Checked = Content.Breakpoint;
|
---|
69 | operatorListView.Content = Content.Operators;
|
---|
70 | parameterCollectionView.Content = ((IOperator)Content).Parameters;
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | protected override void SetEnabledStateOfControls() {
|
---|
75 | base.SetEnabledStateOfControls();
|
---|
76 | breakpointCheckBox.Enabled = Content != null && !Locked;
|
---|
77 | parameterCollectionView.Enabled = Content != null;
|
---|
78 | }
|
---|
79 |
|
---|
80 | protected void Content_BreakpointChanged(object sender, EventArgs e) {
|
---|
81 | if (InvokeRequired)
|
---|
82 | Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
|
---|
83 | else
|
---|
84 | breakpointCheckBox.Checked = Content.Breakpoint;
|
---|
85 | }
|
---|
86 |
|
---|
87 | protected void breakpointCheckBox_CheckedChanged(object sender, System.EventArgs e) {
|
---|
88 | if (Content != null) Content.Breakpoint = breakpointCheckBox.Checked;
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|