Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemRangeControl.cs @ 17712

Last change on this file since 17712 was 17473, checked in by dpiringe, 5 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: 2.5 KB
RevLine 
[17404]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 {
[17464]13  public partial class JsonItemRangeControl : UserControl {
14    IJsonItemVM VM { get; set; }
[17404]15
[17464]16
17    public JsonItemRangeControl(DoubleRangeVM vm) {
[17404]18      InitializeComponent();
[17464]19      VM = vm;
[17454]20      textBoxValueFrom.DataBindings.Add("Text", vm, nameof(vm.MinValue));
21      textBoxValueTo.DataBindings.Add("Text", vm, nameof(vm.MaxValue));
22      InitNumbericRangeControl();
23
[17404]24    }
[17464]25    public JsonItemRangeControl(IntRangeVM vm) {
[17420]26      InitializeComponent();
[17464]27      VM = vm;
[17454]28      textBoxValueFrom.DataBindings.Add("Text", vm, nameof(vm.MinValue));
29      textBoxValueTo.DataBindings.Add("Text", vm, nameof(vm.MaxValue));
30      InitNumbericRangeControl();
[17420]31    }
[17454]32
33    private void InitNumbericRangeControl() {
[17473]34      numericRangeControl.TBMinRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange));
35      numericRangeControl.TBMaxRange.DataBindings.Add("Text", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange));
36      numericRangeControl.EnableMinRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange),
[17454]37        false, DataSourceUpdateMode.OnPropertyChanged);
[17473]38      numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", VM, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange),
[17454]39        false, DataSourceUpdateMode.OnPropertyChanged);
40    }
41
[17410]42    /*
43    protected abstract object Parse(string s);
[17404]44
45    private void SetValue() {
[17405]46      if (!string.IsNullOrWhiteSpace(textBoxValueFrom.Text))
[17404]47        value[0] = Parse(textBoxValueFrom.Text);
48      else
49        value[0] = ((Array)VM.Item.Value).GetValue(0);
50
[17405]51      if (!string.IsNullOrWhiteSpace(textBoxValueTo.Text))
[17404]52        value[1] = Parse(textBoxValueTo.Text);
53      else
54        value[1] = ((Array)VM.Item.Value).GetValue(1);
55      VM.Item.Value = value;
56    }
[17405]57   
[17404]58    private void textBoxValueFrom_Leave(object sender, EventArgs e) {
59      SetValue();
60    }
61
62    private void textBoxValueTo_Leave(object sender, EventArgs e) {
63      SetValue();
64    }
65
[17405]66    private void numericRangeControl1_Load(object sender, EventArgs e) {
67      numericRangeControl1.IsDouble = isDouble;
68      numericRangeControl1.VM = VM;
[17404]69    }
[17410]70    */
[17404]71  }
72}
Note: See TracBrowser for help on using the repository browser.