Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValidValuesControl.cs @ 17405

Last change on this file since 17405 was 17405, checked in by dpiringe, 4 years ago

#3026:

  • added a new way to setup the targeted result types
  • added new ui controls: NumericRangeControl, JsonItemArrayControl, JsonItemDefaultControl
  • redesigned export dialog -> now the user can navigate with a tree view
  • enhanced JsonItemVM
File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10
11namespace HeuristicLab.JsonInterface.OptimizerIntegration {
12  public partial class JsonItemValidValuesControl : JsonItemBaseControl {
13   
14
15    public JsonItemValidValuesControl(JsonItemVM vm) : base(vm) {
16      InitializeComponent();
17      foreach (var i in VM.Item.Range) {
18        AddOption((string)i);
19        if(i == VM.Item.Value) {
20          comboBoxValues.SelectedItem = (string)i;
21        }
22      }
23
24    }
25
26    private void AddOption(string opt) {
27      AddComboOption(opt);
28      TextBox tb = new TextBox();
29      tb.Text = opt;
30      tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
31      tb.Size = new Size(420, 20);
32      tb.ReadOnly = true;
33
34      CheckBox checkBox = new CheckBox();
35      checkBox.Checked = true;
36     
37      checkBox.CheckStateChanged += (o, args) => {
38        if (checkBox.Checked)
39          AddComboOption(opt);
40        else
41          RemoveComboOption(opt);
42      };
43      tableOptions.Controls.Add(checkBox);
44      tableOptions.Controls.Add(tb);
45    }
46
47    private void AddComboOption(string opt) {
48      comboBoxValues.Items.Add(opt);
49      IList<string> items = new List<string>();
50      foreach (var i in comboBoxValues.Items) {
51        items.Add((string)i);
52      }
53      VM.Item.Range = items;
54      tableOptions.Refresh();
55    }
56
57    private void RemoveComboOption(string opt) {
58      comboBoxValues.Items.Remove(opt);
59      IList<string> items = new List<string>();
60      foreach (var i in comboBoxValues.Items) {
61        items.Add((string)i);
62      }
63      VM.Item.Range = items;
64      tableOptions.Refresh();
65    }
66   
67    private void comboBoxValues_SelectedValueChanged(object sender, EventArgs e) {
68      VM.Item.Value = (string)comboBoxValues.SelectedItem;
69    }
70
71    private void JsonItemValidValuesControl_Load(object sender, EventArgs e) {
72
73    }
74  }
75}
Note: See TracBrowser for help on using the repository browser.