Skip to content

Commit

Permalink
Added grouping option for remotes, added voice control, v1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
nicko88 committed Feb 16, 2024
1 parent 3e3eea0 commit c3e2fd8
Show file tree
Hide file tree
Showing 30 changed files with 1,355 additions and 161 deletions.
4 changes: 2 additions & 2 deletions HTWebRemote/Devices/Controllers/PCControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public static void RunCmd(string path, string param)
{
process.Start();
}
catch
catch (Exception e)
{
Util.ErrorHandler.SendError($"Cannot open or run file: \n\n{process.StartInfo.FileName}");
Util.ErrorHandler.SendError($"Cannot open or run file: \n\n{process.StartInfo.FileName}\n\n{e.Message}");
}
}
}
Expand Down
17 changes: 15 additions & 2 deletions HTWebRemote/Devices/Controllers/TCPUDPControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ namespace HTWebRemote.Devices.Controllers
{
class TCPUDPControl
{
public static void RunCmd(bool tcp, string IP, string cmd, string param)
public static void RunCmd(bool tcp, string IP, string cmd, string param, string recvWelcome)
{
if (string.IsNullOrEmpty(recvWelcome))
{
recvWelcome = "False";
}

SocketConnection Socket;
if (tcp)
{
Expand All @@ -36,7 +41,15 @@ public static void RunCmd(bool tcp, string IP, string cmd, string param)

if (Socket.Connect())
{
Thread.Sleep(100);
if (Convert.ToBoolean(recvWelcome))
{
Socket.ReceiveData();
}
else
{
Thread.Sleep(100);
}

Socket.SendData(cmdBytes);
Thread.Sleep(100);

Expand Down
4 changes: 2 additions & 2 deletions HTWebRemote/Devices/DeviceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ public static void CommandDevice(string IP, string devType, string cmd, string p
RS232Control.RunCmd(IP, cmd, param);
break;
case "tcp":
TCPUDPControl.RunCmd(true, IP, cmd, param);
TCPUDPControl.RunCmd(true, IP, cmd, param, specialData);
break;
case "udp":
TCPUDPControl.RunCmd(false, IP, cmd, param);
TCPUDPControl.RunCmd(false, IP, cmd, param, specialData);
break;
case "httppost":
HttpPostControl.RunCmd(IP, cmd, param, specialData);
Expand Down
4 changes: 4 additions & 0 deletions HTWebRemote/Forms/CommandEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ private void btnTestCmds_Click(object sender, EventArgs e)
{
hotkeyManager.Hotkeys[ButtonIndex].RunButtonCommands();
}
else if (Editor is VoiceCommandManager voiceCommandManager)
{
voiceCommandManager.VoiceCommands[ButtonIndex].RunButtonCommands();
}
}

private void CommandEditor_KeyDown(object sender, KeyEventArgs e)
Expand Down
15 changes: 15 additions & 0 deletions HTWebRemote/Forms/DeviceIPManager.Designer.cs

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

24 changes: 24 additions & 0 deletions HTWebRemote/Forms/DeviceIPManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private void lbDevices_SelectedIndexChanged(object sender, EventArgs e)
tbSpecial.Visible = false;
tbSpecial.Enabled = true;
cbLGssl.Visible = false;
cbTCPUDPRecvWelcome.Visible = false;
btnHueAuth.Visible = false;

try
Expand Down Expand Up @@ -101,9 +102,21 @@ private void lbDevices_SelectedIndexChanged(object sender, EventArgs e)
break;
case "tcp":
lblIP.Text = "IP:port";
cbTCPUDPRecvWelcome.Visible = true;
try
{
cbTCPUDPRecvWelcome.Checked = Convert.ToBoolean(values[3]);
}
catch { }
break;
case "udp":
lblIP.Text = "IP:port";
cbTCPUDPRecvWelcome.Visible = true;
try
{
cbTCPUDPRecvWelcome.Checked = Convert.ToBoolean(values[3]);
}
catch { }
break;
case "jvc":
lblSpecial.Text = "Password (NZ):";
Expand Down Expand Up @@ -175,6 +188,7 @@ private void cmbDeviceType_SelectedIndexChanged(object sender, EventArgs e)
tbSpecial.Enabled = true;
lbDevices.ClearSelected();
cbLGssl.Visible = false;
cbTCPUDPRecvWelcome.Visible = false;
btnHueAuth.Visible = false;

if (cmbDeviceType.SelectedItem != null)
Expand Down Expand Up @@ -223,9 +237,11 @@ private void cmbDeviceType_SelectedIndexChanged(object sender, EventArgs e)
break;
case "tcp":
lblIP.Text = "IP:port";
cbTCPUDPRecvWelcome.Visible = true;
break;
case "udp":
lblIP.Text = "IP:port";
cbTCPUDPRecvWelcome.Visible = true;
break;
case "jvc":
lblSpecial.Text = "Password (NZ):";
Expand Down Expand Up @@ -338,6 +354,10 @@ private void btnAdd_Click(object sender, EventArgs e)
{
dev += $",{cbLGssl.Checked}";
}
if (cbTCPUDPRecvWelcome.Visible)
{
dev += $",{cbTCPUDPRecvWelcome.Checked}";
}
lbDevices.Items.Add(dev);
}
else
Expand Down Expand Up @@ -380,6 +400,10 @@ private void btnSave_Click(object sender, EventArgs e)
{
dev += $",{cbLGssl.Checked}";
}
if (cbTCPUDPRecvWelcome.Visible)
{
dev += $",{cbTCPUDPRecvWelcome.Checked}";
}
lbDevices.Items[lbDevices.SelectedIndex] = dev;
}
else
Expand Down
56 changes: 40 additions & 16 deletions HTWebRemote/Forms/EditFileBrowser.Designer.cs

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

27 changes: 27 additions & 0 deletions HTWebRemote/Forms/EditFileBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public EditFileBrowser()
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

FillRemoteNumDropDown();
FillGroupDropDown();
LoadPaths();
LoadSettings();
}
Expand Down Expand Up @@ -55,6 +56,7 @@ private void LoadSettings()
}

cmbFileBrowserRemote.SelectedItem = ConfigHelper.GetRegKey(@"SOFTWARE\HTWebRemote", "FileBrowserRemote");
cmbFileBrowserGroup.SelectedItem = ConfigHelper.GetRegKey(@"SOFTWARE\HTWebRemote", "FileBrowserGroup");

string FBMediaPlayerPath = ConfigHelper.GetRegKey(@"SOFTWARE\HTWebRemote", "FileBrowserMediaPlayer");
if (!string.IsNullOrEmpty(FBMediaPlayerPath))
Expand Down Expand Up @@ -97,6 +99,30 @@ private void FillRemoteNumDropDown()
}
}

