Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Operators.Views/3.3/CheckedMultiOperatorView.cs @ 3696

Last change on this file since 3696 was 3696, checked in by mkommend, 14 years ago

corrected breakpoint checkbox; coupled enabled state to locked instead of readonly (ticket #1001)

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