private void SelectBackType(FlagBackType backType) { _backType = backType; foreach (Grid button in panelBacks.Children) { foreach (UIElement buttonChild in button.Children) { if (buttonChild is Rectangle) { if ((FlagBackType)((Rectangle)buttonChild).Tag == backType) { button.Effect = _selectEffect; } else { button.Effect = null; } break; } } } RedrawFlag(); }
public static Tuple <FlagBackType, FlagOverlayType?, FlagOverlayType?> GetRandomEnums() { Random rand = StaticRandom.GetRandomForThread(); double overlayProb = rand.NextDouble(); // Choose a background FlagBackType backType = UtilityCore.GetRandomEnum <FlagBackType>(); FlagOverlayType[] backTypeFilter = _similarOptions.Value. Where(o => o.Item2.Any(p => p == backType)). SelectMany(o => o.Item1). ToArray(); // Choose overlay one FlagOverlayType?overlayType1 = null; if (overlayProb > .33) { overlayType1 = UtilityCore.GetRandomEnum <FlagOverlayType>(backTypeFilter); } // Choose overlay two FlagOverlayType?overlayType2 = null; if (overlayProb > .66) { var test = _notAbove.Value. Where(o => o.Item2.Any(p => p == overlayType1.Value)). SelectMany(o => o.Item1). ToArray(); IEnumerable <FlagOverlayType> filter2 = UtilityCore.Iterate( new[] { overlayType1.Value }, backTypeFilter, _similarOptions.Value.Where(o => o.Item1.Any(p => p == overlayType1.Value)).SelectMany(o => o.Item1), _notAbove.Value.Where(o => o.Item2.Any(p => p == overlayType1.Value)).SelectMany(o => o.Item1) ); overlayType2 = UtilityCore.GetRandomEnum <FlagOverlayType>(filter2); } return(Tuple.Create(backType, overlayType1, overlayType2)); }