private void SetTxEventLearnedStatus(LearningEventArgs e)
    {
      // Make sure we're calling this method from the correct thread...
      if (receivedIrLbl.InvokeRequired)
      {
        SetLearningStatusCallback d = new SetLearningStatusCallback(SetTxEventLearnedStatus);
        this.Invoke(d, new object[] {e});
      }

      else
      {
        receivedIrLbl.Text = e.IrCode;

        if (e.IsToggledIrCode)
          this.LearnPrgBar.Value = e.CurrentCodeCount;

        System.Windows.Forms.Application.DoEvents();

        string msg;
        MessageBoxIcon mbIcon = MessageBoxIcon.Information;

        if (e.Succeeded)
        {
          int passNumber = 1;

          if (e.IsToggledIrCode)
            passNumber = 2;

          msg = string.Format("Successfully learned IR code {0} of 2 for button:\t\r\n  [{1}]", passNumber, e.Button);
        }

        else
        {
          msg = string.Format("Failed to learn IR code for button:\t\r\n  [{0}]", e.Button);
          mbIcon = MessageBoxIcon.Exclamation;
        }

        MessageBox.Show(this, msg, "USBUIRT", MessageBoxButtons.OK, mbIcon);
        this.statusLabel.Text = "";
      }
    }
    private void SetStartTxLearningStatus(LearningEventArgs e)
    {
      // Make sure we're calling this method from the correct thread...
      if (receivedIrLbl.InvokeRequired)
      {
        SetLearningStatusCallback d = new SetLearningStatusCallback(SetStartTxLearningStatus);
        this.Invoke(d, new object[] {e});
      }

      else
      {
        receivedIrLbl.Text = e.IrCode;
        LearnStatusLbl.Text = string.Format("Learning Set-top Box Codes: {0} of {1}", e.CurrentCodeCount + 1,
                                            e.TotalCodeCount);

        LearnPrgBar.Maximum = e.TotalCodeCount;
        LearnStatusPnl.BringToFront();

        if (!e.IsToggledIrCode)
        {
          statusLabel.ForeColor = Color.DarkBlue;
          statusLabel.Text = "Step 1 of 2:\r\nPress and hold the [" + e.Button + "] button on your Set-top box remote";
        }

        else
        {
          statusLabel.ForeColor = Color.Red;
          statusLabel.Text = "Step 2 of 2:\r\nPress and hold the [" + e.Button + "] button on your Set-top box remote";
        }

        System.Windows.Forms.Application.DoEvents();
      }
    }
 private void Instance_OnRxEventLearned(object sender, LearningEventArgs e)
 {
   SetRxEventLearnedStatus(e);
 }
    private void SetRxEventLearnedStatus(LearningEventArgs e)
    {
      // Make sure we're calling this method from the correct thread...
      if (receivedIrLbl.InvokeRequired)
      {
        SetLearningStatusCallback d = new SetLearningStatusCallback(SetRxEventLearnedStatus);
        this.Invoke(d, new object[] {e});
      }

      else
      {
        receivedIrLbl.Text = e.IrCode;
        string msg;
        MessageBoxIcon mbIcon = MessageBoxIcon.Information;

        if (e.Succeeded)
        {
          int passNumber = 1;

          if (e.IsToggledIrCode)
            passNumber = 2;

          msg = string.Format("Successfully learned IR code {0} of 2 for button:\t\r\n  [{1}]", passNumber, e.Button);
        }

        else
        {
          msg = string.Format("Failed to learn IR code for button:\t\r\n  [{0}]", e.Button);
        }

        MediaPortal.IR.USBUIRT.Instance.ReceiveEnabled = false;
        MessageBox.Show(this, msg, "USBUIRT", MessageBoxButtons.OK, mbIcon);
        MediaPortal.IR.USBUIRT.Instance.ReceiveEnabled = true;

        this.statusLabel.Text = "";
      }
    }
 private void Instance_StartRxLearning(object sender, LearningEventArgs e)
 {
   SetStartRxLearningStatus(e);
 }