示例#1
0
        private async Task Save()
        {
            this.button.Title   = this.textBoxName.Text;
            this.button.Command = this.textBoxCommand.GetNumber();
            this.button.X       = this.textBoxX.GetNumber();
            this.button.Y       = this.textBoxY.GetNumber();
            this.button.Width   = this.textBoxWidth.GetNumber();
            this.button.Height  = this.textBoxHeight.GetNumber();

            int address = this.textBoxAddress.GetNumber();

            if (address == this.remote.Address)
            {
                this.button.Address = null;
            }
            else
            {
                this.button.Address = address;
            }

            IrProtocol protocol = (IrProtocol)this.comboBoxProtocol.SelectedIndex;

            if (protocol == this.remote.Type)
            {
                this.button.Type = null;
            }
            else
            {
                this.button.Type = protocol;
            }

            await this.remote.Save();
        }
示例#2
0
 public Remote()
 {
     this.Id      = Guid.NewGuid().ToString();
     this.Address = 0;
     this.Buttons = new List <RemoteButton>();
     this.Name    = "";
     this.Type    = IrProtocol.SIRC;
 }
        private void RemoteEvent(IrProtocol codeType, uint keyCode, bool firstPress)
        {
#if TRACE
            Trace.WriteLine(String.Format("Remote: {0}, {1}, {2}", Enum.GetName(typeof(IrProtocol), codeType), keyCode, firstPress));
#endif

            if (!firstPress && _lastRemoteButtonCodeType == codeType && _lastRemoteButtonKeyCode == keyCode)
            {
                TimeSpan timeBetween = DateTime.Now.Subtract(_lastRemoteButtonTime);

                if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < _remoteFirstRepeat)
                {
#if TRACE
                    Trace.WriteLine("Skip, First Repeat");
#endif
                    return;
                }

                if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < _remoteHeldRepeats)
                {
#if TRACE
                    Trace.WriteLine("Skip, Held Repeat");
#endif
                    return;
                }

                if (_remoteButtonRepeated && timeBetween.TotalMilliseconds > _remoteFirstRepeat)
                {
                    _remoteButtonRepeated = false;
                }
                else
                {
                    _remoteButtonRepeated = true;
                }
            }
            else
            {
                _lastRemoteButtonCodeType = codeType;
                _lastRemoteButtonKeyCode  = keyCode;
                _remoteButtonRepeated     = false;
            }

            _lastRemoteButtonTime = DateTime.Now;

            if (_remoteHandler != null)
            {
                _remoteHandler(Name, keyCode.ToString());
            }
        }
示例#4
0
        public static void ShowPage(this WebView web, IrProtocol protocol)
        {
            switch (protocol)
            {
            case IrProtocol.SIRC:
                web.Source = new Uri("https://www.google.com/search?q=sirc+remote+addresses");
                break;

            case IrProtocol.NEC:
                web.Source = new Uri("https://www.google.com/search?q=nec+remote+addresses");
                break;

            default:
                web.Source = new Uri("https://en.wikipedia.org/wiki/RC-5#System_Number_Allocations");
                break;
            }
        }
示例#5
0
文件: Data.cs 项目: jehy/32feet.NET
 public WellKnownIrdaSvc(String name, String serviceName, IrProtocol protocolType)
 {
     this.name         = name;
     this.serviceName  = serviceName;
     this.protocolType = protocolType;
 }//
