示例#1
0
        /// <summary>
        /// Renders a ledgroup.
        /// </summary>
        /// <param name="ledGroup">The led group to render.</param>
        // ReSharper disable once MemberCanBeMadeStatic.Local - idc
        protected virtual void Render(ILedGroup ledGroup)
        {
            if (ledGroup == null)
            {
                return;
            }

            IList <CorsairLed> leds = ledGroup.GetLeds().ToList();

            IBrush brush = ledGroup.Brush;

            if (brush == null)
            {
                return;
            }

            try
            {
                switch (brush.BrushCalculationMode)
                {
                case BrushCalculationMode.Relative:
                    RectangleF brushRectangle = RectangleHelper.CreateRectangleFromRectangles(leds.Select(x => x.LedRectangle));
                    float      offsetX        = -brushRectangle.X;
                    float      offsetY        = -brushRectangle.Y;
                    brushRectangle.X = 0;
                    brushRectangle.Y = 0;
                    brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.Move(offsetX, offsetY))));
                    break;

                case BrushCalculationMode.Absolute:
                    brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle)));
                    break;

                default:
                    throw new ArgumentException();
                }

                brush.UpdateEffects();
                brush.PerformFinalize();

                foreach (KeyValuePair <BrushRenderTarget, CorsairColor> renders in brush.RenderedTargets)
                {
                    this[renders.Key.LedId].Color = renders.Value;
                }
            }
            // ReSharper disable once CatchAllClause
            catch (Exception ex) { OnException(ex); }
        }
示例#2
0
 /// <summary>
 /// Initializes the device.
 /// </summary>
 public virtual void Initialize()
 {
     DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
     SaveColors();
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RectangleLedGroup"/> class.
 /// </summary>
 /// <param name="device">The device this ledgroup belongs to.</param>
 /// <param name="fromLed">They first LED to calculate the rectangle of this ledgroup from.</param>
 /// <param name="toLed">They second LED to calculate the rectangle of this ledgroup from.</param>
 /// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param>
 /// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param>
 public RectangleLedGroup(ICueDevice device, CorsairLed fromLed, CorsairLed toLed, float minOverlayPercentage = 0.5f, bool autoAttach = true)
     : this(device, RectangleHelper.CreateRectangleFromRectangles(fromLed.LedRectangle, toLed.LedRectangle), minOverlayPercentage, autoAttach)
 {
 }