1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.MainForm;
|
---|
10 | using HeuristicLab.Common;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Optimization.Views {
|
---|
13 | [Content(typeof(RunCollectionTypeCompatibilityConstraint), true)]
|
---|
14 | public partial class RunCollectionTypeCompatibilityConstraintView : RunCollectionConstraintView {
|
---|
15 | public RunCollectionTypeCompatibilityConstraintView() {
|
---|
16 | InitializeComponent();
|
---|
17 | cmbType.DisplayMember = "Name";
|
---|
18 | }
|
---|
19 |
|
---|
20 | public new RunCollectionTypeCompatibilityConstraint Content {
|
---|
21 | get { return (RunCollectionTypeCompatibilityConstraint)base.Content; }
|
---|
22 | set { base.Content = value; }
|
---|
23 | }
|
---|
24 |
|
---|
25 | protected override void Content_ConstraintColumnChanged(object sender, EventArgs e) {
|
---|
26 | base.Content_ConstraintColumnChanged(sender, e);
|
---|
27 | UpdateTypeColumn();
|
---|
28 | }
|
---|
29 |
|
---|
30 | protected override void OnContentChanged() {
|
---|
31 | base.OnContentChanged();
|
---|
32 | UpdateTypeColumn();
|
---|
33 | }
|
---|
34 |
|
---|
35 | protected virtual void UpdateTypeColumn() {
|
---|
36 | cmbType.Items.Clear();
|
---|
37 | if (Content != null && Content.ConstrainedValue != null) {
|
---|
38 | foreach (Type t in Content.ConstrainedValue.GetDataType(cmbConstraintColumn.SelectedItem.ToString()))
|
---|
39 | cmbType.Items.Add(t);
|
---|
40 | if (Content.ConstraintData != null)
|
---|
41 | cmbType.SelectedItem = Content.ConstraintData;
|
---|
42 | else if (cmbType.Items.Count > 0)
|
---|
43 | cmbType.SelectedIndex = 0;
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void SetEnabledStateOfControls() {
|
---|
48 | base.SetEnabledStateOfControls();
|
---|
49 | cmbType.Enabled = Content != null && !this.ReadOnly;
|
---|
50 | }
|
---|
51 |
|
---|
52 | private void cmbType_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
53 | if (Content != null)
|
---|
54 | Content.ConstraintData = (Type)cmbType.SelectedItem;
|
---|
55 | }
|
---|
56 |
|
---|
57 | private struct ComboBoxItem {
|
---|
58 | public ComboBoxItem(string name, Type type) {
|
---|
59 | this.Name = name;
|
---|
60 | this.Type = type;
|
---|
61 | }
|
---|
62 | public string Name;
|
---|
63 | public Type Type;
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|