示例#6
0
        private void RemoteEvent(IrProtocol codeType, uint keyCode, bool firstPress)
        {
#if TRACE
            Trace.WriteLine(String.Format("Remote: {0}, {1}, {2}", Enum.GetName(typeof(IrProtocol), codeType), keyCode, firstPress));
#endif

            if (!_config.EnableRemoteInput)
            {
                return;
            }

            if (_ignoreAutomaticButtons && codeType == IrProtocol.RC6_MCE)
            {
                // Always ignore these buttones ...
                if (
                    //keyCode == 0x7bdc ||  // Back (removed 12-April-2008)
                    keyCode == 0x7bdd || // OK
                    keyCode == 0x7bde || // Right
                    keyCode == 0x7bdf || // Left
                    keyCode == 0x7be0 || // Down
                    keyCode == 0x7be1 || // Up
                    keyCode == 0x7bee || // Volume_Down
                    keyCode == 0x7bef || // Volume_Up
                    keyCode == 0x7bf1 || // Mute
                    keyCode == 0x7bf3 || // PC_Power
                    keyCode == 0x7bf4 || // Enter
                    keyCode == 0x7bf6 || // Number_9
                    keyCode == 0x7bf7 || // Number_8
                    keyCode == 0x7bf8 || // Number_7
                    keyCode == 0x7bf9 || // Number_6
                    keyCode == 0x7bfa || // Number_5
                    keyCode == 0x7bfb || // Number_4
                    keyCode == 0x7bfc || // Number_3
                    keyCode == 0x7bfd || // Number_2
                    keyCode == 0x7bfe || // Number_1
                    keyCode == 0x7bff)   // Number_0
                {
#if TRACE
                    Trace.WriteLine("Ignoring remote button due to automatic handling");
#endif
                    return;
                }

                // Only ignore Start if the services aren't disabled ...
                if (keyCode == 0x7bf2 && !_config._disableMceServices)
                {
#if TRACE
                    Trace.WriteLine("Ignoring Start button due to automatic handling and the MCE services being active");
#endif
                    return;
                }
            }

            if (!firstPress && _lastRemoteButtonCodeType == codeType && _lastRemoteButtonKeyCode == keyCode)
            {
                TimeSpan timeBetween = DateTime.Now.Subtract(_lastRemoteButtonTime);

                int firstRepeat = _config.RemoteFirstRepeat;
                int heldRepeats = _config.RemoteHeldRepeats;
                if (_config.UseSystemRatesRemote)
                {
                    firstRepeat = 250 + (SystemInformation.KeyboardDelay * 250);
                    heldRepeats = (int)(1000.0 / (2.5 + (SystemInformation.KeyboardSpeed * 0.888)));
                }

                if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < firstRepeat)
                {
#if TRACE
                    Trace.WriteLine("Skip, First Repeat");
#endif
                    return;
                }

                if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < heldRepeats)
                {
#if TRACE
                    Trace.WriteLine("Skip, Held Repeat");
#endif
                    return;
                }

                if (_remoteButtonRepeated && timeBetween.TotalMilliseconds > firstRepeat)
                {
                    _remoteButtonRepeated = false;
                }
                else
                {
                    _remoteButtonRepeated = true;
                }
            }
            else
            {
                _lastRemoteButtonCodeType = codeType;
                _lastRemoteButtonKeyCode  = keyCode;
                _remoteButtonRepeated     = false;
            }

            _lastRemoteButtonTime = DateTime.Now;

            if (RemoteCallback != null)
            {
                RemoteCallback(Name, keyCode.ToString());
            }
        }
    private void RemoteEvent(IrProtocol codeType, uint keyCode, bool firstPress)
    {
#if TRACE
      Trace.WriteLine(String.Format("Remote: {0}, {1}, {2}", Enum.GetName(typeof(IrProtocol), codeType), keyCode, firstPress));
#endif

      if (!firstPress && _lastRemoteButtonCodeType == codeType && _lastRemoteButtonKeyCode == keyCode)
      {
        TimeSpan timeBetween = DateTime.Now.Subtract(_lastRemoteButtonTime);

        if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < _remoteFirstRepeat)
        {
#if TRACE
          Trace.WriteLine("Skip, First Repeat");
#endif
          return;
        }

        if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < _remoteHeldRepeats)
        {
#if TRACE
          Trace.WriteLine("Skip, Held Repeat");
#endif
          return;
        }

        if (_remoteButtonRepeated && timeBetween.TotalMilliseconds > _remoteFirstRepeat)
          _remoteButtonRepeated = false;
        else
          _remoteButtonRepeated = true;
      }
      else
      {
        _lastRemoteButtonCodeType = codeType;
        _lastRemoteButtonKeyCode = keyCode;
        _remoteButtonRepeated = false;
      }

      _lastRemoteButtonTime = DateTime.Now;

      if (_remoteHandler != null)
        _remoteHandler(Name, keyCode.ToString());
    }
    private void RemoteEvent(IrProtocol codeType, uint keyCode, bool firstPress)
    {
#if TRACE
      Trace.WriteLine(String.Format("Remote: {0}, {1}, {2}", Enum.GetName(typeof(IrProtocol), codeType), keyCode, firstPress));
#endif

      if (!_config.EnableRemoteInput)
        return;

      if (_ignoreAutomaticButtons && codeType == IrProtocol.RC6_MCE)
      {
        // Always ignore these buttones ...
        if (
          //keyCode == 0x7bdc ||  // Back (removed 12-April-2008)
          keyCode == 0x7bdd || // OK
          keyCode == 0x7bde || // Right
          keyCode == 0x7bdf || // Left
          keyCode == 0x7be0 || // Down
          keyCode == 0x7be1 || // Up
          keyCode == 0x7bee || // Volume_Down
          keyCode == 0x7bef || // Volume_Up
          keyCode == 0x7bf1 || // Mute
          keyCode == 0x7bf3 || // PC_Power
          keyCode == 0x7bf4 || // Enter
          keyCode == 0x7bf6 || // Number_9
          keyCode == 0x7bf7 || // Number_8
          keyCode == 0x7bf8 || // Number_7
          keyCode == 0x7bf9 || // Number_6
          keyCode == 0x7bfa || // Number_5
          keyCode == 0x7bfb || // Number_4
          keyCode == 0x7bfc || // Number_3
          keyCode == 0x7bfd || // Number_2
          keyCode == 0x7bfe || // Number_1
          keyCode == 0x7bff) // Number_0
        {
#if TRACE
          Trace.WriteLine("Ignoring remote button due to automatic handling");
#endif
          return;
        }

        // Only ignore Start if the services aren't disabled ...
        if (keyCode == 0x7bf2 && !_config._disableMceServices)
        {
#if TRACE
          Trace.WriteLine("Ignoring Start button due to automatic handling and the MCE services being active");
#endif
          return;
        }
      }

      if (!firstPress && _lastRemoteButtonCodeType == codeType && _lastRemoteButtonKeyCode == keyCode)
      {
        TimeSpan timeBetween = DateTime.Now.Subtract(_lastRemoteButtonTime);

        int firstRepeat = _config.RemoteFirstRepeat;
        int heldRepeats = _config.RemoteHeldRepeats;
        if (_config.UseSystemRatesRemote)
        {
          firstRepeat = 250 + (SystemInformation.KeyboardDelay * 250);
          heldRepeats = (int) (1000.0 / (2.5 + (SystemInformation.KeyboardSpeed * 0.888)));
        }

        if (!_remoteButtonRepeated && timeBetween.TotalMilliseconds < firstRepeat)
        {
#if TRACE
          Trace.WriteLine("Skip, First Repeat");
#endif
          return;
        }

        if (_remoteButtonRepeated && timeBetween.TotalMilliseconds < heldRepeats)
        {
#if TRACE
          Trace.WriteLine("Skip, Held Repeat");
#endif
          return;
        }

        if (_remoteButtonRepeated && timeBetween.TotalMilliseconds > firstRepeat)
          _remoteButtonRepeated = false;
        else
          _remoteButtonRepeated = true;
      }
      else
      {
        _lastRemoteButtonCodeType = codeType;
        _lastRemoteButtonKeyCode = keyCode;
        _remoteButtonRepeated = false;
      }

      _lastRemoteButtonTime = DateTime.Now;

      if (RemoteCallback != null)
        RemoteCallback(Name, keyCode.ToString());
    }
