Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTypeCompatibilityConstraintView.cs @ 3832

Last change on this file since 3832 was 3742, checked in by gkronber, 14 years ago

Fixed GPL license headers and deleted files which are not referenced by projects. #893

File size: 2.9 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 System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30using HeuristicLab.MainForm;
31using HeuristicLab.Common;
32
33namespace HeuristicLab.Optimization.Views {
34  [Content(typeof(RunCollectionTypeCompatibilityConstraint), true)]
35  public partial class RunCollectionTypeCompatibilityConstraintView : RunCollectionConstraintView {
36    public RunCollectionTypeCompatibilityConstraintView() {
37      InitializeComponent();
38      cmbType.DisplayMember = "Name";
39    }
40
41    public new RunCollectionTypeCompatibilityConstraint Content {
42      get { return (RunCollectionTypeCompatibilityConstraint)base.Content; }
43      set { base.Content = value; }
44    }
45
46    protected override void Content_ConstraintColumnChanged(object sender, EventArgs e) {
47      base.Content_ConstraintColumnChanged(sender, e);
48      UpdateTypeColumn();
49    }
50
51    protected override void OnContentChanged() {
52      base.OnContentChanged();
53      UpdateTypeColumn();
54    }
55
56    protected virtual void UpdateTypeColumn() {
57      cmbType.Items.Clear();
58      if (Content != null && Content.ConstrainedValue != null) {
59        foreach (Type t in Content.ConstrainedValue.GetDataType(cmbConstraintColumn.SelectedItem.ToString()))
60          cmbType.Items.Add(t);
61        if (Content.ConstraintData != null)
62          cmbType.SelectedItem = Content.ConstraintData;
63        else if (cmbType.Items.Count > 0)
64          cmbType.SelectedIndex = 0;
65      }
66    }
67
68    protected override void SetEnabledStateOfControls() {
69      base.SetEnabledStateOfControls();
70      cmbType.Enabled = Content != null && !this.ReadOnly;
71    }
72
73    private void cmbType_SelectedIndexChanged(object sender, EventArgs e) {
74      if (Content != null)
75        Content.ConstraintData = (Type)cmbType.SelectedItem;
76    }
77
78    private struct ComboBoxItem {
79      public ComboBoxItem(string name, Type type) {
80        this.Name = name;
81        this.Type = type;
82      }
83      public string Name;
84      public Type Type;
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.