コード例 #1
0
ファイル: ListLedGroup.cs プロジェクト: aSunnyWillow/RGBifier
 /// <summary>
 ///   Merges the LEDs from the given ledgroup in this ledgroup.
 /// </summary>
 /// <param name="groupToMerge">The ledgroup to merge.</param>
 public void MergeLeds(ILedGroup groupToMerge)
 {
     foreach (var led in groupToMerge.GetLeds().Where(led => !GroupLeds.Contains(led)))
     {
         GroupLeds.Add(led);
     }
 }
コード例 #2
0
        static void SetLedColors(ILedGroup ledGroup)
        {
            using (Graphics g = Graphics.FromImage(BigScreen))
            {
                // Take screenshot
                g.CopyFromScreen(0, 0, 0, 0, BigScreen.Size);
            }

            using (Graphics g = Graphics.FromImage(SmallScreen))
            {
                // Squeeze the screenshot into a 1x1 bitmap
                g.DrawImage(BigScreen, 0, 0, 1, 1);
            }

            // Get the color of the squeezed pixel
            System.Drawing.Color pixelRGB = SmallScreen.GetPixel(0, 0);

            // Convert RGB -> HSV
            HSV pixelHSV = new HSV(pixelRGB);

            // Crank up saturation
            //if (pixelHSV.H > 0.1)
            //    pixelHSV.S = 1.0;

            // Convert HSV -> RGB
            System.Drawing.Color newPixelRGB = pixelHSV.ToRGB();

            RGB.NET.Core.Color color = new RGB.NET.Core.Color((newPixelRGB.R), (newPixelRGB.G), (newPixelRGB.B));

            // Assign the color to all the LEDs in your ledGroup
            ledGroup.Brush = new SolidColorBrush(color);
        }
コード例 #3
0
 /// <summary>
 /// Merges the <see cref="Led"/> from the given ledgroup in this ledgroup.
 /// </summary>
 /// <param name="groupToMerge">The ledgroup to merge.</param>
 public void MergeLeds(ILedGroup groupToMerge)
 {
     foreach (Led led in groupToMerge.GetLeds())
     {
         if (!GroupLeds.Contains(led))
         {
             GroupLeds.Add(led);
         }
     }
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
        /// <summary>
        /// Attaches the given ledgroup.
        /// </summary>
        /// <param name="ledGroup">The ledgroup to attach.</param>
        /// <returns><c>true</c> if the ledgroup could be attached; otherwise, <c>false</c>.</returns>
        public bool AttachLedGroup(ILedGroup ledGroup)
        {
            lock (LedGroups)
            {
                if (ledGroup == null || LedGroups.Contains(ledGroup))
                {
                    return(false);
                }

                LedGroups.AddLast(ledGroup);
                return(true);
            }
        }
コード例 #7
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); }
        }
コード例 #8
0
        public GraphicsDecorator(ILedGroup ledGroup, double scale)
        {
            _scale = scale;

            var leds = ledGroup.GetLeds().ToList();

            if (!leds.Any())
            {
                return;
            }

            var width  = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Location.X + l.AbsoluteLedRectangle.Size.Width) * scale, 4096);
            var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Location.Y + l.AbsoluteLedRectangle.Size.Height) * scale, 4096);

            Bitmap = new SKBitmap(new SKImageInfo(width.RoundToInt(), height.RoundToInt()));
        }
コード例 #9
0
        /// <summary>
        /// Paints a moving gradient effect on a given ILedGroup
        /// </summary>
        /// <param name="group">The ILedGroup to apply the brush to</param>
        /// <param name="trigger">The UpdateTrigger registered to the RGBSurface used</param>
        public static void PaintGradient(ILedGroup group, TimerUpdateTrigger trigger)
        {
            // Create new gradient
            IGradient gradient = new RainbowGradient();

            // Add a MoveGradientDecorator to the gradient
            gradient.AddDecorator(new RGB.NET.Decorators.Gradient.MoveGradientDecorator());

            // Make new LinearGradientBrush from gradient
            LinearGradientBrush nBrush = new LinearGradientBrush(gradient);

            // Apply LinearGradientBrush to led group
            group.Brush = nBrush;

            // Start UpdateTrigger, without this, the gradient will be drawn, but will not move.
            trigger.Start();
        }
コード例 #10
0
        /// <summary>
        /// Detaches the given ledgroup.
        /// </summary>
        /// <param name="ledGroup">The ledgroup to detached.</param>
        /// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
        public bool DetachLedGroup(ILedGroup ledGroup)
        {
            lock (LedGroups)
            {
                if (ledGroup == null)
                {
                    return(false);
                }

                LinkedListNode <ILedGroup> node = LedGroups.Find(ledGroup);
                if (node == null)
                {
                    return(false);
                }

                LedGroups.Remove(node);
                return(true);
            }
        }
