Beispiel #1
0
        public static List <Device> GetDevices(RGBSurface surface, string type)
        {
            IList <IRGBDevice> devices    = null;
            RGBDeviceType      deviceType = 0;

            switch (type)
            {
            case "keyboard":
                deviceType = RGBDeviceType.Keyboard;
                break;

            case "mouse":
                deviceType = RGBDeviceType.Mouse;
                break;

            case "ledstripe":
                deviceType = RGBDeviceType.LedStripe;
                break;

            case "graphiccard":
                deviceType = RGBDeviceType.GraphicsCard;
                break;

            case "motherboard":
                deviceType = RGBDeviceType.Mainboard;
                break;

            default:
                deviceType = RGBDeviceType.All;
                break;
            }
            //string exeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            //Console.WriteLine(exeDir);
            //CoolerMasterDeviceProvider.PossibleX64NativePaths.Add(exeDir + "\\x64\\CMSDK.dll");
            //CoolerMasterDeviceProvider.PossibleX86NativePaths.Add(exeDir + "\\x86\\CMSDK.dll");
            AddDllPaths();
            surface.LoadDevices(new CorsairDeviceProviderLoader().GetDeviceProvider(), deviceType);
            surface.LoadDevices(new CoolerMasterDeviceProviderLoader().GetDeviceProvider(), deviceType);
            surface.LoadDevices(new LogitechDeviceProviderLoader().GetDeviceProvider(), deviceType);
            surface.LoadDevices(new RazerDeviceProviderLoader().GetDeviceProvider(), deviceType);
            devices = surface.GetDevices(deviceType);

            var data = devices
                       .Select(device => new Device()
            {
                id           = device.DeviceInfo.Lighting,
                type         = type,
                manufacturer = device.DeviceInfo.Manufacturer,
                model        = device.DeviceInfo.Model,
            }).ToList();

            return(data);
        }
