Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3838 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
RevLine 
[2]1#region License Information
2/* HeuristicLab
[2790]3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[2]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
[3376]22using HeuristicLab.Common;
[2805]23using HeuristicLab.Core;
24using HeuristicLab.Core.Views;
[2520]25using HeuristicLab.MainForm;
[2845]26using System;
[2]27
[2805]28namespace HeuristicLab.Operators.Views {
[776]29  /// <summary>
[2655]30  /// The base class for visual representations of items.
[776]31  /// </summary>
[2917]32  [View("Operator View (Default)")]
[2664]33  [Content(typeof(Operator), true)]
[2727]34  [Content(typeof(IOperator), false)]
[2845]35  public partial class OperatorView : ParameterizedNamedItemView {
[2727]36    public new IOperator Content {
37      get { return (IOperator)base.Content; }
[2713]38      set { base.Content = value; }
[2]39    }
40
[776]41    /// <summary>
[2655]42    /// Initializes a new instance of <see cref="ItemBaseView"/>.
[776]43    /// </summary>
[2664]44    public OperatorView() {
[2]45      InitializeComponent();
46    }
47
[2845]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
[2713]66    protected override void OnContentChanged() {
67      base.OnContentChanged();
68      if (Content == null) {
[2845]69        breakpointCheckBox.Checked = false;
[2]70      } else {
[2845]71        breakpointCheckBox.Checked = Content.Breakpoint;
[2]72      }
[3454]73      SetEnabledStateOfControls();
[2]74    }
[2845]75
[3454]76    protected override void OnReadOnlyChanged() {
77      base.OnReadOnlyChanged();
78      SetEnabledStateOfControls();
79    }
[3696]80    protected override void OnLockedChanged() {
81      base.OnLockedChanged();
82      this.SetEnabledStateOfControls();
83    }
[3454]84
85    private void SetEnabledStateOfControls() {
[3696]86      breakpointCheckBox.Enabled = Content != null && !Locked;
[3454]87    }
88
[2917]89    protected void Content_BreakpointChanged(object sender, EventArgs e) {
[2845]90      if (InvokeRequired)
91        Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
92      else
93        breakpointCheckBox.Checked = Content.Breakpoint;
94    }
95
[2917]96    protected void breakpointCheckBox_CheckedChanged(object sender, System.EventArgs e) {
[2845]97      if (Content != null) Content.Breakpoint = breakpointCheckBox.Checked;
98    }
[2]99  }
100}
Note: See TracBrowser for help on using the repository browser.