Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs @ 17464

Last change on this file since 17464 was 17464, checked in by dpiringe, 5 years ago

#3026:

  • Runner now uses SymbolicDataAnalysisExpressionMATLABFormatter to save instances of ISymbolicRegressionSolution
  • refactored user controls for detail view of json items, now they do not inherit from JsonItemBaseControl -> JsonItemBaseControl uses now an extra control
    • this change was made for fluid repositioning of controls (e.g. when no ActualName is present)
File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace HeuristicLab.JsonInterface.OptimizerIntegration {
9
10  public class IntRangeVM : RangeVM<int> {
11    public override Type JsonItemType => typeof(IntRangeJsonItem);
12
13    protected override int MinTypeValue => int.MinValue;
14
15    protected override int MaxTypeValue => int.MaxValue;
16
17    public override JsonItemBaseControl Control =>
18      new JsonItemBaseControl(this, new JsonItemRangeControl(this));
19  }
20
21  public class DoubleRangeVM : RangeVM<double> {
22    public override Type JsonItemType => typeof(DoubleRangeJsonItem);
23
24    protected override double MinTypeValue => double.MinValue;
25
26    protected override double MaxTypeValue => double.MaxValue;
27
28    public override JsonItemBaseControl Control =>
29      new JsonItemBaseControl(this, new JsonItemRangeControl(this));
30  }
31
32  public abstract class RangeVM<T> : RangedValueBaseVM<T> {
33
34    public T MinValue {
35      get => Cast(((Array)Item.Value).GetValue(0));
36      set {
37        SetValue(value, (T)((Array)Item.Value).GetValue(1));
38        OnPropertyChange(this, nameof(MinValue));
39      }
40    }
41
42    public T MaxValue {
43      get => Cast(((Array)Item.Value).GetValue(1));
44      set {
45        SetValue((T)((Array)Item.Value).GetValue(0), value);
46        OnPropertyChange(this, nameof(MaxValue));
47      }
48    }
49
50    private void SetValue(T min, T max) =>
51      Item.Value = new T[] { min, max };
52  }
53}
Note: See TracBrowser for help on using the repository browser.