-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
StateViewModel.cs
84 lines (70 loc) · 2.19 KB
/
StateViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Windows;
namespace Nodify.StateMachine
{
public class StateViewModel : ObservableObject
{
public Guid Id { get; }
public StateViewModel(Guid id)
=> Id = id;
public StateViewModel() : this(Guid.NewGuid()) { }
// TODO: Can remove when auto layout is added
private Point _location;
public Point Location
{
get => _location;
set => SetProperty(ref _location, value);
}
private Point _anchor;
public Point Anchor
{
get => _anchor;
set => SetProperty(ref _anchor, value);
}
private Size _size;
public Size Size
{
get => _size;
set => SetProperty(ref _size, value);
}
private string? _name;
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
private bool _isRenaming;
public bool IsRenaming
{
get => _isRenaming;
set => SetProperty(ref _isRenaming, value);
}
private bool _isActive;
public bool IsActive
{
get => _isActive;
set => SetProperty(ref _isActive, value);
}
private BlackboardItemReferenceViewModel? _actionReference;
public BlackboardItemReferenceViewModel? ActionReference
{
get => _actionReference;
set
{
if (SetProperty(ref _actionReference, value))
{
SetAction(_actionReference);
}
}
}
public BlackboardItemViewModel? Action { get; private set; }
public bool IsEditable { get; set; } = true;
public StateMachineViewModel Graph { get; internal set; } = default!;
public NodifyObservableCollection<StateViewModel> Transitions { get; } = new NodifyObservableCollection<StateViewModel>();
private void SetAction(BlackboardItemReferenceViewModel? actionRef)
{
Action = BlackboardDescriptor.GetItem(actionRef);
OnPropertyChanged(nameof(Action));
}
}
}