1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.JsonInterface.OptimizerIntegration {
|
---|
9 | public class JsonItemVMBase : INotifyPropertyChanged {
|
---|
10 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
11 | public IJsonItem Item { get; set; }
|
---|
12 |
|
---|
13 | protected void OnPropertyChange(object sender, string propertyName) {
|
---|
14 | // Make a temporary copy of the event to avoid possibility of
|
---|
15 | // a race condition if the last subscriber unsubscribes
|
---|
16 | // immediately after the null check and before the event is raised.
|
---|
17 | // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/events/how-to-raise-base-class-events-in-derived-classes
|
---|
18 |
|
---|
19 | PropertyChangedEventHandler tmp = PropertyChanged;
|
---|
20 | tmp?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
---|
21 | }
|
---|
22 |
|
---|
23 | public virtual Type JsonItemType => typeof(JsonItem);
|
---|
24 |
|
---|
25 | //protected IJsonItemValueParser Parser { get; set; }
|
---|
26 | //child tree
|
---|
27 | //private IList<JsonItemVM> nodes = new List<JsonItemVM>();
|
---|
28 |
|
---|
29 | //public IEnumerable<JsonItemVM> Nodes { get => nodes; }
|
---|
30 | //public JsonItemVM Parent { get; private set; }
|
---|
31 |
|
---|
32 |
|
---|
33 | private bool selected = true;
|
---|
34 | public bool Selected {
|
---|
35 | get => selected;
|
---|
36 | set {
|
---|
37 | selected = value;
|
---|
38 | OnPropertyChange(this, nameof(Selected));
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public string Name {
|
---|
43 | get => Item.Name;
|
---|
44 | set {
|
---|
45 | Item.Name = value;
|
---|
46 | OnPropertyChange(this, nameof(Name));
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public string ActualName {
|
---|
51 | get => Item.ActualName;
|
---|
52 | set {
|
---|
53 | Item.ActualName = value;
|
---|
54 | OnPropertyChange(this, nameof(ActualName));
|
---|
55 | }
|
---|
56 | }
|
---|
57 | public virtual JsonItemBaseControl GetControl() {
|
---|
58 | return new JsonItemBaseControl(this);
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|
62 | }
|
---|