Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Operators.Views/3.3/OperatorView.cs @ 4000

Last change on this file since 4000 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.2 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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Core.Views;
25using HeuristicLab.MainForm;
26using System;
27
28namespace HeuristicLab.Operators.Views {
29  /// <summary>
30  /// The base class for visual representations of items.
31  /// </summary>
32  [View("Operator View (Default)")]
33  [Content(typeof(Operator), true)]
34  [Content(typeof(IOperator), false)]
35  public partial class OperatorView : ParameterizedNamedItemView {
36    public new IOperator Content {
37      get { return (IOperator)base.Content; }
38      set { base.Content = value; }
39    }
40
41    /// <summary>
42    /// Initializes a new instance of <see cref="ItemBaseView"/>.
43    /// </summary>
44    public OperatorView() {
45      InitializeComponent();
46    }
47
48    /// <summary>
49    /// Removes the eventhandlers from the underlying <see cref="IOperatorGraph"/>.
50    /// </summary>
51    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
52    protected override void DeregisterContentEvents() {
53      Content.BreakpointChanged -= new EventHandler(Content_BreakpointChanged);
54      base.DeregisterContentEvents();
55    }
56
57    /// <summary>
58    /// Adds eventhandlers to the underlying <see cref="IOperatorGraph"/>.
59    /// </summary>
60    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
61    protected override void RegisterContentEvents() {
62      base.RegisterContentEvents();
63      Content.BreakpointChanged += new EventHandler(Content_BreakpointChanged);
64    }
65
66    protected override void OnContentChanged() {
67      base.OnContentChanged();
68      if (Content == null) {
69        breakpointCheckBox.Checked = false;
70      } else {
71        breakpointCheckBox.Checked = Content.Breakpoint;
72      }
73    }
74
75    protected override void SetEnabledStateOfControls() {
76      base.SetEnabledStateOfControls();
77      breakpointCheckBox.Enabled = Content != null && !Locked;
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}
Note: See TracBrowser for help on using the repository browser.