Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JSMForcingStrategyView.cs @ 13443

Last change on this file since 13443 was 13443, checked in by mkommend, 8 years ago

#2521: Adapted decoders for SchedulingProblem.

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Windows.Forms;
24using HeuristicLab.Core.Views;
25using HeuristicLab.Encodings.ScheduleEncoding;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.Problems.Scheduling.Views {
29  [View("JSMForcingStrategy View")]
30  [Content(typeof(JSMForcingStrategy), true)]
31  public partial class JSMForcingStrategyView : ItemView {
32
33    public new JSMForcingStrategy Content {
34      get { return (JSMForcingStrategy)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public override bool ReadOnly {
39      get {
40        if ((Content != null) && Content.ReadOnly) return true;
41        return base.ReadOnly;
42      }
43      set { base.ReadOnly = value; }
44    }
45
46    public JSMForcingStrategyView() {
47      InitializeComponent();
48      valueComboBox.DataSource = Enum.GetValues(typeof(JSMForcingStrategyTypes));
49    }
50    public JSMForcingStrategyView(JSMForcingStrategy content)
51      : this() {
52      Content = content;
53    }
54
55    protected override void DeregisterContentEvents() {
56      Content.ValueChanged -= Content_ValueChanged;
57      base.DeregisterContentEvents();
58    }
59
60    protected override void RegisterContentEvents() {
61      base.RegisterContentEvents();
62      Content.ValueChanged += Content_ValueChanged;
63    }
64
65    protected override void OnContentChanged() {
66      base.OnContentChanged();
67      if (Content == null)
68        valueComboBox.Enabled = false;
69      else
70        valueComboBox.SelectedItem = Content.Value;
71    }
72
73    protected override void SetEnabledStateOfControls() {
74      base.SetEnabledStateOfControls();
75      if (Content == null) valueComboBox.Enabled = false;
76      else valueComboBox.Enabled = !ReadOnly;
77    }
78
79    private void Content_ValueChanged(object sender, EventArgs e) {
80      if (InvokeRequired)
81        Invoke(new EventHandler(Content_ValueChanged), sender, e);
82      else
83        valueComboBox.SelectedItem = Content.Value;
84    }
85
86    private void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) {
87      if ((Content != null) && !Content.ReadOnly) Content.Value = (JSMForcingStrategyTypes)valueComboBox.SelectedItem;
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.