This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmAppSettings.cs
250 lines (209 loc) · 7.99 KB
/
frmAppSettings.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Octo_Streamer
{
public partial class frmAppSettings : Form
{
public frmAppSettings()
{
InitializeComponent();
}
#region Form Load
private void frmAppSettings_Load(object sender, EventArgs e)
{
#region Application addons
// check to see if there is currently a connection active to the remote server
if (csSettings.connectionActive == 1)
{
// there is currently an active connection to the remote server so we cannot allow changes to be made
groupApplicationAddons.Text = "Application Addons (please disconnect from server first!)";
groupApplicationAddons.Enabled = false;
}
else
{
// there is currently no connection to the remote server
groupApplicationAddons.Text = "Application Addons";
groupApplicationAddons.Enabled = true;
}
// Check if displayLayerProgress is enabled in application settings
if (csSettings.displayLayerProgress == 1)
{
// Setting is enabled, check the box
chkDisplayLayerProgress.Checked = true;
}
else
{
// Setting is disabled, dont check the box
chkDisplayLayerProgress.Checked = false;
}
#endregion
#region Stream Settings
// Check if toolTempTarget is enabled in application settings
if (csSettings.toolTempTargetSwitch == 1)
{
// Setting is enabled, check the box
chkToolTempTarget.Checked = true;
}
else
{
// Setting is disabled, dont check the box
chkToolTempTarget.Checked = false;
}
// Check if bedTempTarget is enabled in application settings
if (csSettings.bedTempTargetSwitch == 1)
{
// Setting is enabled, check the box
chkBedTempTarget.Checked = true;
}
else
{
// Setting is disabled, dont check the box
chkBedTempTarget.Checked = false;
}
#endregion
}
#endregion
#region DisplayLayerProgress Plugin Link
private void lblDisplayLayerProgressLink_Click(object sender, EventArgs e)
{
// Open octoprint plugin repository and navigate to DisplayLayerProgress plugin
System.Diagnostics.Process.Start("https://plugins.octoprint.org/plugins/DisplayLayerProgress/");
}
#endregion
#region Update Addons
private void btnUpdateAddons_Click(object sender, EventArgs e)
{
// Define registry scope
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Octo-Streamer", true);
// Check to see if registry folder exists in the context
if (key != null)
{
// Check to see if displayLayerProgress checkbox has been checked
if (chkDisplayLayerProgress.Checked == true)
{
// Checkbox is checked, store setting
csSettings.displayLayerProgress = 1;
key.SetValue("displayLayerProgress", "1");
}
else
{
// Checkbox is not checked, store setting
csSettings.displayLayerProgress = 0;
key.SetValue("displayLayerProgress", "0");
}
// Close key
key.Close();
}
// Update connection state
csSettings.updateDataSignal = 2;
// Show saved tag and start delay
lblUpdatedAddons.Visible = true;
btnUpdateAddons.Enabled = false;
tmrSaveApplicationAddons.Enabled = true;
tmrSaveApplicationAddons.Start();
}
private void tmrSaveApplicationAddons_Tick(object sender, EventArgs e)
{
// Stop the timer
tmrSaveApplicationAddons.Stop();
tmrSaveApplicationAddons.Enabled = false;
// Hide saved tag
lblUpdatedAddons.Visible = false;
// Enable update button
btnUpdateAddons.Enabled = true;
}
#endregion
#region Update Stream Settings
private void btnUpdateStreamSettings_Click(object sender, EventArgs e)
{
// Define registry scope
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Octo-Streamer", true);
// Check to see if registry folder exists in the context
if (key != null)
{
// Check to see if ToolTempTarget checkbox has been checked
if (chkToolTempTarget.Checked == true)
{
// Checkbox is checked, store setting
csSettings.toolTempTargetSwitch = 1;
key.SetValue("toolTempTarget", "1");
}
else
{
// Checkbox is not checked, store setting
csSettings.toolTempTargetSwitch = 0;
key.SetValue("toolTempTarget", "0");
}
// Check to see if BedTempTarget checkbox has been checked
if (chkBedTempTarget.Checked == true)
{
// Checkbox is checked, store setting
csSettings.bedTempTargetSwitch = 1;
key.SetValue("bedTempTarget", "1");
}
else
{
// Checkbox is not checked, store setting
csSettings.bedTempTargetSwitch = 0;
key.SetValue("bedTempTarget", "0");
}
// Close key
key.Close();
}
// Show saved tag and start delay
lblUpdatedStreamSettings.Visible = true;
btnUpdateStreamSettings.Enabled = false;
tmrSaveStreamSettings.Enabled = true;
tmrSaveStreamSettings.Start();
}
private void tmrSaveStreamSettings_Tick(object sender, EventArgs e)
{
// Stop the timer
tmrSaveStreamSettings.Stop();
tmrSaveStreamSettings.Enabled = false;
// Hide saved tag
lblUpdatedStreamSettings.Visible = false;
// Enable update button
btnUpdateStreamSettings.Enabled = true;
}
#endregion
#region Open Stream Directory
private void btnOpenStreamDirectory_Click(object sender, EventArgs e)
{
// Open stream directory
System.Diagnostics.Process.Start(Application.StartupPath + "/stream");
}
#endregion
#region Stream Setup Guide
private void linkStreamSetupGuide_Click(object sender, EventArgs e)
{
// Navigate to github wiki for setting up stream
System.Diagnostics.Process.Start("https://github.com/dualznz/Octo-Streamer");
}
#endregion
#region Camera Feed
private void btnCameraStream_Click(object sender, EventArgs e)
{
string portCheck = null;
if (csSettings.connectionPort != null)
{
portCheck = ":" + csSettings.connectionPort;
}
else
{
portCheck = null;
}
// Open camera stream (OctoPrint)
System.Diagnostics.Process.Start(csSettings.connectionAddress + portCheck + "/webcam/?action=stream");
}
#endregion
}
}