Free cookie consent management tool by TermsFeed Policy Generator

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

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

Added SetEnabledStateOfControls as protected virtual method in !View. Therefore the overloading of OnReadOnlyChanged and OnLockedChanged got obsolete in most views, because the method got called in the !View respectively ContentView. (ticket #1021)

File size: 3.5 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    }
74
75    protected override void SetEnabledStateOfControls() {
76      base.SetEnabledStateOfControls();
77      breakpointCheckBox.Enabled = Content != null && !Locked;
78      parameterCollectionView.Enabled = Content != null;
79    }
80
81    protected void Content_BreakpointChanged(object sender, EventArgs e) {
82      if (InvokeRequired)
83        Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
84      else
85        breakpointCheckBox.Checked = Content.Breakpoint;
86    }
87
88    protected void breakpointCheckBox_CheckedChanged(object sender, System.EventArgs e) {
89      if (Content != null) Content.Breakpoint = breakpointCheckBox.Checked;
90    }
91  }
92}
Note: See TracBrowser for help on using the repository browser.