Exemplo n.º 1
0
        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.UITextMouse);
            comboBoxCommands.Items.Add(Common.UITextEject);
            comboBoxCommands.Items.Add(Common.UITextPopup);
            comboBoxCommands.Items.Add(Common.UITextGotoScreen);
            //comboBoxCommands.Items.Add(Common.UITextWindowState);
            comboBoxCommands.Items.Add(Common.UITextFocus);
            comboBoxCommands.Items.Add(Common.UITextExit);
            comboBoxCommands.Items.Add(Common.UITextSendMPAction);
            comboBoxCommands.Items.Add(Common.UITextSendMPMsg);
            comboBoxCommands.Items.Add(Common.UITextStandby);
            comboBoxCommands.Items.Add(Common.UITextHibernate);
            comboBoxCommands.Items.Add(Common.UITextReboot);
            comboBoxCommands.Items.Add(Common.UITextShutdown);

            string[] fileList = TV2BlasterPlugin.GetFileList(true);
            if (fileList != null && fileList.Length > 0)
            {
                comboBoxCommands.Items.AddRange(fileList);
            }
        }
Exemplo n.º 2
0
        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
            {
                string fileName = Path.Combine(TV2BlasterPlugin.FolderMacros, name + Common.FileExtensionMacro);
                WriteToFile(fileName);

                TV2BlasterPlugin.ProcessCommand(Common.CmdPrefixMacro + name, false);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public void SetToConfig(int cardId)
        {
            ExternalChannelConfig config = TV2BlasterPlugin.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;
            }
        }
Exemplo n.º 4
0
        private void RefreshMacroList()
        {
            listViewMacro.Items.Clear();

            string[] macroList = TV2BlasterPlugin.GetMacroList(false);
            if (macroList != null && macroList.Length > 0)
            {
                foreach (string macroFile in macroList)
                {
                    listViewMacro.Items.Add(macroFile);
                }
            }
        }
Exemplo n.º 5
0
        private void buttonChangeServer_Click(object sender, EventArgs e)
        {
            TV2BlasterPlugin.StopClient();

            ServerAddress serverAddress = new ServerAddress(TV2BlasterPlugin.ServerHost);

            serverAddress.ShowDialog(this);

            TV2BlasterPlugin.ServerHost = serverAddress.ServerHost;

            IPAddress  serverIP = Client.GetIPFromName(TV2BlasterPlugin.ServerHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            TV2BlasterPlugin.StartClient(endPoint);
        }
Exemplo n.º 6
0
        public StbSetup(int cardId)
        {
            InitializeComponent();

            _cardId = cardId;

            // 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);
            comboBoxCommands.Items.Add(Common.UITextKeys);
            comboBoxCommands.Items.Add(Common.UITextPopup);

            string[] fileList = TV2BlasterPlugin.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);
        }
Exemplo n.º 7
0
        private void buttonTestMacro_Click(object sender, EventArgs e)
        {
            if (listViewMacro.SelectedItems.Count != 1)
            {
                return;
            }

            try
            {
                TV2BlasterPlugin.ProcessCommand(Common.CmdPrefixMacro + listViewMacro.SelectedItems[0].Text, false);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (StbSetup setup in _tvCardStbSetups)
                {
                    setup.Save();
                    TV2BlasterPlugin.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();
        }
Exemplo n.º 9
0
        public void SetToCard(int cardId)
        {
            ExternalChannelConfig config = TV2BlasterPlugin.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);
        }
Exemplo n.º 10
0
        private void SetupForm_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(TV2BlasterPlugin.ServerHost))
            {
                ServerAddress serverAddress = new ServerAddress();
                serverAddress.ShowDialog(this);

                TV2BlasterPlugin.ServerHost = serverAddress.ServerHost;
            }

            IPAddress  serverIP = Client.GetIPFromName(TV2BlasterPlugin.ServerHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            if (!TV2BlasterPlugin.StartClient(endPoint))
            {
                MessageBox.Show(this, "Failed to start local comms. IR functions temporarily disabled.",
                                "TV2 Blaster Plugin - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshIRList();
            RefreshMacroList();

            TV2BlasterPlugin.HandleMessage += ReceivedMessage;
        }
Exemplo n.º 11
0
        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))
                    {
                        TV2BlasterPlugin.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))
                        {
                            TV2BlasterPlugin.ProcessExternalCommand(command, charVal, channel);

                            if (setup.PauseTime > 0)
                            {
                                Thread.Sleep(setup.PauseTime);
                            }
                        }
                    }

                    if (setup.SendSelect && !String.IsNullOrEmpty(setup.SelectCommand))
                    {
                        TV2BlasterPlugin.ProcessExternalCommand(setup.SelectCommand, -1, channel);

                        if (setup.DoubleChannelSelect)
                        {
                            if (setup.PauseTime > 0)
                            {
                                Thread.Sleep(setup.PauseTime);
                            }

                            TV2BlasterPlugin.ProcessExternalCommand(setup.SelectCommand, -1, channel);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Failed to test external channel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }