-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValueInjector.cs
100 lines (87 loc) · 3.53 KB
/
ValueInjector.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ODIF;
namespace ValueInjector
{
[PluginInfo(
PluginName = "Value Injector",
PluginDescription = "",
PluginID = 0,
PluginAuthorName = "InputMapper",
PluginAuthorEmail = "[email protected]",
PluginAuthorURL = "http://inputmapper.com",
PluginIconPath = @"pack://application:,,,/SimpleLogic;component/Resources/share-icon.png"
)]
[CompatibleTypes(
InputTypes = mappingIOTypes.Bool,
OutputTypes = mappingIOTypes.Bool| mappingIOTypes.Double
)]
public class ValueInjector : InputModificationPlugin
{
Setting ValType, FixedValue, ChannelValue, PluginValue;
dynamic cachedValue = 0d;
bool inVal = false;
public ValueInjector(Guid guid) : base(guid)
{
ValType = new Setting("Value Type", "Type of value that will be used", SettingControl.Dropdown, SettingType.Text, "fixed", true, true);
ValType.configuration.Add("options", new List<string>() { "fixed", "input channel", "existing plugin value" });
ValType.PropertyChanged += ValType_PropertyChanged; ;
FixedValue = new Setting("Fixed Value", "value that will used", SettingControl.Numeric, SettingType.Decimal, 0d, true, true);
FixedValue.configuration["interval"] = .1d;
ChannelValue = new Setting("Input Channel", "", SettingControl.InputChannelSelector, SettingType.Text, new DeviceChannel(), false, true);
settings.settings.Add(ValType);
settings.settings.Add(FixedValue);
settings.settings.Add(ChannelValue);
//trueChannelValue.configuration.Add("options", new List<string>() { "fixed", "input channel", "existing plugin value" });
ChannelValue.PropertyChanged += ChannelValue_PropertyChanged;
SetValue(false);
}
private void ChannelValue_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (ChannelValue.settingValue != null)
{
(ChannelValue.settingValue as DeviceChannel).PropertyChanged += (s, ev) => { SetValue(cachedValue); };
}
}
private void ValType_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (ValType.settingValue == "fixed")
{
FixedValue.visible = true;
ChannelValue.visible = false;
}
if (ValType.settingValue == "input channel")
{
FixedValue.visible = false;
ChannelValue.visible = true;
}
if (ValType.settingValue == "existing plugin value")
{
FixedValue.visible = false;
ChannelValue.visible = false;
}
}
public override void SetValue(dynamic inValue)
{
if (inValue == inVal) return;
inVal = inValue;
if (inValue == true)
{
if (ValType.settingValue == "fixed")
{
this.Value = FixedValue.settingValue;
}
if (ValType.settingValue == "input channel")
{
this.Value = ChannelValue.settingValue.Value;
}
if (ValType.settingValue == "existing plugin value")
{
}
}
}
}
}