示例#9
0
        private void RemoteEvent(IrProtocol codeType, uint keyCode, bool firstPress)
        {
            MessageBox.Show(this,
                            String.Format("Protocol: {0}\nCode: {1}", Enum.GetName(typeof(IrProtocol), codeType), keyCode),
                            "Decode IR", MessageBoxButtons.OK, MessageBoxIcon.Information);

            int newCarrier;

            switch (codeType)
            {
            case IrProtocol.Daewoo:
                newCarrier = 38000;
                break;

            case IrProtocol.JVC:
                newCarrier = 38000;
                break;

            case IrProtocol.Matsushita:
                newCarrier = 56800;
                break;

            case IrProtocol.Mitsubishi:
                newCarrier = 40000;
                break;

            case IrProtocol.NEC:
                newCarrier = 38000;
                break;

            case IrProtocol.NRC17:
                newCarrier = 38000;
                break;

            case IrProtocol.Panasonic:
                newCarrier = 38000;
                break;

            case IrProtocol.RC5:
                newCarrier = 36000;
                break;

            case IrProtocol.RC5X:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6A:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6_MCE:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6_16:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6_20:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6_24:
                newCarrier = 36000;
                break;

            case IrProtocol.RC6_32:
                newCarrier = 36000;
                break;

            case IrProtocol.RCA:
                newCarrier = 56000;
                break;

            case IrProtocol.RCMM:
                newCarrier = 36000;
                break;

            case IrProtocol.RECS80:
                newCarrier = 38000;
                break;

            case IrProtocol.Sharp:
                newCarrier = 38000;
                break;

            case IrProtocol.SIRC:
                newCarrier = 40000;
                break;

            case IrProtocol.Toshiba:
                newCarrier = 38000;
                break;

            case IrProtocol.XSAT:
                newCarrier = 38000;
                break;

            default:
                return;
            }

            // If the current carrier frequency is within +- 50 hz then it's close enough.
            if (_code.Carrier >= newCarrier - 50 && _code.Carrier <= newCarrier + 50)
            {
                return;
            }

            if (DialogResult.Yes ==
                MessageBox.Show(this, String.Format("Use this protocol's carrier frequency ({0})?", newCarrier), "Decode IR",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                textBoxCarrier.Text = newCarrier.ToString();

                _code.Carrier = newCarrier;

                RefreshForm();
            }
        }