/// <summary>
        ///   Returns a new <see cref="ListLedGroup" /> which contains all LEDs from the given ledgroup excluding the specified
        ///   ones.
        /// </summary>
        /// <param name="ledGroup">The base ledgroup.</param>
        /// <param name="ledIds">The LEDs to exclude.</param>
        /// <returns>The new <see cref="ListLedGroup" />.</returns>
        public static ListLedGroup Exclude(this AbstractLedGroup ledGroup, params CorsairLed[] ledIds)
        {
            var listLedGroup = ledGroup.ToListLedGroup();

            foreach (var led in ledIds)
            {
                listLedGroup.RemoveLed(led);
            }
            return(listLedGroup);
        }
        /// <summary>
        ///   Converts the given <see cref="AbstractLedGroup" /> to a <see cref="ListLedGroup" />.
        /// </summary>
        /// <param name="ledGroup">The <see cref="AbstractLedGroup" /> to convert.</param>
        /// <returns>The converted <see cref="ListLedGroup" />.</returns>
        public static ListLedGroup ToListLedGroup(this AbstractLedGroup ledGroup)
        {
            var listLedGroup = ledGroup as ListLedGroup;

            // ReSharper disable once InvertIf
            if (listLedGroup == null)
            {
                var wasAttached = ledGroup.Detach();
                listLedGroup = new ListLedGroup(ledGroup.Device, wasAttached, ledGroup.GetLeds())
                {
                    Brush = ledGroup.Brush
                };
            }
            return(listLedGroup);
        }
 /// <summary>
 ///   Detaches the given ledgroup from the device.
 /// </summary>
 /// <param name="ledGroup">The ledgroup to attach.</param>
 /// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
 public static bool Detach(this AbstractLedGroup ledGroup) => ledGroup.Device?.DetachLedGroup(ledGroup) ?? false;
Beispiel #4
0
 /// <summary>
 /// Detaches the given ledgroup from the device.
 /// </summary>
 /// <param name="ledGroup">The ledgroup to attach.</param>
 /// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
 public static bool Detach(this AbstractLedGroup ledGroup)
 {
     return(ledGroup.Device?.DetachLedGroup(ledGroup) ?? false);
 }