private bool IsTriggered(IPopupEvent @event) { if (@event.Type != EventType.KeyPress) { return(false); } var keyArgs = @event.EventArgs as KeyEventArgs; return(IsTargetSource(@event.Source) && Key == keyArgs.Key && Modifiers.All(keyArgs.KeyboardDevice.IsKeyDown)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var contraFactorsAllowed = new[] { 1, 2, 4, 8, 16 }; if (ScoreDifference % 5 != 0) { yield return(new ValidationResult("Score must be divisable by 5.")); } if (!contraFactorsAllowed.Contains(ContraFactor)) { yield return(new ValidationResult("ContraFactor must be one of 1, 2, 4, 8, or 16.")); } if (!Modifiers.All(m => contraFactorsAllowed.Contains((int)m.ContraFactor))) { yield return(new ValidationResult("Modifier contraFactors must be one of 1, 2, 4, 8 or 16.")); } if (!IsKlop && !Enum.IsDefined(typeof(GameType), GameType)) { yield return(new ValidationResult($"Dont suppor't game type: {GameType.ToString()}")); } }