Inheritance: System.EventArgs
Esempio n. 1
0
        void carControlsDataGenerator_ButtonStateChanged(object sender, CarButtonEventArgs e)
        {
            if (!e.On)
            {
                return;
            }
            switch (e.Button)
            {
            case CarButtons.ShiftUp:
                GearShiftUp();
                break;

            case CarButtons.ShiftDown:
                GearShiftDown();
                break;

            case CarButtons.SE:
                refreshIntervalManager.Decrease();
                break;

            case CarButtons.ST:
                refreshIntervalManager.Increase();
                break;

            case CarButtons.Home:
                refreshIntervalManager.Reset();
                break;
            }
        }
Esempio n. 2
0
        void carControlsDataGenerator_ButtonStateChanged(object sender, CarButtonEventArgs e)
        {
            if (!e.On) return;
            switch (e.Button)
            {
                case CarButtons.ShiftUp:
                    GearShiftUp();
                    break;

                case CarButtons.ShiftDown:
                    GearShiftDown();
                    break;

                case CarButtons.SE:
                    refreshIntervalManager.Decrease();
                    break;

                case CarButtons.ST:
                    refreshIntervalManager.Increase();
                    break;

                case CarButtons.Home:
                    refreshIntervalManager.Reset();
                    break;
            }
        }
        private void UpdateButtons(JoystickState joystickState)
        {
            var buttons = joystickState.GetButtons();

            if (null == lastReportedButtons)
            {
                // We don't raise any events on the first call to this method.
                lastReportedButtons = buttons;
                return;
            }

            if (buttons.Length != lastReportedButtons.Length)
            {
                throw new Exception("Button array lengths differ. This is unexpected.");
            }

            for (int i = 0; i < buttons.Length; i++)
            {
                // Only report this button if state has flipped (on vs off).
                if (buttons[i] != lastReportedButtons[i])
                {
                    CarButtonEventArgs e = CreateCarButtonEventArgs(i, buttons[i]);
                    Log.Spew("Button " + i + ": " + (buttons[i] ? "On" : "Off") + (null == e ? " [not tracked]" : ""));

                    if (null != e)
                    {
                        OnButtonStateChanged(e);
                    }
                }
            }

            lastReportedButtons = buttons;
        }
        protected virtual void OnButtonStateChanged(CarButtonEventArgs e)
        {
            var handler = ButtonStateChanged;

            if (null == handler)
            {
                return;
            }
            handler(this, e);
        }
 protected virtual void OnButtonStateChanged(CarButtonEventArgs e)
 {
     var handler = ButtonStateChanged;
     if (null == handler) return;
     handler(this, e);
 }