-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBPGEView.cs
More file actions
94 lines (84 loc) · 3.01 KB
/
Copy pathBPGEView.cs
File metadata and controls
94 lines (84 loc) · 3.01 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
using System.Net;
namespace BPGE
{
using Terminal.Gui;
public partial class BPGEView : Window
{
private bool _debug;
public int IntifacePort;
public string IntifaceIP;
public HttpReceiver HttpReceiver;
public VibrationManager VibrationManager;
public BPGEView(bool debug, int intifacePort, string intifaceIP)
{
_debug = debug;
IntifacePort = intifacePort;
IntifaceIP = intifaceIP;
init();
serverLabel.Clicked += () => {
Clipboard.Contents = $"http://{Dns.GetHostName().ToLower()}.local/Temporary_Listen_Addresses/";
MessageBox.Query ("Copied", "Copied to clipboard", "Ok");
};
btnTest.Clicked += async () => {
if (VibrationManager is { Client.Connected: true })
{
new Thread(async () =>
{
foreach (var buttplugClientDevice in VibrationManager.Client.Devices)
{
await buttplugClientDevice.VibrateAsync(1);
}
Thread.Sleep(1000);
foreach (var buttplugClientDevice in VibrationManager.Client.Devices)
{
await buttplugClientDevice.VibrateAsync(0);
}
}).Start();
}
};
btnReconnect.Clicked += async () =>
{
VibrationManager?.Reconnect();
};
btnStopVibration.Clicked += async () =>
{
VibrationManager?.ClearArray();
new Thread(async () =>
{
if (VibrationManager?.Client?.Devices == null) return;
foreach (var buttplugClientDevice in VibrationManager.Client.Devices)
{
await buttplugClientDevice.VibrateAsync(0);
}
}).Start();
};
Initialized += (s,e) => {
LogDebug(Directory.GetCurrentDirectory());
HttpReceiver = new HttpReceiver(this);
HttpReceiver.Thread.Start();
VibrationManager = new VibrationManager(this);
VibrationManager.Init();
};
}
private void Log(string text)
{
logView.Text += text + "\n";
logView.MoveEnd();
}
public void LogInfo(string text)
{
Log($"[{DateTime.Now.ToString("HH:mm:ss")}] [INFO] {text}");
}
public void LogDebug(string text)
{
if (_debug)
{
Log($"[{DateTime.Now.ToString("HH:mm:ss")}] [DEBUG] {text}");
}
}
public void LogError(string text)
{
Log($"[{DateTime.Now.ToString("HH:mm:ss")}] [ERROR] {text}");
}
}
}