Last change
on this file since 17417 was
17417,
checked in by dpiringe, 4 years ago
|
#3026:
- added initial VM (ArrayValueVM) and control for array values (JsonItemArrayValueControl)
- new types of JsonItems for better type safety:
- for arrays: DoubleArrayJsonItem, IntArrayJsonItem, BoolArrayJsonItem
- for matrix: DoubleMatrixJsonItem, IntMatrixJsonItem, BoolMatrixJsonItem
- refactored ValueTypeArrayConverter and ValueTypeMatrixConverter -> better type safety with new JsonItems
- enhanced StringValueVM and implemented JsonItemValidValuesControl with MVVM architecture
- the VM of JsonItemBaseControl is now protected (was private)
- improved JsonItem<V,R> -> now handles JTokens correctly
|
File size:
1.1 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 |
|
---|
7 | namespace 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.