Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/21 14:37:18 (3 years ago)
Author:
dpiringe
Message:

#3026

  • removed the option to set the value for JsonItems via exporter
    • reworked some base controls
    • added new controls for JsonItem specific properties (e.g. ArrayResizable)
    • deleted a lot of obsolet controls
  • removed the Enable checkbox in the detail view of JsonItems
  • exporter now clones the IOptimizer object
  • added a check + message for unsupported exports
  • list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
  • refactored the converter type check
    • now every converter has to specify its supported type(s)
File:
1 edited

Legend:

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

    r17560 r17828  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading;
    6 using System.Threading.Tasks;
    7 using System.Windows.Forms;
     1using System.Linq;
    82
    93namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    10   public class StringValueVM : JsonItemVMBase<StringJsonItem> {
    11     public override UserControl Control =>
    12        new JsonItemValidValuesControl(this);
    134
    14     public string Value {
    15       get => Item.Value?.ToString();
    16       set {
    17         Item.Value = value;
    18         OnPropertyChange(this, nameof(Value));
    19       }
    20     }
     5  public class StringValueVM : ConcreteRestrictedJsonItemVM<StringJsonItem, string, string> {
     6    protected override string GetDefaultValue() => Range.FirstOrDefault();
    217
    22     public IEnumerable<string> Range {
    23       get => Item.ConcreteRestrictedItems;
    24       set {
    25         Item.ConcreteRestrictedItems = value;
    26         //check if value is still in range
    27         if (!Range.Contains(Value)) {
    28           Value = Range.FirstOrDefault();
    29           if (Range.Count() == 0)
    30             //if no elements exists -> deselect item
    31             base.Selected = false;
    32           OnPropertyChange(this, nameof(Value));
    33         }
    34        
    35         OnPropertyChange(this, nameof(Range));
    36       }
    37     }
     8    protected override bool RangeContainsValue() => Range.Contains(Value);
    389  }
    3910
    40   public class StringArrayVM : JsonItemVMBase<StringArrayJsonItem> {
    41     public override UserControl Control =>
    42        new JsonItemConcreteItemArrayControl(this);
     11  public class StringArrayVM : ConcreteRestrictedJsonItemVM<StringArrayJsonItem, string, string[]> {
     12    protected override string[] GetDefaultValue() => Range.ToArray();
    4313
    44     public string[] Value {
    45       get => Item.Value;
    46       set {
    47         Item.Value = value;
    48         OnPropertyChange(this, nameof(Value));
    49       }
    50     }
    51 
    52     public IEnumerable<string> Range {
    53       get => Item.ConcreteRestrictedItems;
    54       set {
    55         Item.ConcreteRestrictedItems = value;
    56         OnPropertyChange(this, nameof(Range));
    57       }
    58     }
     14    protected override bool RangeContainsValue() => Value.All(x => Range.Any(y => x == y));
    5915  }
    6016}
Note: See TracChangeset for help on using the changeset viewer.