Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ConcreteItemsRestrictor.cs @ 17843

Last change on this file since 17843 was 17843, checked in by dpiringe, 3 years ago

#3026

  • removed property ConvertableType from all converters
  • removed the option to fixate or loosen the path of JsonItems (obsolete)
  • added a abstract formatter SymbolicRegressionSolutionFormatterBase as base formatter for ISymbolicRegressionSolution
  • unified the construction of exporter controls
  • code cleanup
File size: 1.7 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 ConcreteItemsRestrictor : UserControl {
13
14    public event Action<object> OnChecked;
15    public event Action<object> OnUnchecked;
16
17    protected ConcreteItemsRestrictor() {
18      InitializeComponent();
19    }
20
21    public static ConcreteItemsRestrictor Create<T>(IEnumerable<T> objs) {
22      ConcreteItemsRestrictor ctrl = new ConcreteItemsRestrictor();
23      ctrl.Init<T>(objs);
24      return ctrl;
25    }
26
27    protected void Init<T>(IEnumerable<T> objs) {
28      if(objs != null)
29        foreach(var obj in objs)
30          SetupOption(obj);
31    }
32
33    private void SetupOption(object opt) {
34      AddComboOption(opt);
35      TextBox tb = new TextBox();
36      tb.Text = opt.ToString();
37      tb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
38      tb.ReadOnly = true;
39
40      CheckBox checkBox = new CheckBox();
41      checkBox.Checked = true;
42
43      checkBox.CheckStateChanged += (o, args) => {
44        if (checkBox.Checked)
45          AddComboOption(opt);
46        else
47          RemoveComboOption(opt);
48      };
49      tableOptions.Controls.Add(checkBox);
50      tableOptions.Controls.Add(tb);
51    }
52
53    private void AddComboOption(object obj) {
54      OnChecked?.Invoke(obj);
55      tableOptions.Refresh();
56    }
57
58    private void RemoveComboOption(object obj) {
59      OnUnchecked?.Invoke(obj);
60      tableOptions.Refresh();
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.