public void Initialize() { int delay = Settings.StartDelay * 1000; Thread.Sleep(delay); RGBSurface surface = RGBSurface.Instance; LoadDeviceProviders(); surface.AlignDevices(); foreach (IRGBDevice device in surface.Devices) { device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack; } UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / MathHelper.Clamp(Settings.UpdateRate, 1, 100) }; surface.RegisterUpdateTrigger(UpdateTrigger); UpdateTrigger.Start(); foreach (SyncGroup syncGroup in Settings.SyncGroups) { RegisterSyncGroup(syncGroup); } }
static void Main() { var config = new NLog.Config.LoggingConfiguration(); // Targets where to log to: File and Console var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "debugtool.log" }; // Rules for mapping loggers to targets config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile); // Apply config LogManager.Configuration = config; RGBSurface surface = RGBSurface.Instance; LoadDeviceProviders(); surface.AlignDevices(); foreach (IRGBDevice device in surface.Devices) { device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack; } UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / 60 }; surface.RegisterUpdateTrigger(UpdateTrigger); ILedGroup group = new ListLedGroup(surface.Leds); // 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. UpdateTrigger.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
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(); }
public void Initialize() { RGBSurface surface = RGBSurface.Instance; LoadDeviceProviders(); surface.AlignDevices(); surface.Devices.OfType <AsusMainboardRGBDevice>().First().UpdateMode = DeviceUpdateMode.SyncBack; UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / 30.0 }; //MathHelper.Clamp(Settings.UpdateRate, 1, 100) }; surface.RegisterUpdateTrigger(UpdateTrigger); UpdateTrigger.Start(); PremadeSyncGroups(); //Create your sync groups here! HueEntertainment = HueEntertainment.Instance; Task.Factory.StartNew(() => HueEntertainment.Initialize()); }
static void Main(string[] args) { if (args.Length < 1) { throw new ArgumentException("No valid argument."); } var arguments = new ExecArguments(args); var output = new Output(); try { RGBSurface surface = RGBSurface.Instance; surface.AlignDevices(); switch (arguments.action.ToLowerInvariant()) { case "--getdevices": output.data = GetDevices(surface, arguments.deviceType); break; case "--setcolor": output.data = SetColor(surface, arguments.deviceType, arguments.color); break; default: output.error = "No valid argument."; break; } } catch (Exception e) { output.error = e.ToString(); output.data = null; } finally { Console.WriteLine(JsonConvert.SerializeObject(output)); } }
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; }
public KeyboardIO() { Console.WriteLine("Initializing SDK"); RGBSurface surface = RGBSurface.Instance; LoadDevices(surface, CorsairDeviceProvider.Instance); LoadDevices(surface, CoolerMasterDeviceProvider.Instance); LoadDevices(surface, NovationDeviceProvider.Instance); LoadDevices(surface, RazerDeviceProvider.Instance); LoadDevices(surface, LogitechDeviceProvider.Instance); LoadDevices(surface, AsusDeviceProvider.Instance); surface.AlignDevices(); devices = surface.Devices.ToArray(); foreach (var kb in devices) { Console.WriteLine("Detected: " + kb.DeviceInfo.Model); } }
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(); }
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; }
public void Configure(DriverDetails driverDetails) { surface = RGBSurface.Instance; string deviceProvierDir = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? string.Empty, DEVICEPROVIDER_DIRECTORY); if (!Directory.Exists(deviceProvierDir)) { return; } foreach (string file in Directory.GetFiles(deviceProvierDir, "*.dll")) { try { Assembly assembly = Assembly.LoadFrom(file); foreach (Type loaderType in assembly.GetTypes().Where(t => !t.IsAbstract && !t.IsInterface && t.IsClass && typeof(IRGBDeviceProviderLoader).IsAssignableFrom(t))) { if (Activator.CreateInstance(loaderType) is IRGBDeviceProviderLoader deviceProviderLoader) { if (deviceProviderLoader.RequiresInitialization) { continue; } RGBSurface.Instance.LoadDevices(deviceProviderLoader, RGBDeviceType.All); } } } catch (Exception e) { Console.WriteLine(e.Message); } } surface.AlignDevices(); foreach (IRGBDevice device in surface.Devices) { device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack; ControlDevice slsDevice = new ControlDevice(); slsDevice.Name = device.DeviceInfo.Manufacturer + "-" + device.DeviceInfo.DeviceName; slsDevice.DeviceType = DeviceTypeConverter.GetType(device.DeviceInfo.DeviceType); slsDevice.Driver = this; slsDevice.Has2DSupport = false; slsDevice.ProductImage = (Bitmap)System.Drawing.Image.FromStream(imageStream); List <ControlDevice.LedUnit> deviceLeds = new List <ControlDevice.LedUnit>(); int i = 0; foreach (Led led in device) { RGBNetLed newLed = new RGBNetLed(); newLed.Data = new ControlDevice.LEDData(); newLed.Data.LEDNumber = i; i++; newLed.LedId = (int)led.Id; newLed.DeviceName = led.Device.DeviceInfo.DeviceName; deviceLeds.Add(newLed); } slsDevice.LEDs = deviceLeds.ToArray(); DeviceAdded?.Invoke(slsDevice, new Events.DeviceChangeEventArgs(slsDevice)); } UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / 30 }; surface.RegisterUpdateTrigger(UpdateTrigger); UpdateTrigger.Start(); }
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(); }
private void LoadDevices() { RGBDeviceType deviceMask = RGBDeviceType.None; if (_config.Model.rgbDeviceSettings.useKeyboards) { deviceMask |= RGBDeviceType.Keyboard; } if (_config.Model.rgbDeviceSettings.useMice) { deviceMask |= RGBDeviceType.Mouse; } if (_config.Model.rgbDeviceSettings.useMotherboard) { deviceMask |= RGBDeviceType.Mainboard; } Console.WriteLine("Loading rgb devices..."); if (!CorsairDeviceProvider.Instance.IsInitialized) { CorsairDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } CorsairDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(CorsairDeviceProvider.Instance, deviceMask, throwExceptions: true); //razer sdk may not exist because it has to be in system directories. try { if (!RazerDeviceProvider.Instance.IsInitialized) { RazerDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } RazerDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(RazerDeviceProvider.Instance, deviceMask, throwExceptions: true); } catch { } if (!LogitechDeviceProvider.Instance.IsInitialized) { LogitechDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } LogitechDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(LogitechDeviceProvider.Instance, deviceMask, throwExceptions: true); if (!AsusDeviceProvider.Instance.IsInitialized) { AsusDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } AsusDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(AsusDeviceProvider.Instance, deviceMask, throwExceptions: true); _surface.AlignDevices(); foreach (var device in _surface.Devices) { var group = new ListLedGroup(device.Surface) { Brush = new SolidColorBrush(RGBConsts.Black) }; _surface.Update(); group.Detach(); } }
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"); } }
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; }
public void Initialize() { var config = new NLog.Config.LoggingConfiguration(); // Targets where to log to: File and Console var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "rgbsync.log" }; // Rules for mapping loggers to targets config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile); // Apply config LogManager.Configuration = config; Logger.Debug("============ JackNet RGB Sync is Starting ============"); if (AppSettings.RunAsAdmin == true) { Logger.Debug("App should be run as administrator."); Logger.Debug("Checking to see if app is running as administrator..."); var identity = WindowsIdentity.GetCurrent(); var principal = new WindowsPrincipal(identity); bool isRunningAsAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator); if (isRunningAsAdmin == false) { Logger.Debug("App is not running as administrator, restarting..."); ExecuteAsAdmin("RGBSync+.exe"); Exit(); } else { Logger.Debug("App is running as administrator, proceding with startup."); } } CultureInfo ci = CultureInfo.InstalledUICulture; if (AppSettings.Lang == null) { Logger.Debug("Language is not set, inferring language from system culture. Lang=" + ci.TwoLetterISOLanguageName); AppSettings.Lang = ci.TwoLetterISOLanguageName; } System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(AppSettings.Lang); client = new DiscordRpcClient("581567509959016456"); client.Initialize(); string tempSetup = Directory.GetCurrentDirectory() + "\\~TEMP_setup.exe"; if (File.Exists(tempSetup)) { Logger.Debug("Found old installer, removing..."); try { File.Delete(tempSetup); Logger.Debug("Old installer successfully removed."); } catch (Exception ex) { Logger.Error("Error deleting file: " + ex.ToString()); } } int delay = AppSettings.StartDelay * 1000; RGBSurface surface = RGBSurface.Instance; LoadDeviceProviders(); surface.AlignDevices(); foreach (IRGBDevice device in surface.Devices) { device.UpdateMode = DeviceUpdateMode.Sync | DeviceUpdateMode.SyncBack; } UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / MathHelper.Clamp(AppSettings.UpdateRate, 1, 100) }; surface.RegisterUpdateTrigger(UpdateTrigger); UpdateTrigger.Start(); foreach (SyncGroup syncGroup in Settings.SyncGroups) { RegisterSyncGroup(syncGroup); } }
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; }
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(); }