Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemValueControl.cs @ 17417

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

#3026:

  • added initial VM (ArrayValueVM) and control for array values (JsonItemArrayValueControl)
  • new types of JsonItems for better type safety:
    • for arrays: DoubleArrayJsonItem, IntArrayJsonItem, BoolArrayJsonItem
    • for matrix: DoubleMatrixJsonItem, IntMatrixJsonItem, BoolMatrixJsonItem
  • refactored ValueTypeArrayConverter and ValueTypeMatrixConverter -> better type safety with new JsonItems
  • enhanced StringValueVM and implemented JsonItemValidValuesControl with MVVM architecture
  • the VM of JsonItemBaseControl is now protected (was private)
  • improved JsonItem<V,R> -> now handles JTokens correctly
File size: 2.9 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 System.Globalization;
11
12namespace HeuristicLab.JsonInterface.OptimizerIntegration {
13
14  public class JsonItemIntValueControl : JsonItemValueControl {
15
16    #region Overriden Properties
17    protected override string ValuePropertyId => nameof(IntValueVM.Value);
18    protected override string MinRangePropertyId => nameof(IntValueVM.MinRange);
19    protected override string MaxRangePropertyId => nameof(IntValueVM.MaxRange);
20    protected override string EnableMinRangePropertyId => nameof(IntValueVM.EnableMinRange);
21    protected override string EnableMaxRangePropertyId => nameof(IntValueVM.EnableMaxRange);
22    #endregion
23
24    public JsonItemIntValueControl(IntValueVM vm) : base(vm) {
25      Init();
26    }
27
28  }
29
30  public class JsonItemDoubleValueControl : JsonItemValueControl {
31
32    #region Overriden Properties
33    protected override string ValuePropertyId => nameof(DoubleValueVM.Value);
34    protected override string MinRangePropertyId => nameof(DoubleValueVM.MinRange);
35    protected override string MaxRangePropertyId => nameof(DoubleValueVM.MaxRange);
36    protected override string EnableMinRangePropertyId => nameof(DoubleValueVM.EnableMinRange);
37    protected override string EnableMaxRangePropertyId => nameof(DoubleValueVM.EnableMaxRange);
38    #endregion
39
40    public JsonItemDoubleValueControl(DoubleValueVM vm) : base(vm) {
41      Init();
42    }
43
44  }
45
46  public abstract partial class JsonItemValueControl : JsonItemBaseControl {
47    #region Protected Properties
48    protected TextBox TBValue { get; set; }
49    protected NumericRangeControl NumericRangeControl { get; set; }
50    #endregion
51
52    #region Abstract Properties
53    protected abstract string ValuePropertyId { get; }
54    protected abstract string MinRangePropertyId { get; }
55    protected abstract string MaxRangePropertyId { get; }
56    protected abstract string EnableMinRangePropertyId { get; }
57    protected abstract string EnableMaxRangePropertyId { get; }
58    #endregion
59
60    public JsonItemValueControl(JsonItemVMBase vm) : base(vm) {
61      InitializeComponent();
62      TBValue = textBoxValue;
63      NumericRangeControl = numericRangeControl1;
64    }
65
66    protected void Init() {
67      TBValue.DataBindings.Add("Text", base.VM, ValuePropertyId);
68      NumericRangeControl.TBMinRange.DataBindings.Add("Text", VM, MinRangePropertyId);
69      NumericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, MaxRangePropertyId);
70      NumericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, EnableMinRangePropertyId,
71        false, DataSourceUpdateMode.OnPropertyChanged);
72      NumericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, EnableMaxRangePropertyId,
73        false, DataSourceUpdateMode.OnPropertyChanged);
74    }
75
76  }
77}
Note: See TracBrowser for help on using the repository browser.