private void buttonDeleteMacro_Click(object sender, EventArgs e) { if (listViewMacro.SelectedItems.Count != 1) { return; } string file = listViewMacro.SelectedItems[0].Text; string fileName = TV3BlasterPlugin.PathCombine(file); if (File.Exists(fileName)) { if ( MessageBox.Show(this, String.Format("Are you sure you want to delete \"{0}\"?", file), "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { File.Delete(fileName); } } else { MessageBox.Show(this, "File not found: " + fileName, "Macro file missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } RefreshMacroList(); }
public override void OnSectionActivated() { Log.Info("TV3BlasterPlugin: Configuration activated"); TV3BlasterPlugin.InConfiguration = true; TvBusinessLayer layer = new TvBusinessLayer(); TV3BlasterPlugin.ServerHost = layer.GetSetting("TV3BlasterPlugin_ServerHost", "localhost").Value; IPAddress serverIP = Network.GetIPFromName(TV3BlasterPlugin.ServerHost); IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort); if (!TV3BlasterPlugin.StartClient(endPoint)) { MessageBox.Show(this, "Failed to start local comms. IR functions temporarily disabled.", "TV3 Blaster Plugin - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } TV3BlasterPlugin.LoadExternalConfigs(); RefreshIRList(); RefreshMacroList(); TV3BlasterPlugin.HandleMessage += ReceivedMessage; base.OnSectionActivated(); }
private void EditMacro() { if (listViewMacro.SelectedItems.Count != 1) { return; } try { string command = listViewMacro.SelectedItems[0].Text; string fileName = TV3BlasterPlugin.PathCombine(command); if (File.Exists(fileName)) { MacroEditor macroEditor = new MacroEditor(command); macroEditor.ShowDialog(this); } else { RefreshMacroList(); throw new FileNotFoundException("Macro file missing", fileName); } } catch (Exception ex) { Log.Error(ex.ToString()); MessageBox.Show(this, ex.Message, "Failed to edit macro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonOK_Click(object sender, EventArgs e) { string name = textBoxName.Text.Trim(); if (name.Length == 0) { MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxName.Focus(); return; } if (!Common.IsValidFileName(name)) { MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxName.Focus(); return; } try { WriteToFile(TV3BlasterPlugin.PathCombine(name)); } catch (Exception ex) { Log.Error(ex.ToString()); MessageBox.Show(this, ex.Message, "Failed writing macro to file", MessageBoxButtons.OK, MessageBoxIcon.Error); } DialogResult = DialogResult.OK; Close(); }
private void buttonTest_Click(object sender, EventArgs e) { string name = textBoxName.Text.Trim(); if (name.Length == 0) { MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxName.Focus(); return; } if (!Common.IsValidFileName(name)) { MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBoxName.Focus(); return; } try { WriteToFile(TV3BlasterPlugin.PathCombine(name)); TV3BlasterPlugin.ProcessCommand(Common.CmdPrefixMacro + name, false); } catch (Exception ex) { Log.Error(ex.ToString()); MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void SetToConfig(int cardId) { ExternalChannelConfig config = TV3BlasterPlugin.GetExternalChannelConfig(cardId); config.CardId = cardId; config.PauseTime = Decimal.ToInt32(numericUpDownPauseTime.Value); config.SendSelect = checkBoxSendSelect.Checked; config.DoubleChannelSelect = checkBoxDoubleSelect.Checked; config.RepeatChannelCommands = Decimal.ToInt32(numericUpDownRepeat.Value); int chDigits = comboBoxChDigits.SelectedIndex; if (chDigits > 0) { chDigits++; } config.ChannelDigits = chDigits; config.RepeatPauseTime = Decimal.ToInt32(numericUpDownRepeatDelay.Value); config.UsePreChangeCommand = checkBoxUsePreChange.Checked; config.SelectCommand = listViewExternalCommands.Items[10].SubItems[1].Text; config.PreChangeCommand = listViewExternalCommands.Items[11].SubItems[1].Text; for (int i = 0; i < 10; i++) { config.Digits[i] = listViewExternalCommands.Items[i].SubItems[1].Text; } }
public StbSetup(int cardId) { InitializeComponent(); _cardId = cardId; foreach (Card card in Card.ListAll()) { if (card.IdCard == _cardId) { labelCardName.Text = card.Name; if (!card.Enabled) { labelCardName.Text += " (Disabled)"; } break; } } // Setup commands combo box comboBoxCommands.Items.Add(Common.UITextRun); comboBoxCommands.Items.Add(Common.UITextSerial); comboBoxCommands.Items.Add(Common.UITextWindowMsg); comboBoxCommands.Items.Add(Common.UITextTcpMsg); comboBoxCommands.Items.Add(Common.UITextHttpMsg); string[] fileList = TV3BlasterPlugin.GetFileList(true); if (fileList != null) { comboBoxCommands.Items.AddRange(fileList); } comboBoxCommands.SelectedIndex = 0; // Setup command list ListViewItem item; string[] subItems = new string[2]; for (int i = 0; i < 10; i++) { subItems[0] = "Digit " + i; subItems[1] = String.Empty; item = new ListViewItem(subItems); listViewExternalCommands.Items.Add(item); } subItems[0] = "Select"; subItems[1] = String.Empty; item = new ListViewItem(subItems); listViewExternalCommands.Items.Add(item); subItems[0] = "PreChange"; subItems[1] = String.Empty; item = new ListViewItem(subItems); listViewExternalCommands.Items.Add(item); SetToCard(_cardId); }
private void RefreshMacroList() { listViewMacro.Items.Clear(); string[] macroList = TV3BlasterPlugin.GetMacroList(false); if (macroList != null && macroList.Length > 0) { foreach (string macroFile in macroList) { listViewMacro.Items.Add(macroFile); } } }
private void listViewMacro_AfterLabelEdit(object sender, LabelEditEventArgs e) { ListView origin = sender as ListView; if (origin == null) { e.CancelEdit = true; return; } if (String.IsNullOrEmpty(e.Label)) { e.CancelEdit = true; return; } ListViewItem originItem = origin.Items[e.Item]; string oldFileName = TV3BlasterPlugin.PathCombine(originItem.Text); if (!File.Exists(oldFileName)) { MessageBox.Show("File not found: " + oldFileName, "Cannot rename, Original file not found", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } string name = e.Label.Trim(); if (!Common.IsValidFileName(name)) { MessageBox.Show("File name not valid: " + name, "Cannot rename, New file name not valid", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } try { string newFileName = TV3BlasterPlugin.PathCombine(name); File.Move(oldFileName, newFileName); } catch (Exception ex) { IrssLog.Error(ex); MessageBox.Show(ex.Message, "Failed to rename file", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonHostSetup_Click(object sender, EventArgs e) { TV3BlasterPlugin.StopClient(); ServerAddress serverAddress = new ServerAddress(TV3BlasterPlugin.ServerHost); serverAddress.ShowDialog(this); TV3BlasterPlugin.ServerHost = serverAddress.ServerHost; IPAddress serverIP = Network.GetIPFromName(TV3BlasterPlugin.ServerHost); IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort); TV3BlasterPlugin.StartClient(endPoint); }
/// <summary> /// Creates a Macro Editor windows form. /// </summary> /// <param name="name">The name of an existing macro.</param> public MacroEditor(string name) : this() { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } textBoxName.Text = name; textBoxName.Enabled = false; string fileName = TV3BlasterPlugin. PathCombine(name); ReadFromFile(fileName); }
private void buttonTestMacro_Click(object sender, EventArgs e) { if (listViewMacro.SelectedItems.Count != 1) { return; } try { TV3BlasterPlugin.ProcessCommand(Common.CmdPrefixMacro + listViewMacro.SelectedItems[0].Text, false); } catch (Exception ex) { Log.Error(ex.ToString()); MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonOK_Click(object sender, EventArgs e) { try { foreach (StbSetup setup in _tvCardStbSetups) { setup.Save(); TV3BlasterPlugin.GetExternalChannelConfig(setup.CardId).Save(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Failed to save external channel setup", MessageBoxButtons.OK, MessageBoxIcon.Error); } DialogResult = DialogResult.OK; Close(); }
public override void OnSectionDeActivated() { Log.Info("TV3BlasterPlugin: Configuration deactivated"); TV3BlasterPlugin.HandleMessage -= ReceivedMessage; TvBusinessLayer layer = new TvBusinessLayer(); Setting setting = layer.GetSetting("TV3BlasterPlugin_ServerHost"); setting.Value = TV3BlasterPlugin.ServerHost; setting.Persist(); //TV3BlasterPlugin.LoadExternalConfigs(); TV3BlasterPlugin.StopClient(); TV3BlasterPlugin.InConfiguration = false; base.OnSectionDeActivated(); }
public void SetToCard(int cardId) { ExternalChannelConfig config = TV3BlasterPlugin.GetExternalChannelConfig(cardId); if (config == null) { MessageBox.Show(this, "You must save your card configurations before copying between card setups", "No saved configration to copy from", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Setup command list. for (int i = 0; i < 10; i++) { listViewExternalCommands.Items[i].SubItems[1].Text = config.Digits[i]; } listViewExternalCommands.Items[10].SubItems[1].Text = config.SelectCommand; listViewExternalCommands.Items[11].SubItems[1].Text = config.PreChangeCommand; // Setup options. numericUpDownPauseTime.Value = config.PauseTime; checkBoxSendSelect.Checked = config.SendSelect; checkBoxDoubleSelect.Checked = config.DoubleChannelSelect; numericUpDownRepeat.Value = config.RepeatChannelCommands; checkBoxDoubleSelect.Enabled = checkBoxSendSelect.Checked; int channelDigitsSelect = config.ChannelDigits; if (channelDigitsSelect > 0) { channelDigitsSelect--; } comboBoxChDigits.SelectedIndex = channelDigitsSelect; checkBoxUsePreChange.Checked = config.UsePreChangeCommand; numericUpDownRepeatDelay.Value = new Decimal(config.RepeatPauseTime); }
private void RefreshCommandList() { comboBoxCommands.Items.Clear(); comboBoxCommands.Items.Add(Common.UITextRun); comboBoxCommands.Items.Add(Common.UITextPause); comboBoxCommands.Items.Add(Common.UITextSerial); comboBoxCommands.Items.Add(Common.UITextWindowMsg); comboBoxCommands.Items.Add(Common.UITextTcpMsg); comboBoxCommands.Items.Add(Common.UITextHttpMsg); comboBoxCommands.Items.Add(Common.UITextKeys); comboBoxCommands.Items.Add(Common.UITextEject); comboBoxCommands.Items.Add(Common.UITextStandby); comboBoxCommands.Items.Add(Common.UITextHibernate); comboBoxCommands.Items.Add(Common.UITextReboot); comboBoxCommands.Items.Add(Common.UITextShutdown); string[] fileList = TV3BlasterPlugin.GetFileList(true); if (fileList != null && fileList.Length > 0) { comboBoxCommands.Items.AddRange(fileList); } }
private void buttonTest_Click(object sender, EventArgs e) { try { StbSetup setup = _tvCardStbSetups[tabControlTVCards.SelectedIndex]; int channelTest = Decimal.ToInt32(numericUpDownTest.Value); string channel; switch (setup.ChannelDigits) { case 2: channel = channelTest.ToString("00"); break; case 3: channel = channelTest.ToString("000"); break; case 4: channel = channelTest.ToString("0000"); break; default: channel = channelTest.ToString(); break; } int charVal; string command; for (int repeatCount = 0; repeatCount <= setup.RepeatChannelCommands; repeatCount++) { if (repeatCount > 0 && setup.RepeatPauseTime > 0) { Thread.Sleep(setup.RepeatPauseTime); } if (setup.UsePreChangeCommand && !String.IsNullOrEmpty(setup.PreChangeCommand)) { TV3BlasterPlugin.ProcessExternalCommand(setup.PreChangeCommand, -1, channel); if (setup.PauseTime > 0) { Thread.Sleep(setup.PauseTime); } } foreach (char digit in channel) { charVal = digit - 48; command = setup.Digits[charVal]; if (!String.IsNullOrEmpty(command)) { TV3BlasterPlugin.ProcessExternalCommand(command, charVal, channel); if (setup.PauseTime > 0) { Thread.Sleep(setup.PauseTime); } } } if (setup.SendSelect && !String.IsNullOrEmpty(setup.SelectCommand)) { TV3BlasterPlugin.ProcessExternalCommand(setup.SelectCommand, -1, channel); if (setup.DoubleChannelSelect) { if (setup.PauseTime > 0) { Thread.Sleep(setup.PauseTime); } TV3BlasterPlugin.ProcessExternalCommand(setup.SelectCommand, -1, channel); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Failed to test external channel", MessageBoxButtons.OK, MessageBoxIcon.Error); } }