예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Configure"/> class.
        /// </summary>
        public Configure()
        {
            InitializeComponent();
            this.Icon = Properties.Resources.Icon;

            // Put this in a try...catch so that if the registry keys don't exist we don't throw an ugly exception.
            try
            {
                checkBoxDisableAutomaticButtons.Checked = !MicrosoftMceTransceiver.CheckAutomaticButtons();
            }
            catch
            {
                checkBoxDisableAutomaticButtons.Enabled = false;
            }
        }
예제 #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (checkBoxDisableAutomaticButtons.Enabled)
            {
                try
                {
                    bool changeMade = false;

                    bool keysExist = MicrosoftMceTransceiver.CheckAutomaticButtons();

                    if (checkBoxDisableAutomaticButtons.Checked && keysExist)
                    {
                        MicrosoftMceTransceiver.DisableAutomaticButtons();
                        changeMade = true;
                    }
                    else if (!checkBoxDisableAutomaticButtons.Checked && !keysExist)
                    {
                        MicrosoftMceTransceiver.EnableAutomaticButtons();
                        changeMade = true;
                    }

                    if (changeMade)
                    {
                        MessageBox.Show(this,
                                        "You must restart the computer for changes to automatic button handling to take effect",
                                        "Restart required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.ToString(), "Error modifiying the system registry", MessageBoxButtons.OK);
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #3
0
    static void Main()
    {
      Console.WriteLine("Microsoft MCE Transceiver Test App");
      Console.WriteLine("====================================");
      Console.WriteLine();

      SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);

      try
      {
        device = new MicrosoftMceTransceiver();

        //Keyboard.LoadLayout(Keyboard.German_DE);

        Console.Write("Configure device? (y/n) ");

        if (Console.ReadKey().Key == ConsoleKey.Y)
        {
          Console.WriteLine();

          Console.WriteLine("Configuring ...");
          device.Configure(null);
        }
        else
        {
          Console.WriteLine();
        }

        device.RemoteCallback += new RemoteHandler(xRemote);
        device.KeyboardCallback += new KeyboardHandler(xKeyboard);
        device.MouseCallback += new MouseHandler(xMouse);

        Console.WriteLine("Starting device access ...");

        device.Start();

        Console.Write("Learn IR? (y/n) ");

        while (Console.ReadKey().Key == ConsoleKey.Y)
        {
          Console.WriteLine();
          Console.WriteLine("Learning IR Command ...");

          byte[] data;

          switch (device.Learn(out data))
          {
            case LearnStatus.Failure:
              Console.WriteLine("Learn process failed!");
              break;

            case LearnStatus.Success:
              Console.WriteLine("Learn successful");

              Console.Write("Blast IR back? (y/n) ");

              if (Console.ReadKey().Key == ConsoleKey.Y)
              {
                Console.WriteLine();
                Console.WriteLine("Blasting ...");

                if (device.Transmit("Both", data))
                {
                  Console.WriteLine("Blasting successful");
                }
                else
                {
                  Console.WriteLine("Blasting failure!");
                }
              }
              else
              {
                Console.WriteLine();
              }
              break;

            case LearnStatus.Timeout:
              Console.WriteLine("Learn process timed-out");
              break;
          }

          Console.Write("Learn another IR? (y/n) ");
        }
        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine("Press a button on your remote ...");

        Application.Run();

        device.Stop();
      }
      catch (Exception ex)
      {
        Console.WriteLine("Error:");
        Console.WriteLine(ex.ToString());
        Console.WriteLine();
        Console.WriteLine("");

        Console.ReadKey();
      }
      finally
      {
        device = null;
      }

      SystemEvents.PowerModeChanged -= new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
    }
예제 #4
0
        static void Main()
        {
            Console.WriteLine("Microsoft MCE Transceiver Test App");
            Console.WriteLine("====================================");
            Console.WriteLine();

            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);

            try
            {
                device = new MicrosoftMceTransceiver();

                //Keyboard.LoadLayout(Keyboard.German_DE);

                Console.Write("Configure device? (y/n) ");

                if (Console.ReadKey().Key == ConsoleKey.Y)
                {
                    Console.WriteLine();

                    Console.WriteLine("Configuring ...");
                    device.Configure(null);
                }
                else
                {
                    Console.WriteLine();
                }

                device.RemoteCallback   += new RemoteHandler(xRemote);
                device.KeyboardCallback += new KeyboardHandler(xKeyboard);
                device.MouseCallback    += new MouseHandler(xMouse);

                Console.WriteLine("Starting device access ...");

                device.Start();

                Console.Write("Learn IR? (y/n) ");

                while (Console.ReadKey().Key == ConsoleKey.Y)
                {
                    Console.WriteLine();
                    Console.WriteLine("Learning IR Command ...");

                    byte[] data;

                    switch (device.Learn(out data))
                    {
                    case LearnStatus.Failure:
                        Console.WriteLine("Learn process failed!");
                        break;

                    case LearnStatus.Success:
                        Console.WriteLine("Learn successful");

                        Console.Write("Blast IR back? (y/n) ");

                        if (Console.ReadKey().Key == ConsoleKey.Y)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Blasting ...");

                            if (device.Transmit("Both", data))
                            {
                                Console.WriteLine("Blasting successful");
                            }
                            else
                            {
                                Console.WriteLine("Blasting failure!");
                            }
                        }
                        else
                        {
                            Console.WriteLine();
                        }
                        break;

                    case LearnStatus.Timeout:
                        Console.WriteLine("Learn process timed-out");
                        break;
                    }

                    Console.Write("Learn another IR? (y/n) ");
                }
                Console.WriteLine();
                Console.WriteLine();

                Console.WriteLine("Press a button on your remote ...");

                Application.Run();

                device.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:");
                Console.WriteLine(ex.ToString());
                Console.WriteLine();
                Console.WriteLine("");

                Console.ReadKey();
            }
            finally
            {
                device = null;
            }

            SystemEvents.PowerModeChanged -= new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
        }