Beispiel #2
0
        public bool IsPeripheralConnected() => _deviceProvider.Devices.Any(d => d.DeviceInfo.DeviceType == RGBDeviceType.Mouse); //TODO DarthAffe 03.02.2019: Which devices are "peripherals"?

        public bool Initialize()
        {
            lock (_lock)
            {
                if (IsInitialized())
                {
                    return(true);                 //DarthAffe 03.02.2019: I'm not sure if that's intended, but to me it seems aurora has a threading-issue in the initialization-part
                }
                try
                {
                    _surface.LoadDevices(_deviceProvider, throwExceptions: true, exclusiveAccessIfPossible: false);
                    _ledGroup?.Detach(); //DarthAffe 03.02.2019: This should never run, but safety first
                    _ledGroup = new ListLedGroup(_deviceProvider.Devices.SelectMany(d => d))
                    {
                        Brush = _brush
                    };
                    //rgbDevice  = new CorsairDeviceProvider();
                    // _deviceProvider.Initialize(RGBDeviceType.Fan|RGBDeviceType.Cooler|RGBDeviceType.HeadsetStand);


                    //RGB.NET.Core.Color c = new RGB.NET.Core.Color(27, 184, 235);
                    //ledGroup.Brush = new SolidColorBrush(c);
                    //_surface.Update();
                    return(IsInitialized());
                }
                catch (Exception ex)
                {
                    Global.logger.Error(ex, $"RGB.NET device ({GetDeviceName()}), Exception! Message: " + ex.Message);
                    return(false);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initilize the keylighter
        /// </summary>
        public void Start()
        {
            //initilize the keyboard or return an exception if it fails.
            try
            {
                surface.Exception += args =>
                {
                    Console.WriteLine("RGB Wrapper Exception!");
                    Console.WriteLine("Message:" + args.Exception.Message);
                };
                surface.LoadDevices(CorsairDeviceProvider.Instance);

                Console.WriteLine("CUE Started");

                keyboard = surface.Devices.FirstOrDefault(x => x.DeviceInfo.Manufacturer.ToUpper() == "CORSAIR" && x.DeviceInfo.DeviceType == RGBDeviceType.Keyboard) as CorsairKeyboardRGBDevice;
                if (keyboard != null)
                {
                    keyboard.UpdateMode = DeviceUpdateMode.Sync;
                    //keyboard.UpdateFrequency = 1f/30f;
                    KeyGroups.SetupKeyGroups(keyboard);
                }
            }
            catch (CUEException ex)
            {
                Console.WriteLine("CUE Exception!");
                Console.WriteLine("ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error));
                keyboard = null;
            }
        }
 protected void LoadDevices(RGBSurface surface, IRGBDeviceProvider deviceProvider)
 {
     surface.LoadDevices(deviceProvider, RGBDeviceType.Keyboard | RGBDeviceType.LedMatrix
                         | RGBDeviceType.Mousepad | RGBDeviceType.LedStripe
                         | RGBDeviceType.Mouse | RGBDeviceType.Headset
                         | RGBDeviceType.HeadsetStand);
 }
 private void LoadDevices(RGBSurface surface, IRGBDeviceProvider deviceProvider)
 {
     surface.LoadDevices(deviceProvider, RGBDeviceType.Keyboard | RGBDeviceType.LedMatrix
                         | RGBDeviceType.Mousepad | RGBDeviceType.LedStripe
                         | RGBDeviceType.Mouse // | RGBDeviceType.Headset
                         | RGBDeviceType.HeadsetStand
                                               //| RGBDeviceType.GraphicsCard
                                               //| RGBDeviceType.DRAM | RGBDeviceType.LedMatrix
                                               //| RGBDeviceType.LedStripe | RGBDeviceType.Keypad
                                               //| RGBDeviceType.Mainboard
                         );
 }
Beispiel #6
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 / 60.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());

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine(device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
            }

            ILedGroup ledGroup = new ListLedGroup(surface.Leds);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (true)
            {
                double time = stopwatch.Elapsed.TotalMilliseconds / 400.0;
                ledGroup.Brush = new RadialGradientBrush(new Point(0.5 + 0.4 * Math.Cos(time), 0.5 + 0.4 * Math.Sin(time)), new RainbowGradient());
            }

            Console.ReadKey();
        }
Beispiel #7
0
        static void InitializeDevices()
        {
            corsairLNP = new HidDeviceLoader().GetDevices().Where(d => d.ProductID == 0x0C0B).First();
            lnpStream  = corsairLNP.Open();
            LightingNodeUtils.FirstTransaction(lnpStream);

            surface            = RGBSurface.Instance;
            surface.Exception += args => Debug.WriteLine(args.Exception.Message);
            surface.UpdateMode = UpdateMode.Continuous;
            surface.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard);
            surface.LoadDevices(CorsairDeviceProvider.Instance);

            auraMb              = surface.Devices.OfType <AsusMainboardRGBDevice>().First();
            auraMb.UpdateMode   = DeviceUpdateMode.SyncBack;
            corsairKeyboard     = surface.Devices.OfType <CorsairKeyboardRGBDevice>().First();
            corsairMousepad     = surface.Devices.OfType <CorsairMousepadRGBDevice>().First();
            corsairHeadsetStand = surface.Devices.OfType <CorsairHeadsetStandRGBDevice>().First();

            IBridgeLocator locator                = new HttpBridgeLocator();
            var            locateBridges          = locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));
            IEnumerable <LocatedBridge> bridgeIPs = locateBridges.Result;

            if (bridgeIPs.Where(B => B.BridgeId == "001788fffe678124").Count() > 0)
            {
                bridgeOne = new LocalHueClient(bridgeIPs.Where(B => B.BridgeId == "001788fffe678124").First().IpAddress);
                var registerOne = bridgeOne.RegisterAsync("LightingLink", "WarMachine");
                //string appKeyOne = registerOne.Result;
                bridgeOne.Initialize("NnmhRXVqLmBUw93kmIwi8PPCt6QHgWlHwkTYT9NC");
            }

            if (bridgeIPs.Where(B => B.BridgeId == "001788fffea04d9c").Count() > 0)
            {
                bridgeTwo = new LocalHueClient(bridgeIPs.Where(B => B.BridgeId == "001788fffea04d9c").First().IpAddress);
                var registerTwo = bridgeTwo.RegisterAsync("LightingLink", "WarMachine");
                //string appKeyTwo = registerTwo.Result;
                bridgeTwo.Initialize("2b0AIky9S2g1LgbggOgsCdNV8EzE2JS8QfBOCHHv");
            }

            GetAsusColors();
        }
