Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs @ 17477

Last change on this file since 17477 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.7 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  public class IntValueVM : SingleValueVM<int, IntJsonItem> {
11    public override Type TargetedJsonItemType => typeof(IntJsonItem);
12
13    protected override int MinTypeValue => int.MinValue;
14    protected override int MaxTypeValue => int.MaxValue;
15
16    public override UserControl Control =>
17      new JsonItemIntValueControl(this);
18  }
19
20  public class DoubleValueVM : SingleValueVM<double, DoubleJsonItem> {
21    public override Type TargetedJsonItemType => typeof(DoubleJsonItem);
22
23    protected override double MinTypeValue => double.MinValue;
24    protected override double MaxTypeValue => double.MaxValue;
25
26    public override UserControl Control =>
27       new JsonItemDoubleValueControl(this);
28  }
29
30  public class BoolValueVM : JsonItemVMBase<BoolJsonItem> {
31    public override Type TargetedJsonItemType => typeof(BoolJsonItem);
32
33    public bool Value {
34      get => Item.Value;
35      set {
36        Item.Value = value;
37        OnPropertyChange(this, nameof(Value));
38      }
39    }
40   
41    public override UserControl Control =>
42       new JsonItemBoolControl(this);
43  }
44
45  public abstract class SingleValueVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType>
46    where T : IComparable
47    where JsonItemType : class, IIntervalRestrictedJsonItem<T>, IValueJsonItem<T>
48  {
49
50    public T Value {
51      get => Item.Value;
52      set {
53        Item.Value = value;
54        OnPropertyChange(this, nameof(Value));
55      }
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.