Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026

  • removed the option to set the value for JsonItems via exporter
    • reworked some base controls
    • added new controls for JsonItem specific properties (e.g. ArrayResizable)
    • deleted a lot of obsolet controls
  • removed the Enable checkbox in the detail view of JsonItems
  • exporter now clones the IOptimizer object
  • added a check + message for unsupported exports
  • list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
  • refactored the converter type check
    • now every converter has to specify its supported type(s)
File size: 1.4 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    private static IDictionary<Type, Type> JI2VM { get; set; }
15
16    public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) {
17      InitializeComponent();
18      InitCache();
19      if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) {
20        IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType);
21        tmp.Item = vm.JsonItemReference;
22        content.Controls.Clear();
23        UserControl control = tmp.Control;
24        if(control != null) {
25          content.Controls.Add(control);
26          control.Dock = DockStyle.Fill;
27        }
28      }
29    }
30
31    private void InitCache() {
32      if(JI2VM == null) {
33        JI2VM = new Dictionary<Type, Type>();
34        foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) {
35          IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
36          JI2VM.Add(vm.TargetedJsonItemType, vmType);
37        }
38      }
39    }
40  }
41}
Note: See TracBrowser for help on using the repository browser.