コード例 #11
0
        /// <summary>
        /// Attaches the given <see cref="ILedGroup"/>.
        /// </summary>
        /// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
        /// <returns><c>true</c> if the <see cref="ILedGroup"/> could be attached; otherwise, <c>false</c>.</returns>
        public bool AttachLedGroup(ILedGroup ledGroup)
        {
            if (ledGroup == null)
            {
                return(false);
            }

            lock (_ledGroups)
            {
                if (_ledGroups.Contains(ledGroup))
                {
                    return(false);
                }

                _ledGroups.AddLast(ledGroup);
                ledGroup.OnAttach();

                return(true);
            }
        }
コード例 #12
0
        /// <summary>
        /// Detaches the given <see cref="ILedGroup"/>.
        /// </summary>
        /// <param name="ledGroup">The <see cref="ILedGroup"/> to detached.</param>
        /// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
        public bool DetachLedGroup(ILedGroup ledGroup)
        {
            if (ledGroup == null)
            {
                return(false);
            }

            lock (_ledGroups)
            {
                LinkedListNode <ILedGroup> node = _ledGroups.Find(ledGroup);
                if (node == null)
                {
                    return(false);
                }

                _ledGroups.Remove(node);
                node.Value.OnDetach();

                return(true);
            }
        }
コード例 #13
0
        /// <summary>
        /// Renders a ledgroup.
        /// </summary>
        /// <param name="ledGroup">The led group to render.</param>
        private void Render(ILedGroup ledGroup)
        {
            IList <Led> leds  = ledGroup.GetLeds().ToList();
            IBrush      brush = ledGroup.Brush;

            if ((brush == null) || !brush.IsEnabled)
            {
                return;
            }

            switch (brush.BrushCalculationMode)
            {
            case BrushCalculationMode.Relative:
                Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x)));
                Point     offset         = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
                brushRectangle.Location.X = 0;
                brushRectangle.Location.Y = 0;
                brush.PerformRender(brushRectangle,
                                    leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
                break;

            case BrushCalculationMode.Absolute:
                brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x))));
                break;

            default:
                throw new ArgumentException();
            }

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

            foreach (KeyValuePair <BrushRenderTarget, Color> renders in brush.RenderedTargets)
            {
                renders.Key.Led.Color = renders.Value;
            }
        }
コード例 #14
0
 /// <summary>
 ///   Checks if the effect can be applied to the target object.
 /// </summary>
 /// <param name="target">The <see cref="IEffectTarget{T}" /> this effect is attached to.</param>
 /// <returns><c>true</c> if the effect can be attached; otherwise, <c>false</c>.</returns>
 public virtual bool CanBeAppliedTo(ILedGroup target) => target is T;
コード例 #15
0
 /// <summary>
 /// Checks if the effect can be applied to the target object.
 /// </summary>
 /// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
 /// <returns><c>true</c> if the effect can be attached; otherwise, <c>false</c>.</returns>
 public virtual bool CanBeAppliedTo(ILedGroup target)
 {
     return(target is T);
 }
コード例 #16
0
 /// <summary>
 /// Detaches the given <see cref="ILedGroup"/> from the <see cref="RGBSurface"/>.
 /// </summary>
 /// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
 /// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
 public static bool Detach(this ILedGroup ledGroup)
 {
     return(RGBSurface.Instance.DetachLedGroup(ledGroup));
 }
コード例 #17
0
        /// <summary>
        /// Detaches the given ledgroup.
        /// </summary>
        /// <param name="ledGroup">The ledgroup to detached.</param>
        /// <returns><c>true</c> if the ledgroup could be detached; otherwise, <c>false</c>.</returns>
        public bool DetachLedGroup(ILedGroup ledGroup)
        {
            lock (LedGroups)
            {
                if (ledGroup == null) return false;

                LinkedListNode<ILedGroup> node = LedGroups.Find(ledGroup);
                if (node == null) return false;

                LedGroups.Remove(node);
                return true;
            }
        }