Beispiel #8
0
        static void InitializeDevices()
        {
            exclusive = new OpenConfiguration();
            exclusive.SetOption(OpenOption.Exclusive, true);
            exclusive.SetOption(OpenOption.Interruptible, false);

            corsairLNP = DeviceList.Local.GetHidDevices().Where(d => d.ProductID == 0x0C0B).First();
            lnpStream  = corsairLNP.Open(exclusive);
            LightingNodeUtils.FirstTransaction(lnpStream);

            surface            = RGBSurface.Instance;
            surface.Exception += args => Debug.WriteLine(args.Exception.Message);
            surface.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard);
            surface.LoadDevices(CorsairDeviceProvider.Instance);

            auraMb              = surface.Devices.OfType <AsusMainboardRGBDevice>().First();
            auraMb.UpdateMode   = DeviceUpdateMode.SyncBack;
            corsairKeyboard     = surface.Devices.OfType <CorsairKeyboardRGBDevice>().First();
            corsairMousepad     = surface.Devices.OfType <CorsairMousepadRGBDevice>().First();
            corsairHeadsetStand = surface.Devices.OfType <CorsairHeadsetStandRGBDevice>().First();

            GetAsusColors();
        }
Beispiel #9
0
        public static void Init()
        {
            if (!cvarRgb.Valueb())
            {
                return;
            }

            log.WriteLine("rgb: initialising api..");
            _surface            = RGBSurface.Instance;
            _surface.Exception += args => Console.WriteLine(args.Exception.Message);

            _surface.LoadDevices(CorsairDeviceProvider.Instance);
            //surface.LoadDevices(LogitechDeviceProvider.Instance);
            //surface.LoadDevices(MsiDeviceProvider.Instance);
            _surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
            _surface.LoadDevices(RazerDeviceProvider.Instance);

            TimerUpdateTrigger TimerTrigger = new TimerUpdateTrigger
            {
                UpdateFrequency = 0.05
            };

            RGBSurface.Instance.RegisterUpdateTrigger(TimerTrigger);
            TimerTrigger.Start();

            _surface.AlignDevices();

            foreach (var v in RGBSurface.Instance.Devices)
            {
                log.WriteLine("rgb: device connected " + v.DeviceInfo.Manufacturer + " " + v.DeviceInfo.Model + " (" +
                              v.DeviceInfo.DeviceType + ")");
            }
            log.WriteLine("rgb: ready (" + RGBSurface.Instance.Devices.Count() + " devices)", log.LogMessageType.Good);

            _rules             = new Dictionary <LedId, Color>();
            _surface.Updating += args => Update();
        }
        public static void GetCoolerMasterDevices()
        {
            RGBSurface s = RGBSurface.Instance;

            if (!CoolerMasterDeviceProvider.Instance.IsInitialized)
            {
                CoolerMasterDeviceProvider.Instance.Initialize();
            }


            //var a=  App.surface.Devices.OfType<RGBDeviceType.GraphicsCard>();
            s.LoadDevices(CoolerMasterDeviceProvider.Instance);
            foreach (var item in s.Devices)
            {
            }
        }
        /// <summary>
        /// Loads devices from the selected DeviceProviders into the RGBSurface "surface"
        /// The AsusDeviceProvider can cause lots of issues.
        ///     Don't use it on a system that does not have any Aura devices.
        ///     Even when a system has Aura devices, it can still cause issues.
        /// </summary>
        public static void LoadDevices()
        {
            // This method is not best practice, but it does work,
            //     and there are no plans to deprecate it

            //surface.LoadDevices(AsusDeviceProvider.Instance);
            surface.LoadDevices(LogitechDeviceProvider.Instance);
            surface.LoadDevices(CorsairDeviceProvider.Instance);
            surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
            surface.LoadDevices(DMXDeviceProvider.Instance);
            surface.LoadDevices(NovationDeviceProvider.Instance);
            surface.LoadDevices(RazerDeviceProvider.Instance);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            Surface = RGBSurface.Instance;

            Surface.LoadDevices(CorsairDeviceProvider.Instance, RGBDeviceType.LedStripe);
            Surface.AlignDevices();

            ILedGroup  stripGroup   = new ListLedGroup(Surface.Leds);
            List <Led> ledsToRemove = new List <Led>();

            Leds = (List <Led>)stripGroup.GetLeds();
            foreach (Led led in Leds)
            {
                // If you see that something is wrong with your setup, try changing the numbers in the strings
                if (led.Device.DeviceInfo.DeviceName != "Corsair Led Strip" &&
                    led.Device.DeviceInfo.DeviceName != "Corsair Led Strip 2" &&
                    led.Device.DeviceInfo.DeviceName != "Corsair Led Strip 3" &&
                    led.Device.DeviceInfo.DeviceName != "Corsair Led Strip 4"
                    // Uncomment the following lines if you have 6 strips in your design
                    // && led.Device.DeviceInfo.DeviceName != "Corsair Led Strip 5"
                    // && led.Device.DeviceInfo.DeviceName != "Corsair Led Strip 6"
                    )
                {
                    ledsToRemove.Add(led);
                }
            }
            foreach (Led led in ledsToRemove)
            {
                Leds.Remove(led);
            }

            Thread UpdateThread = new Thread(UpdateLeds);

            RunUpdateThread   = true;
            PotentialFpsMeter = new Stopwatch();
            ActualFpsMeter    = new Stopwatch();
            UpdateThread.Start();
            Console.WriteLine("Running Ambientia. Press any key or close this window to exit.\n\n");
            Console.ReadKey();
            RunUpdateThread = false;
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            Surface = RGBSurface.Instance;
            // You should set some device filters here
            Surface.LoadDevices(CorsairDeviceProvider.Instance);
            Surface.AlignDevices();

            foreach (IRGBDevice device in Surface.GetDevices <IRGBDevice>())
            {
                Console.WriteLine("Found " + device.DeviceInfo.DeviceName);
            }
            CorsairGroup = new ListLedGroup(Surface.Leds);

            Thread UpdateThread = new Thread(UpdateLeds);

            RunUpdateThread   = true;
            Stopwatch         = new Stopwatch();
            ActualFpsMeter    = new Stopwatch();
            PotentialFpsMeter = new Stopwatch();
            UpdateThread.Start();
            Console.WriteLine("Running Mediana. Press any key or close this window to exit.\n\n");
            Console.ReadKey();
            RunUpdateThread = false;
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Currently modes are supported: rainbow and sync");
            Console.WriteLine("For rainbow, just run the exe");
            Console.WriteLine("For sync, add the argument sync -> eg. 'RGB.exe sync'");

            RGBSurface surface = RGBSurface.Instance;

            bool sync = false;

            if (args != null && args.Length > 0 && args[0] == "sync")
            {
                sync = true;
                Console.WriteLine("Starting sync mode...");
            }
            else
            {
                Console.WriteLine("Starting rainbow mode...");
            }


            if (sync)
            {
                surface.LoadDevices(AsusDeviceProvider.Instance, exclusiveAccessIfPossible: false, throwExceptions: true);
                surface.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
            }
            else
            {
                surface.LoadDevices(AsusDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
                surface.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true);
            }

            surface.AlignDevices();


            Console.WriteLine($"Found {surface.Devices.Count()} devices!");
            foreach (var dev in surface.Devices)
            {
                Console.WriteLine($"dev: {dev.DeviceInfo.DeviceName}");
            }

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

                mainboard.UpdateMode = DeviceUpdateMode.SyncBack;

                var group = new ListLedGroup(surface.Leds).Exclude(mainboard.ToArray());
                group.Brush = new SyncBrush(((IRGBDevice)mainboard)[LedId.Mainboard1]);
            }
            else
            {
                foreach (var dev in surface.Devices)
                {
                    dev.UpdateMode = DeviceUpdateMode.Sync;
                }

                var group    = new ListLedGroup(surface.Leds);
                var gradient = new RainbowGradient();
                var brush    = new LinearGradientBrush(gradient);
                group.Brush = brush;

                System.Timers.Timer aTimer = new System.Timers.Timer();
                aTimer.Elapsed += (s, e) => { gradient.Move(7); };
                aTimer.Interval = 100;
                aTimer.Start();
            }

            TimerUpdateTrigger timerTrigger = new TimerUpdateTrigger();

            timerTrigger.UpdateFrequency = 0.05;
            surface.RegisterUpdateTrigger(timerTrigger);
            timerTrigger.Start();

            Console.Read();
        }
        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");
            }
        }
