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()); }
/// <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(); }
static void Main(string[] args) { try { OpenRGBDeviceProvider.Instance.DeviceDefinitions.Add(new OpenRGBServerDefinition { ClientName = "TestProgram", Ip = "127.0.0.1", Port = 6742 }); List <IRGBDeviceProvider> deviceProviders = new List <IRGBDeviceProvider> { OpenRGBDeviceProvider.Instance, WootingDeviceProvider.Instance }; using RGBSurface surface = new RGBSurface(); surface.RegisterUpdateTrigger(new TimerUpdateTrigger()); foreach (IRGBDeviceProvider dp in deviceProviders) { surface.Load(dp); } ListLedGroup ledgroup = new ListLedGroup(surface, surface.Leds); RainbowGradient gradient = new RainbowGradient(); gradient.AddDecorator(new MoveGradientDecorator(surface)); ledgroup.Brush = new TextureBrush(new LinearGradientTexture(new Size(1, 1), gradient)); foreach (IRGBDevice d in surface.Devices) { Console.WriteLine($"Found {d.DeviceInfo.DeviceName}"); } Console.ReadLine(); surface?.Dispose(); foreach (IRGBDeviceProvider dp in deviceProviders) { dp.Dispose(); } } catch (Exception e) { Console.WriteLine($"Exception: {e}"); } }