コード例 #18
0
ファイル: Settings.cs プロジェクト: sthales/RGBSync
        private void Form1_Load(object sender, EventArgs e)
        {
            this.ShowInTaskbar   = false;
            this.WindowState     = FormWindowState.Minimized;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            if (chkShowNotification.Checked)
            {
                notifyIcon1.ShowBalloonTip(5000, "RGBSync", "Click the notification icon to configure RGB Devices.", ToolTipIcon.Info);
            }
            //Process.Start("C:\\Program Files (x86)\\ASUS\\AURA\\AURA.exe");
            //Thread.Sleep(1000);
            //Process.GetProcessesByName("Aura")[0].Kill();

            tabCorsairLink.Enabled = false;
            try
            {
                RGBSurface.Instance.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard, throwExceptions: true);
                if (chkCorsairCue.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkLogitech.Checked)
                {
                    RGBSurface.Instance.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkCM.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CoolerMasterDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkNovation.Checked)
                {
                    RGBSurface.Instance.LoadDevices(NovationDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkCorsairLink.Checked)
                {
                    RGBSurface.Instance.LoadDevices(CorsairLinkDeviceProvider.Instance, exclusiveAccessIfPossible: false, throwExceptions: true);
                }
                if (chkMSI.Checked)
                {
                    RGBSurface.Instance.LoadDevices(MsiDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }
                if (chkRazer.Checked)
                {
                    RGBSurface.Instance.LoadDevices(RazerDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                }


                AsusMainboardRGBDevice mainboard = RGBSurface.Instance.GetDevices <AsusMainboardRGBDevice>().FirstOrDefault();
                if (mainboard == null)
                {
                    throw new ApplicationException("No mainboard to sync with is loaded.");
                }

                mainboard.UpdateMode = DeviceUpdateMode.SyncBack;

                _ledGroup       = new ListLedGroup(RGBSurface.Instance.Leds).Exclude(mainboard.ToArray());
                _ledGroup.Brush = new SyncBrush(((IRGBDevice)mainboard)[SYNC_LED]);
                TimerUpdateTrigger TimerTrigger = new TimerUpdateTrigger();
                TimerTrigger.UpdateFrequency = 0.05;
                RGBSurface.Instance.RegisterUpdateTrigger(TimerTrigger);
                TimerTrigger.Start();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #19
0
        /// <summary>
        /// Paints all leds in a given ILedGroup with a static color
        /// </summary>
        /// <param name="group">The ILedGroup to apply the brush to</param>
        public static void PaintStaticColor(ILedGroup group)
        {
            Color c = new Color(255, 255, 255);

            group.Brush = new SolidColorBrush(c);
        }
コード例 #20
0
ファイル: ListLedGroup.cs プロジェクト: DarthAffe/CUE.NET
 /// <summary>
 /// Merges the LEDs from the given ledgroup in this ledgroup. 
 /// </summary>
 /// <param name="groupToMerge">The ledgroup to merge.</param>
 public void MergeLeds(ILedGroup groupToMerge)
 {
     foreach (CorsairLed led in groupToMerge.GetLeds())
         if (!GroupLeds.Contains(led))
             GroupLeds.Add(led);
 }
コード例 #21
0
 /// <summary>
 /// Detaches the given <see cref="ILedGroup"/> from the <see cref="RGBSurface"/>.
 /// </summary>
 /// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
 /// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
 public static bool Detach(this ILedGroup ledGroup) => RGBSurface.Instance.DetachLedGroup(ledGroup);
コード例 #22
0
        /// <summary>
        /// Attaches the given ledgroup.
        /// </summary>
        /// <param name="ledGroup">The ledgroup to attach.</param>
        /// <returns><c>true</c> if the ledgroup could be attached; otherwise, <c>false</c>.</returns>
        public bool AttachLedGroup(ILedGroup ledGroup)
        {
            lock (LedGroups)
            {
                if (ledGroup == null || LedGroups.Contains(ledGroup)) return false;

                LedGroups.AddLast(ledGroup);
                return true;
            }
        }
コード例 #23
0
 /// <summary>
 ///   Hook which is called when the effect is attached to a device.
 /// </summary>
 /// <param name="target">The <see cref="ILedGroup" /> this effect is attached to.</param>
 public virtual void OnAttach(ILedGroup target)
 {
     LedGroup = (T)target;
 }
コード例 #24
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 144.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + RGBSurface.Instance.Devices.Count());

            ILedGroup groupNum1 = null, groupNum2 = null, groupNum3 = null,
                      groupNum4 = null, groupNum5 = null, groupNum6 = null,
                      groupNum7 = null, groupNum8 = null, groupNum9 = null,
                      groupNumPad = null;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine(device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                groupNum1 = new ListLedGroup(device[LedId.Keyboard_Num1]);
                groupNum2 = new ListLedGroup(device[LedId.Keyboard_Num2]);
                groupNum3 = new ListLedGroup(device[LedId.Keyboard_Num3]);
                groupNum4 = new ListLedGroup(device[LedId.Keyboard_Num4]);
                groupNum5 = new ListLedGroup(device[LedId.Keyboard_Num5]);
                groupNum6 = new ListLedGroup(device[LedId.Keyboard_Num6]);
                groupNum7 = new ListLedGroup(device[LedId.Keyboard_Num7]);
                groupNum8 = new ListLedGroup(device[LedId.Keyboard_Num8]);
                groupNum9 = new ListLedGroup(device[LedId.Keyboard_Num9]);
            }

            if (groupNum1 == null || groupNum2 == null || groupNum3 == null || groupNum4 == null || groupNum5 == null || groupNum6 == null || groupNum7 == null || groupNum8 == null || groupNum9 == null)
            {
                Console.WriteLine("[Error] No numpad LEDs identifiable.");
                return;
            }

            groupNum1.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum2.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum3.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum4.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum5.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum6.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum7.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum8.Brush = new SolidColorBrush(new Color(100, 100, 100));
            groupNum9.Brush = new SolidColorBrush(new Color(100, 100, 100));

            Console.WriteLine("Press [NumPad1-9] to play, [ESC] to quit.\n");

            ConsoleKeyInfo key = Console.ReadKey();

            Console.Write("\r");
            while (key.Key != ConsoleKey.Escape)
            {
                if (key.Key == ConsoleKey.NumPad1 || key.Key == ConsoleKey.NumPad2 || key.Key == ConsoleKey.NumPad3 ||
                    key.Key == ConsoleKey.NumPad4 || key.Key == ConsoleKey.NumPad5 || key.Key == ConsoleKey.NumPad6 ||
                    key.Key == ConsoleKey.NumPad7 || key.Key == ConsoleKey.NumPad8 || key.Key == ConsoleKey.NumPad9)
                {
                    groupNum1.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum2.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum3.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum4.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum5.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum6.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum7.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum8.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum9.Brush = new SolidColorBrush(new Color(100, 100, 100));
                }

                switch (key.Key)
                {
                default:
                    break;

                case ConsoleKey.NumPad1:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum1.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad2:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum2.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad3:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum3.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad4:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum4.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad5:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum5.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad6:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum6.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad7:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum7.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad8:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum8.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;

                case ConsoleKey.NumPad9:
                    //groupNumPad.Brush = new SolidColorBrush(new Color(100, 100, 100));
                    groupNum9.Brush = new SolidColorBrush(new Color(255, 0, 0));
                    break;
                }

                key = Console.ReadKey();
                Console.Write("\r");
            }
        }
コード例 #25
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;

            surface.Exception += eventArgs => Console.WriteLine(eventArgs.Exception.Message);

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 144.0;
            surface.RegisterUpdateTrigger(updateTrigger);
            updateTrigger.Start();

            bool throwExceptions = true;
            //RGBDeviceType loadType = (RGBDeviceType)(-1);
            RGBDeviceType loadType = RGBDeviceType.Keyboard;

            surface.LoadDevices(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            //MSI DLL Broken -- surface.LoadDevices(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);
            surface.LoadDevices(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance, loadType, throwExceptions: throwExceptions);

            surface.AlignDevices();

            //List Detected Devices of loadType
            Console.WriteLine("Device Count: " + RGBSurface.Instance.Devices.Count());

            ILedGroup groupNum1 = null, groupNum2 = null, groupNum3 = null,
                      groupNum4 = null, groupNum5 = null, groupNum6 = null,
                      groupNum7 = null, groupNum8 = null, groupNum9 = null,
                      groupNumPad = null;

            foreach (IRGBDevice device in surface.Devices)
            {
                //Determine device-specific led position minima and maxima (Rectangle Bounds)
                double minx = double.PositiveInfinity, miny = double.PositiveInfinity, maxx = double.NegativeInfinity, maxy = double.NegativeInfinity;
                int    count = 0;
                foreach (Led led in device)
                {
                    if (led.ActualLocation.X < minx)
                    {
                        minx = led.ActualLocation.X;
                    }
                    if (led.ActualLocation.Y < miny)
                    {
                        miny = led.ActualLocation.Y;
                    }
                    if (led.ActualLocation.X > maxx)
                    {
                        maxx = led.ActualLocation.X;
                    }
                    if (led.ActualLocation.Y > maxy)
                    {
                        maxy = led.ActualLocation.Y;
                    }
                    count++;
                }

                foreach (Led led in device)
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.Brush = new SolidColorBrush(new Color(led.ActualLocation.X.Map(minx, maxx, 0.0, 1.0), led.ActualLocation.Y.Map(miny, maxy, 0.0, 1.0), 0.0));
                }

                Console.WriteLine($"Device {device.DeviceInfo.DeviceName} - Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]");
            }

            Console.ReadKey();
        }
コード例 #26
0
 /// <summary>
 ///   Hook which is called when the effect is detached from a device.
 /// </summary>
 /// <param name="target">The <see cref="ILedGroup" /> this effect is detached from.</param>
 public virtual void OnDetach(ILedGroup target)
 {
     LedGroup = default(T);
 }
コード例 #27
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)
        {
            IList<CorsairLed> leds = ledGroup.GetLeds().ToList();
            IBrush brush = ledGroup.Brush;

            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); }
        }