예제 #1
0
        protected virtual void OnButtonChanged(BuzzButtonChangedEventArgs e)
        {
            var handler = ButtonChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #2
0
 /// <summary>
 /// Logic when a buzz is triggered by a participant
 /// </summary>
 private void BuzzButtonChangedEventHandler(object sender, BuzzButtonChangedEventArgs args)
 {
     if ((args.Buttons[0].Red && team1CanBuzz) || (args.Buttons[1].Red && team2CanBuzz) || (args.Buttons[2].Red && team3CanBuzz))
     {
         buzzers.ButtonChanged -= BuzzButtonChangedEventHandler;
         if (args.Buttons[0].Red == true)
         {
             playRandomSound(1);
             buzzers.SetLights(true, false, false, false);
             if (!Dispatcher.CheckAccess())
             {
                 Dispatcher.Invoke(
                        () => this.team1BuzzAlert.Visibility = System.Windows.Visibility.Visible, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team1RightAnswer.IsEnabled = true, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team1WrongAnswer.IsEnabled = true, DispatcherPriority.Normal);
             }
         }
         else if (args.Buttons[1].Red == true)
         {
             playRandomSound(2);
             buzzers.SetLights(false, true, false, false);
             if (!Dispatcher.CheckAccess())
             {
                 Dispatcher.Invoke(
                        () => this.team2BuzzAlert.Visibility = System.Windows.Visibility.Visible, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team2RightAnswer.IsEnabled = true, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team2WrongAnswer.IsEnabled = true, DispatcherPriority.Normal);
             }
         }
         else if (args.Buttons[2].Red == true)
         {
             playRandomSound(3);
             buzzers.SetLights(false, false, true, false);
             if (!Dispatcher.CheckAccess())
             {
                 Dispatcher.Invoke(
                        () => this.team3BuzzAlert.Visibility = System.Windows.Visibility.Visible, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team3RightAnswer.IsEnabled = true, DispatcherPriority.Normal);
                 Dispatcher.Invoke(
                        () => this.team3WrongAnswer.IsEnabled = true, DispatcherPriority.Normal);
             }
         }
     }
 }
예제 #3
0
 protected virtual void OnButtonChanged(BuzzButtonChangedEventArgs e)
 {
     var handler = ButtonChanged;
     if (handler != null)
         handler(this, e);
 }
        private void somethingHappens(Object sender, BuzzButtonChangedEventArgs e)
        {
            Debug.WriteLine("BuzzerLayer.somethingHappens()\t"+this+"\tEvent on buzzer # "+
                            devices.IndexOf((IBuzzHandsetDevice) sender)+": "+e);
            lock (states) {
                CallbackArgs result;
                result.handsetId = devices.IndexOf((IBuzzHandsetDevice) sender);

                ButtonStates[] status = e.Buttons;
                ButtonStates changes;

                for (int i = 0; i < 4; i++) {
                    result.buzzerId = i;
                    changes = xor(status[i], states[i]);
                    if (changes.Red) { // red changed
                        result.button = Button.RED;
                        if (status[i].Red) // red pressed
                            result.eventType = CallbackType.BUTTON_PRESS;
                        else // red released
                            result.eventType = CallbackType.BUTTON_RELEASE;
                        cb(result);
                    }
                    if (changes.Blue) {
                        result.button = Button.BLUE;
                        if (status[i].Blue)
                            result.eventType = CallbackType.BUTTON_PRESS;
                        else
                            result.eventType = CallbackType.BUTTON_RELEASE;
                        cb(result);
                    }
                    if (changes.Green) {
                        result.button = Button.GREEN;
                        if (status[i].Green)
                            result.eventType = CallbackType.BUTTON_PRESS;
                        else
                            result.eventType = CallbackType.BUTTON_RELEASE;
                        cb(result);
                    }
                    if (changes.Orange) {
                        result.button = Button.ORANGE;
                        if (status[i].Orange)
                            result.eventType = CallbackType.BUTTON_PRESS;
                        else
                            result.eventType = CallbackType.BUTTON_RELEASE;
                        cb(result);
                    }
                    if (changes.Yellow) {
                        result.button = Button.YELLOW;
                        if (status[i].Yellow)
                            result.eventType = CallbackType.BUTTON_PRESS;
                        else
                            result.eventType = CallbackType.BUTTON_RELEASE;
                        cb(result);
                    }
                }
            }
        }