Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.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.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using System.Windows.Forms;
8
9namespace HeuristicLab.JsonInterface.OptimizerIntegration {
10
11  public class IntRangeVM : RangeVM<int, IntRangeJsonItem> {
12    public override Type TargetedJsonItemType => typeof(IntRangeJsonItem);
13
14    protected override int MinTypeValue => int.MinValue;
15
16    protected override int MaxTypeValue => int.MaxValue;
17
18    public override UserControl Control =>
19      new JsonItemRangeControl(this);
20  }
21
22  public class DoubleRangeVM : RangeVM<double, DoubleRangeJsonItem> {
23    public override Type TargetedJsonItemType => typeof(DoubleRangeJsonItem);
24
25    protected override double MinTypeValue => double.MinValue;
26
27    protected override double MaxTypeValue => double.MaxValue;
28
29    public override UserControl Control =>
30      new JsonItemRangeControl(this);
31  }
32
33  public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>
34    where T : IComparable
35    where JsonItemType : class, IRangedJsonItem<T>
36  {
37
38    public T MinValue {
39      get => Item.MinValue;
40      set {
41        Item.MinValue = value;
42        OnPropertyChange(this, nameof(MinValue));
43      }
44    }
45
46    public T MaxValue {
47      get => Item.MaxValue;
48      set {
49        Item.MaxValue = value;
50        OnPropertyChange(this, nameof(MaxValue));
51      }
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.