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

Last change on this file since 17843 was 17843, checked in by dpiringe, 7 weeks 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.6 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;
10using HeuristicLab.PluginInfrastructure;
11
12namespace HeuristicLab.JsonInterface.OptimizerIntegration {
13  public partial class ValueLookupJsonItemControl : UserControl {
14
15    private static IDictionary<Type, Type> ji2vm = null;
16    private static IDictionary<Type, Type> JI2VM {
17      get {
18        if (ji2vm == null) {
19          ji2vm = new Dictionary<Type, Type>();
20          foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) {
21            IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
22            ji2vm.Add(vm.TargetedJsonItemType, vmType);
23          }
24        }
25        return ji2vm;
26      }
27    }
28
29    private ValueLookupJsonItemControl() {
30      InitializeComponent();
31    }
32
33    protected ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) {
34      InitializeComponent();
35      if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) {
36        IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType);
37        tmp.Item = vm.JsonItemReference;
38        content.Controls.Clear();
39        UserControl control = tmp.Control;
40        if(control != null) {
41          content.Controls.Add(control);
42          control.Dock = DockStyle.Fill;
43        }
44      }
45    }
46
47    public static ValueLookupJsonItemControl Create(IValueLookupJsonItemVM vm) => new ValueLookupJsonItemControl(vm);
48  }
49}
Note: See TracBrowser for help on using the repository browser.