Exemplo n.º 1
0
        private void ExternalChannels_Load(object sender, EventArgs e)
        {
            ArrayList cards = new ArrayList();

            TVDatabase.GetCards(ref cards);

            if (cards.Count == 0)
            {
                cards.Add(0);
            }

            _tvCardTabs      = new TabPage[cards.Count];
            _tvCardStbSetups = new StbSetup[cards.Count];

            comboBoxCopyFrom.Items.Clear();

            int index = 0;

            foreach (int cardId in cards)
            {
                string cardName = String.Format("TV Card {0}", cardId);

                comboBoxCopyFrom.Items.Add(cardName);

                _tvCardStbSetups[index]      = new StbSetup(cardId);
                _tvCardStbSetups[index].Name = "StbSetup" + index;
                _tvCardStbSetups[index].Dock = DockStyle.Fill;

                _tvCardTabs[index] = new TabPage(cardName);
                _tvCardTabs[index].Controls.Add(_tvCardStbSetups[index]);

                tabControlTVCards.TabPages.Add(_tvCardTabs[index]);

                index++;
            }

            comboBoxCopyFrom.SelectedIndex = 0;

            // Setup quick setup combo box
            string[] quickSetupFiles = Directory.GetFiles(Common.FolderSTB, "*.xml", SearchOption.TopDirectoryOnly);
            foreach (string file in quickSetupFiles)
            {
                comboBoxQuickSetup.Items.Add(Path.GetFileNameWithoutExtension(file));
            }

            comboBoxQuickSetup.Items.Add("Clear all");
        }
    private void ExternalChannels_Load(object sender, EventArgs e)
    {
      ArrayList cards = new ArrayList();
      TVDatabase.GetCards(ref cards);

      if (cards.Count == 0)
        cards.Add(0);

      _tvCardTabs = new TabPage[cards.Count];
      _tvCardStbSetups = new StbSetup[cards.Count];

      comboBoxCopyFrom.Items.Clear();

      int index = 0;
      foreach (int cardId in cards)
      {
        string cardName = String.Format("TV Card {0}", cardId);

        comboBoxCopyFrom.Items.Add(cardName);

        _tvCardStbSetups[index] = new StbSetup(cardId);
        _tvCardStbSetups[index].Name = "StbSetup" + index;
        _tvCardStbSetups[index].Dock = DockStyle.Fill;

        _tvCardTabs[index] = new TabPage(cardName);
        _tvCardTabs[index].Controls.Add(_tvCardStbSetups[index]);

        tabControlTVCards.TabPages.Add(_tvCardTabs[index]);

        index++;
      }

      comboBoxCopyFrom.SelectedIndex = 0;

      // Setup quick setup combo box
      string[] quickSetupFiles = Directory.GetFiles(Common.FolderSTB, "*.xml", SearchOption.TopDirectoryOnly);
      foreach (string file in quickSetupFiles)
        comboBoxQuickSetup.Items.Add(Path.GetFileNameWithoutExtension(file));

      comboBoxQuickSetup.Items.Add("Clear all");
    }
Exemplo n.º 3
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);
            }
        }