/// <summary> /// Returns a new <see cref="ListLedGroup" /> which contains all <see cref="Led"/> from the given <see cref="ILedGroup"/> excluding the specified ones. /// </summary> /// <param name="ledGroup">The base <see cref="ILedGroup"/>.</param> /// <param name="ledIds">The <see cref="Led"/> to exclude.</param> /// <returns>The new <see cref="ListLedGroup" />.</returns> public static ListLedGroup Exclude(this ILedGroup ledGroup, params Led[] ledIds) { ListLedGroup listLedGroup = ledGroup.ToListLedGroup(); foreach (Led led in ledIds) { listLedGroup.RemoveLed(led); } return(listLedGroup); }
/// <summary> /// Converts the given <see cref="ILedGroup" /> to a <see cref="ListLedGroup" />. /// </summary> /// <param name="ledGroup">The <see cref="ILedGroup" /> to convert.</param> /// <returns>The converted <see cref="ListLedGroup" />.</returns> public static ListLedGroup ToListLedGroup(this ILedGroup ledGroup) { // ReSharper disable once InvertIf if (!(ledGroup is ListLedGroup listLedGroup)) { bool wasAttached = ledGroup.Detach(); listLedGroup = new ListLedGroup(wasAttached, ledGroup.GetLeds()) { Brush = ledGroup.Brush }; } return(listLedGroup); }