Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVM.cs @ 17405

Last change on this file since 17405 was 17405, checked in by dpiringe, 5 years ago

#3026:

  • added a new way to setup the targeted result types
  • added new ui controls: NumericRangeControl, JsonItemArrayControl, JsonItemDefaultControl
  • redesigned export dialog -> now the user can navigate with a tree view
  • enhanced JsonItemVM
File size: 1.2 KB
Line 
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace HeuristicLab.JsonInterface.OptimizerIntegration {
9  public delegate void OnSelectionChangeHandler(JsonItemVM sender, bool selection);
10  public delegate void OnChildAddedHandler(JsonItemVM sender, JsonItemVM child);
11
12  public class JsonItemVM {
13    public JsonItem Item { get; set; }
14
15    private IList<JsonItemVM> children = new List<JsonItemVM>();
16    public IEnumerable<JsonItemVM> Children {
17      get => children;
18    }
19
20    public JsonItemVM Parent { get; set; }
21
22    private bool selected = true;
23    public bool Selected {
24      get => selected;
25      set {
26        selected = value;
27        OnSelectionChange?.Invoke(this, Selected);
28      }
29    }
30
31    public event OnSelectionChangeHandler OnSelectionChange;
32    public event OnChildAddedHandler OnChildAdded;
33
34    public JsonItemVM(JsonItem item) {
35      this.Item = item;
36    }
37
38    public void AddChild(JsonItemVM vm) {
39      children.Add(vm);
40      vm.Parent = this;
41      OnChildAdded?.Invoke(this, vm);
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.