Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone2/sources/HeuristicLab.Constraints/3.2/OrConstraintView.cs @ 6703

Last change on this file since 6703 was 1529, checked in by gkronber, 16 years ago

Moved source files of plugins AdvancedOptimizationFrontEnd ... Grid into version-specific sub-folders. #576

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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 System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Windows.Forms;
29using HeuristicLab.Core;
30using HeuristicLab.Data;
31
32namespace HeuristicLab.Constraints {
33  /// <summary>
34  /// Visual representation of an <see cref="OrConstraint"/>.
35  /// </summary>
36  public partial class OrConstraintView : ViewBase {
37    private OrConstraint OrConstraint {
38      get { return (OrConstraint)Item; }
39      set { base.Item = value; }
40    }
41
42    /// <summary>
43    /// Initializes a new instance of <see cref="OrConstraintView"/>.
44    /// </summary>
45    public OrConstraintView() {
46      InitializeComponent();
47    }
48    /// <summary>
49    /// Initializes a new instance of <see cref="OrConstraintView"/> with the given
50    /// <paramref name="orConstraint"/> to display.
51    /// </summary>
52    /// <param name="orConstraint">The constraint to represent visually.</param>
53    public OrConstraintView(OrConstraint orConstraint)
54      : this() {
55      OrConstraint = orConstraint;
56    }
57
58    /// <summary>
59    /// Removes the eventhandler from the underlying <see cref="OrConstraint"/>.
60    /// </summary>
61    /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.
62    /// </remarks>
63    protected override void RemoveItemEvents() {
64      OrConstraint.Changed -= new EventHandler(OrConstraint_Changed);
65      base.RemoveItemEvents();
66    }
67    /// <summary>
68    /// Adds an eventhandler to the underlying <see cref="OrConstraint"/>.
69    /// </summary>
70    /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.
71    /// </remarks>
72    protected override void AddItemEvents() {
73      base.AddItemEvents();
74      OrConstraint.Changed += new EventHandler(OrConstraint_Changed);
75    }
76
77    /// <summary>
78    /// Updates all controls with the latest values.
79    /// </summary>   
80    protected override void UpdateControls() {
81      if (OrConstraint == null) {
82        clausesItemListView.Enabled = false;
83        clausesItemListView.ItemList = null;
84      } else {
85        clausesItemListView.ItemList = OrConstraint.Clauses;
86        clausesItemListView.Enabled = true;
87      }
88    }
89
90    private void OrConstraint_Changed(object sender, EventArgs e) {
91      Refresh();
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.