Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026:

  • refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
  • updated view models for new json item structure
  • updated SingleLineArrayJsonWriter
File size: 1.3 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 : LookupJsonItemControl {
14    private static IDictionary<Type, Type> JI2VM { get; set; }
15
16    public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) : base(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        content.Controls.Add(control);
25        control.Dock = DockStyle.Fill;
26       
27      }
28    }
29
30    private void InitCache() {
31      if(JI2VM == null) {
32        JI2VM = new Dictionary<Type, Type>();
33        foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) {
34          IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType);
35          JI2VM.Add(vm.TargetedJsonItemType, vmType);
36        }
37      }
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.