-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPluginToggleControlBase.cs
64 lines (54 loc) · 1.89 KB
/
PluginToggleControlBase.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
using BarRaider.SdTools;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace com.zaphop.nvidiabroadcast
{
public class PluginToggleControlBase : KeypadBase
{
private readonly NvidiaBroadcastManager _nvidiaBroadcastManager;
private bool _wasEnabledOnLastTick = false;
public PluginToggleControlBase(NvidiaBroadcastResourceID toggleResourceID, string configName, SDConnection connection, InitialPayload payload) : base(connection, payload)
{
_nvidiaBroadcastManager = new NvidiaBroadcastManager(toggleResourceID, configName);
UpdateToggleStatus();
}
public override void Dispose()
{
}
public override void KeyPressed(KeyPayload payload)
{
_nvidiaBroadcastManager.Toggle();
}
public override void KeyReleased(KeyPayload payload) { }
public override void OnTick()
{
UpdateToggleStatus();
}
public override void ReceivedSettings(ReceivedSettingsPayload payload)
{
}
public override void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload) { }
private void UpdateToggleStatus()
{
if (_nvidiaBroadcastManager.IsToggleEnabled() == true)
{
if (_wasEnabledOnLastTick == false)
{
Connection.SetImageAsync(Tools.FileToBase64("Images\\green72.png", true));
_wasEnabledOnLastTick = true;
}
}
else if (_wasEnabledOnLastTick == true)
{
Connection.SetImageAsync(Tools.FileToBase64("Images\\gray72.png", true));
_wasEnabledOnLastTick = false;
}
}
}
}