Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs @ 17443

Last change on this file since 17443 was 17443, checked in by dpiringe, 4 years ago

#3026:

  • added support for string values without range limitation (dropdown gets automatically replaced by textbox)
  • fixed a UI bug for JsonItemValidValuesControl -> now the control resizes correctly
  • fixed a bug in AlgorithmConverter -> now it searches for the ItemName (instead of Name) in method Inject
  • fixed a bug in StringValueConverter -> now it sets the correct name
File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace HeuristicLab.JsonInterface.OptimizerIntegration {
8  public class StringValueVM : JsonItemVMBase {
9    public override Type JsonItemType => typeof(StringJsonItem);
10    public override JsonItemBaseControl GetControl() =>
11       new JsonItemValidValuesControl(this);
12
13    public string Value {
14      get => Item.Value?.ToString();
15      set {
16        Item.Value = value;
17        OnPropertyChange(this, nameof(Value));
18      }
19    }
20
21    public IEnumerable<string> Range {
22      get => Item.Range?.Cast<string>();
23      set {
24        Item.Range = value;
25        //check if value is still in range
26        if (!Range.Any(x => x == Value)) {
27          Value = Range.FirstOrDefault();
28          if (Range.Count() == 0)
29            //if no elements exists -> deselect item
30            base.Selected = false;
31          OnPropertyChange(this, nameof(Value));
32        }
33       
34        OnPropertyChange(this, nameof(Range));
35      }
36    }
37  }
38}
Note: See TracBrowser for help on using the repository browser.