Beispiel #16
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 / 200.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: " + surface.Devices.Count());

            int index = 0;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine("[" + index + "] " + device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                index++;
            }

            //Index of the chosen device
            int choice;

            if (surface.Devices.Count() < 1)
            {
                Console.WriteLine("No devices detected :(");
                Console.ReadKey();

                return;
            }
            else if (surface.Devices.Count() == 1)
            {
                choice = 0;
            }
            else
            {
                //Let the user choose which device the effect should be applied to by it's index in the enumeration
                Console.Write("Pick a device [Enter Number]:\n>");


                bool isOutOfRange = false;
                do
                {
                    //Is the entered string an int?
                    while (!int.TryParse(Console.ReadLine(), out choice))
                    {
                        Console.Write("Invalid Number.\n>");
                    }

                    //If it is an int, is it out of range?
                    isOutOfRange = choice <0 || choice> surface.Devices.Count() - 1;

                    if (isOutOfRange)
                    {
                        Console.Write("Invalid Number.\n>");
                    }
                } while (isOutOfRange);
            }

            //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 surface.Devices.ElementAt(choice))
            {
                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++;
            }

            Console.WriteLine($"Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]\nPress [ESC] to Close, any other key to continue the animation.");

            //Set background
            ListLedGroup groupBackground = new ListLedGroup(surface.Devices.ElementAt(choice));

            groupBackground.ZIndex = 0;
            groupBackground.Brush  = new SolidColorBrush(new Color(100, 100, 100));

            Dictionary <LedId, ListLedGroup> ledGroups = new Dictionary <LedId, ListLedGroup>();

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (!ledGroups.ContainsKey(led.Id))
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.ZIndex          = 1;
                    group.Brush           = new SolidColorBrush(new Color(0.0, 1.0, 0.0));
                    group.Brush.IsEnabled = false;

                    ledGroups.Add(led.Id, group);
                }
            }

            double xoff = 0.0;
            bool   play;

            do
            {
                foreach (Led led in surface.Devices.ElementAt(choice))
                {
                    //Map positions of Leds to Range
                    double x = (led.ActualLocation.X + led.ActualSize.Width / 2.0).Map(minx, maxx, 0.0, 4 * Math.PI);
                    double y = (led.ActualLocation.Y + led.ActualSize.Height / 2.0).Map(miny, maxy, 2, -2);

                    //Activate/Deactivate Brushes according to calculation
                    if (Math.Sin(x + xoff) >= y)
                    {
                        ledGroups[led.Id].Brush.IsEnabled = true;
                    }
                    else
                    {
                        ledGroups[led.Id].Brush.IsEnabled = false;
                    }
                }

                if (!anim_autoplay)
                {
                    play = Console.ReadKey().Key != ConsoleKey.Escape;
                }
                else
                {
                    Thread.Sleep(1000 / 12);
                }

                xoff += 0.1;
            } while (anim_autoplay || play);


            Console.ReadKey();
            return;
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            RGBSurface surface = RGBSurface.Instance;
            Random     random  = new Random();

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

            TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger();

            updateTrigger.UpdateFrequency = 1.0 / 200.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: " + surface.Devices.Count());

            int index = 0;

            foreach (IRGBDevice device in surface.Devices)
            {
                Console.WriteLine("[" + index + "] " + device.DeviceInfo.DeviceName + " || " + device.DeviceInfo.DeviceType + " || " + device.DeviceInfo.Manufacturer + " || " + device.DeviceInfo.Model);
                index++;
            }

            //Index of the chosen device
            int choice;

            if (surface.Devices.Count() < 1)
            {
                Console.WriteLine("No devices detected :(");
                Console.ReadKey();

                return;
            }
            else if (surface.Devices.Count() == 1)
            {
                choice = 0;
            }
            else
            {
                //Let the user choose which device the effect should be applied to by it's index in the enumeration
                Console.Write("Pick a device [Enter Number]:\n>");


                bool isOutOfRange = false;
                do
                {
                    //Is the entered string an int?
                    while (!int.TryParse(Console.ReadLine(), out choice))
                    {
                        Console.Write("Invalid Number.\n>");
                    }

                    //If it is an int, is it out of range?
                    isOutOfRange = choice <0 || choice> surface.Devices.Count() - 1;

                    if (isOutOfRange)
                    {
                        Console.Write("Invalid Number.\n>");
                    }
                } while (isOutOfRange);
            }


            //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 surface.Devices.ElementAt(choice))
            {
                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++;
            }

            Console.WriteLine($"Total LED count: {count}, X: [{minx}, {maxx}], Y: [{miny}, {maxy}]\nPress [ESC] to Close, any other key to continue the animation.");

            //Set background
            ListLedGroup groupBackground = new ListLedGroup(surface.Devices.ElementAt(choice));

            groupBackground.ZIndex = 0;
            groupBackground.Brush  = new SolidColorBrush(new Color(0, 0, 0));

            Dictionary <LedId, ListLedGroup> ledGroups = new Dictionary <LedId, ListLedGroup>();

            foreach (Led led in surface.Devices.ElementAt(choice))
            {
                if (!ledGroups.ContainsKey(led.Id))
                {
                    ListLedGroup group = new ListLedGroup(led);
                    group.ZIndex          = 1;
                    group.Brush           = new SolidColorBrush(new Color(0.0, 0.0, 0.0));
                    group.Brush.IsEnabled = false;

                    ledGroups.Add(led.Id, group);
                }
            }

            ConsoleKeyInfo key = Console.ReadKey();

            Console.Write("\r");
            while (key.Key != ConsoleKey.Escape)
            {
                LedId pressedKeyLedId = KeyConverter.GetLedByConsoleKey(key.Key);

                foreach (Led led in surface.Devices.ElementAt(choice))
                {
                    ledGroups[led.Id].Brush.IsEnabled = false;
                }

                if (pressedKeyLedId != LedId.Invalid)
                {
                    double hue = random.NextDouble() * 360;
                    foreach (Led led in surface.Devices.ElementAt(choice))
                    {
                        const double distScaleFac = 2.0;
                        double       deltaX       = led.ActualLocation.X - led.ActualSize.Width / 2 - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualLocation.X - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualSize.Width / 2;
                        double       deltaY       = led.ActualLocation.Y - led.ActualSize.Height / 2 - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualLocation.Y - surface.Devices.ElementAt(choice)[pressedKeyLedId].ActualSize.Height / 2;
                        double       dist         = distScaleFac * Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

                        Color color = new Color();
                        color = color.SetHSV(hue, 1.0, 1.0);
                        color = color.SetA(Math.Max(255.0 - dist, 0) / 255.0);

                        ledGroups[led.Id].Brush           = new SolidColorBrush(color);
                        ledGroups[led.Id].Brush.IsEnabled = true;
                    }
                }

                key = Console.ReadKey();
                Console.Write("\r");
            }


            Console.ReadKey();
            return;
        }
Beispiel #18
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();
        }