Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17404 was 17404, checked in by dpiringe, 5 years ago

#3026:

  • fixed a bug in BaseConverter -> the range for percent values should be returned correctly now
  • fixed a bug in ConstrainedValueParameterConverter, ParameterizedItemConverter, ValueParameterConverter -> unsupported json items get filtered now
  • JCGenerator is now a dynamic class and can return all JsonItems for an IOptimizer now (instead of string only) + it is now possible to generate an template string with an IEnumerable<JsonItem>
  • added first version of an export dialog for JsonInterface
    • it is organized with a main view (for the dialog) and some user controls (for a better visualization of an JsonItem -> to reduce wrong user inputs)
    • the user controls inherit a base control, which organizes some base values of an JsonItem
File size: 1.9 KB
RevLine 
[17404]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    private void AddOption(string opt) {
26      comboBoxValues.Items.Add(opt);
27      TextBox tb = new TextBox();
28      tb.Text = opt;
29      tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
30      tb.Size = new Size(420, 20);
31      tb.ReadOnly = true;
32      Button btn = new Button();
33      btn.Text = "-";
34      btn.Size = new Size(20, 20);
35      btn.Click += (o, args) => {
36        tableOptions.Controls.Remove(tb);
37        tableOptions.Controls.Remove(btn);
38        comboBoxValues.Items.Remove(tb.Text);
39        IList<string> items = new List<string>();
40        foreach(var i in comboBoxValues.Items) {
41          items.Add((string)i);
42        }
43        VM.Item.Range = items;
44        tableOptions.Refresh();
45      };
46      tableOptions.Controls.Add(tb);
47      tableOptions.Controls.Add(btn);
48    }
49
50    private void buttonAdd_Click(object sender, EventArgs e) {
51      string newOption = textBoxAdd.Text;
52      if (string.IsNullOrWhiteSpace(newOption)) return;
53      textBoxAdd.Text = "";
54      AddOption(newOption);
55    }
56
57    private void comboBoxValues_SelectedValueChanged(object sender, EventArgs e) {
58      VM.Item.Value = (string)comboBoxValues.SelectedItem;
59    }
60
61    private void JsonItemValidValuesControl_Load(object sender, EventArgs e) {
62
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.