private void FillGroupDropDown()
{
cmbFileBrowserGroup.Items.Clear();

string[] remoteFiles = Directory.GetFiles(ConfigHelper.WorkingPath, "HTWebRemoteButtons*").CustomSort().ToArray();
List<string> groups = new List<string>();

foreach (string file in remoteFiles)
{
if (file.Contains(".json"))
{
JObject oRemote = JObject.Parse(File.ReadAllText(file));
string remoteGroup = (string)oRemote.SelectToken("RemoteGroup");

if (!string.IsNullOrEmpty(remoteGroup) && !groups.Contains(remoteGroup))
{
groups.Add(remoteGroup);
}
}
}

cmbFileBrowserGroup.DataSource = groups;
}

private void BtnAdd_Click(object sender, EventArgs e)
{
FolderBrowserDialog selectPath = new FolderBrowserDialog();
Expand Down Expand Up @@ -246,6 +272,7 @@ private void EditFileBrowser_FormClosing(object sender, FormClosingEventArgs e)
RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\HTWebRemote", true);
key.SetValue("YoutubeAPIKey", tbYoutubeAPIKey.Text);
key.SetValue("ItemRowHeight", tbItemRowHeight.Text);
key.SetValue("FileBrowserGroup", cmbFileBrowserGroup.SelectedItem);
}

private void lblAPIHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
Expand Down
Loading

0 comments on commit c3e2fd8

Please sign in to comment.