Skip to content

Commit

Permalink
Create a menu item and rpc command for reloading the config
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisaphone committed May 19, 2016
1 parent 96d59dc commit 39b70f8
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 88 deletions.
146 changes: 78 additions & 68 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions MainForm.cs
Expand Up @@ -83,5 +83,9 @@ public partial class MainForm : Form {
private void mnuTrayKeyCheck_Click(object sender, EventArgs e) {
MessageBox.Show(InputState.WhichNonModKeyIsDown().ToString());
}

private void mnuReloadConfig_Click(object sender, EventArgs e) {
App.config.Reload();
}
}
}
6 changes: 3 additions & 3 deletions MainForm.resx
Expand Up @@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mnuNotifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="mnuNotifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
25 changes: 8 additions & 17 deletions RPCServer.cs
Expand Up @@ -80,24 +80,15 @@ private void HandleContext(HttpListenerContext context)
}
}

private JToken HandleRequest(string method, JArray param)
{
if (method == "setRunning")
{
private JToken HandleRequest(string method, JArray param) {
if (method == "setRunning") {
var running = param[0].Value<bool>();
if (running)
{
App.audioMaster.Enabled = true;
return new JValue("Audio listening started");
}
else
{
App.audioMaster.Enabled = false;
return new JValue("Audio listening stopped");
}
}
else
{
App.audioMaster.Enabled = running;
return JValue.CreateNull();
} else if (method == "reloadConfig") {
App.config.Reload();
return JValue.CreateNull();
} else {
throw new ArgumentException("");
}
}
Expand Down

0 comments on commit 39b70f8

Please sign in to comment.