Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/28/20 16:21:53 (5 years ago)
Author:
dpiringe
Message:

#3026:

  • deleted JsonItemVM
  • reduced code duplicates in JsonItemValueControl
  • implemented logic for entering ranges -> automatically sets to min/max value of datatype when checkbox is not checked
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs

    r17410 r17411  
    77
    88namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    9   public abstract class JsonItemVMBase : INotifyPropertyChanged {
     9  public class JsonItemVMBase : INotifyPropertyChanged {
    1010    public event PropertyChangedEventHandler PropertyChanged;
    1111    public IJsonItem Item { get; set; }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs

    r17410 r17411  
    1818  }
    1919
    20   public abstract class RangeVM<T> : JsonItemVM {
     20  public abstract class RangeVM<T> : JsonItemVMBase {
    2121
    2222    public T MinValue {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs

    r17410 r17411  
    1010  public class IntValueVM : SingleValueVM<int> {
    1111    public override Type JsonItemType => typeof(IntJsonItem);
     12
     13    protected override int MinTypeValue => int.MinValue;
     14    protected override int MaxTypeValue => int.MaxValue;
     15
    1216    public override JsonItemBaseControl GetControl() =>
    1317      new JsonItemIntValueControl(this);
     
    1519
    1620  public class DoubleValueVM : SingleValueVM<double> {
    17     public override Type JsonItemType => typeof(DoubleJsonItem);
     21    public override Type JsonItemType => typeof(DoubleJsonItem);
     22
     23    protected override double MinTypeValue => double.MinValue;
     24    protected override double MaxTypeValue => double.MaxValue;
     25
    1826    public override JsonItemBaseControl GetControl() =>
    1927       new JsonItemDoubleValueControl(this);
     
    2230  public class BoolValueVM : SingleValueVM<bool> {
    2331    public override Type JsonItemType => typeof(BoolJsonItem);
     32
     33    protected override bool MinTypeValue => false;
     34    protected override bool MaxTypeValue => true;
     35
    2436    public override JsonItemBaseControl GetControl() =>
    2537       new JsonItemBoolControl(this);
    2638  }
    2739
    28   public abstract class SingleValueVM<T> : JsonItemVM {
     40  public abstract class SingleValueVM<T> : JsonItemVMBase {
    2941   
    3042    public T Value {
     
    5264    }
    5365
     66    private bool enableMinRange = false;
     67    public bool EnableMinRange {
     68      get => enableMinRange;
     69      set {
     70        enableMinRange = value;
     71        if (!enableMinRange)
     72          MinRange = MinTypeValue;
     73        OnPropertyChange(this, nameof(EnableMinRange));
     74      }
     75    }
     76
     77    private bool enableMaxRange = false;
     78    public bool EnableMaxRange {
     79      get => enableMaxRange;
     80      set {
     81        enableMaxRange = value;
     82        if (!enableMaxRange)
     83          MaxRange = MaxTypeValue;
     84        OnPropertyChange(this, nameof(EnableMaxRange));
     85      }
     86    }
     87
    5488    private T Cast(object obj) => (T)Convert.ChangeType(obj, typeof(T));
    5589
     
    5993    }
    6094
     95    protected abstract T MinTypeValue { get; }
     96    protected abstract T MaxTypeValue { get; }
    6197  }
    6298}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs

    r17410 r17411  
    66
    77namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    8   public class StringValueVM : JsonItemVM {
     8  public class StringValueVM : JsonItemVMBase {
    99    public override Type JsonItemType => typeof(StringJsonItem);
    1010    public override JsonItemBaseControl GetControl() =>
Note: See TracChangeset for help on using the changeset viewer.