-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainWindowViewModel.cs
More file actions
132 lines (114 loc) · 4.03 KB
/
Copy pathMainWindowViewModel.cs
File metadata and controls
132 lines (114 loc) · 4.03 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace CurveEditor
{
public class ControlValueViewModel : Livet.ViewModel
{
public float Value => Model.Value;
public float RangeValue => Model.RangeValue;
public float NormalizedTime => Model.NormalizedTime;
ControlValue Model { get; }
public ControlValueViewModel(ControlValue model)
{
Model = model;
Model.PropertyChanged += Model_PropertyChanged;
CompositeDisposable.Add(() =>
{
Model.PropertyChanged -= Model_PropertyChanged;
});
}
private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
switch(e.PropertyName)
{
case nameof(ControlValue.Value):
RaisePropertyChanged(nameof(Value));
break;
case nameof(ControlValue.RangeValue):
RaisePropertyChanged(nameof(RangeValue));
break;
case nameof(ControlValue.NormalizedTime):
RaisePropertyChanged(nameof(NormalizedTime));
break;
}
}
}
class MainWindowViewModel : Livet.ViewModel
{
public bool IsClampEnabled
{
get => _IsClampEnabled;
set => RaisePropertyChangedIfSet(ref _IsClampEnabled, value);
}
bool _IsClampEnabled = false;
public bool IsRangeEnabled
{
get => _IsRangeEnabled;
set => RaisePropertyChangedIfSet(ref _IsRangeEnabled, value);
}
bool _IsRangeEnabled = false;
public bool IsReadOnlyCurveType
{
get => _IsReadOnlyCurveType;
set => RaisePropertyChangedIfSet(ref _IsReadOnlyCurveType, value);
}
bool _IsReadOnlyCurveType = true;
public bool IsReadOnlyClampFlag
{
get => _IsReadOnlyClampFlag;
set => RaisePropertyChangedIfSet(ref _IsReadOnlyClampFlag, value);
}
bool _IsReadOnlyClampFlag = false;
public bool IsReadOnlyRangeFlag
{
get => _IsReadOnlyRangeFlag;
set => RaisePropertyChangedIfSet(ref _IsReadOnlyRangeFlag, value);
}
bool _IsReadOnlyRangeFlag = false;
public CurveType CurveType
{
get => _CurveType;
set => RaisePropertyChangedIfSet(ref _CurveType, value);
}
CurveType _CurveType = CurveType.CatmullRom;
public float MinValue
{
get => _MinValue;
set => RaisePropertyChangedIfSet(ref _MinValue, value);
}
float _MinValue = 0;
public float MaxValue
{
get => _MaxValue;
set => RaisePropertyChangedIfSet(ref _MaxValue, value);
}
float _MaxValue = 100;
public IEnumerable<ControlValue> ControlPoints => _ControlPoints;
ObservableCollection<ControlValue> _ControlPoints = new ObservableCollection<ControlValue>();
public IEnumerable<ControlValueViewModel> ControlPointVMs => _ControlPointVMs;
ObservableCollection<ControlValueViewModel> _ControlPointVMs = new ObservableCollection<ControlValueViewModel>();
public MainWindowViewModel()
{
_ControlPoints.Add(new ControlValue(0.0f, 0.0f));
_ControlPoints.Add(new ControlValue(100.0f, 0.5f));
_ControlPoints.Add(new ControlValue(50.0f, 0.8f));
_ControlPoints.Add(new ControlValue(60.0f, 1.0f));
foreach (var m in _ControlPoints)
{
_ControlPointVMs.Add(new ControlValueViewModel(m));
}
CompositeDisposable.Add(() =>
{
foreach(var vm in _ControlPointVMs)
{
vm.Dispose();
}
});
}
}
}