private static async void MpaRgbButton_PressedChanged(object sender, ButtonChangedEventArgs e) { IMPARgbButton b = sender as IMPARgbButton; if (b == null) { return; } if (b.Index < 7) { b.ButtonColor = b.Pressed ? Color.Blue : Color.Red; } else { if (b.Pressed) { return; } List <Color> colors = new List <Color>() { Color.Blue, Color.GreenYellow, Color.Aqua, Color.Firebrick, Color.DarkOrange, Color.Fuchsia, Color.DodgerBlue, Color.Yellow }; var buttons = b.Parent.OfType <IMPARgbButton>(); for (int round = 0; round < 100; round++) { foreach (var mpaRgbButton in buttons) { mpaRgbButton.ButtonColor = colors[(mpaRgbButton.Index + round) % colors.Count]; } await Task.Delay(50); } } }
private void GamePadChanged(object sender, ButtonChangedEventArgs args) { if (args.Buttons.Any(x => x.Button == ButtonStatus.ButtonType.A)) { PerformAction(ActionType.Select); } else if (args.Buttons.Any(x => x.Button == ButtonStatus.ButtonType.Left)) { PerformAction(ActionType.Left); } else if (args.Buttons.Any(x => x.Button == ButtonStatus.ButtonType.Right)) { PerformAction(ActionType.Right); } else if (args.Buttons.Any(x => x.Button == ButtonStatus.ButtonType.Up)) { PerformAction(ActionType.Up); } else if (args.Buttons.Any(x => x.Button == ButtonStatus.ButtonType.Down)) { PerformAction(ActionType.Down); } }
private void OnButtonChanged(ButtonChangedEventArgs e) => this.ButtonChanged?.Invoke(this, e);