Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

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 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      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    }
88
89    protected void Content_BreakpointChanged(object sender, EventArgs e) {
90      if (InvokeRequired)
91        Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
92      else
93        breakpointCheckBox.Checked = Content.Breakpoint;
94    }
95
96    protected void breakpointCheckBox_CheckedChanged(object sender, System.EventArgs e) {
97      if (Content != null) Content.Breakpoint = breakpointCheckBox.Checked;
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.