public FrameRenderingEventArgs(List <Module> modules, SKCanvas canvas, double deltaTime, RGBSurface rgbSurface) { Modules = modules; Canvas = canvas; DeltaTime = deltaTime; RgbSurface = rgbSurface; }
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); } }
protected void LoadDevices(RGBSurface surface, IRGBDeviceProvider deviceProvider) { surface.LoadDevices(deviceProvider, RGBDeviceType.Keyboard | RGBDeviceType.LedMatrix | RGBDeviceType.Mousepad | RGBDeviceType.LedStripe | RGBDeviceType.Mouse | RGBDeviceType.Headset | RGBDeviceType.HeadsetStand); }
protected AbstractRGBNetDevice(IRGBDeviceProvider deviceProvider, AuroraRGBNetBrush brush = null) { this._deviceProvider = deviceProvider; _surface = RGBSurface.Instance; _brush = brush ?? new AuroraRGBNetBrush(); }
public void Render(double deltaTime, RGBSurface surface, Graphics graphics) { // Folders don't render but their children do foreach (var profileElement in Children) { profileElement.Render(deltaTime, surface, graphics); } }
/// <inheritdoc /> public override void Render(double deltaTime, RGBSurface surface, Graphics graphics) { lock (this) { // Render the profile ActiveProfile?.Render(deltaTime, surface, graphics); } }
public override void Render(double deltaTime, RGBSurface surface, Graphics graphics) { // Lets do this in the least performant way possible foreach (var surfaceLed in _surface.Leds) { var rectangle = surfaceLed.AbsoluteLedRectangle.ToDrawingRectangle(); graphics.FillRectangle(new SolidBrush(_color), rectangle); } }
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); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { _surface = RGBSurface.Instance; _surface.SurfaceLayoutChanged += RGBSurfaceOnSurfaceLayoutChanged; foreach (IRGBDevice device in _surface.Devices) { _newDevices.Add(device); } UpdateSurface(); }
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 ); }
public void Render(double deltaTime, RGBSurface surface, Graphics graphics) { if (LayerType == null) { return; } lock (LayerType) { LayerType.Render(this, surface, graphics); } }
public GeneralModule(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo) { _settings = settings; DisplayName = "General"; ExpandsMainDataModel = true; _surface = rgbService.Surface; var testSetting = _settings.GetSetting("TestSetting", DateTime.Now); _color = ColorHelpers.GetRandomRainbowColor(); }
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()); }
internal ArtemisSurface(RGBSurface rgbSurface, SurfaceEntity surfaceEntity, double scale) { SurfaceEntity = surfaceEntity; EntityId = surfaceEntity.Id; RgbSurface = rgbSurface; Scale = scale; Name = surfaceEntity.Name; IsActive = surfaceEntity.IsActive; // Devices are not populated here but as they are detected Devices = new List <ArtemisDevice>(); }
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 Render(double deltaTime, RGBSurface surface, Graphics graphics) { lock (this) { if (!IsActivated) { throw new ArtemisCoreException($"Cannot render inactive profile: {this}"); } foreach (var profileElement in Children) { profileElement.Render(deltaTime, surface, graphics); } } }
public static bool SetColor(RGBSurface surface, string type, Color color, LedEffect effect = 0) { IList <Device> devices = GetDevices(surface, type); try { ILedGroup ledGroup = new ListLedGroup(surface.Leds); ledGroup.Brush = new SolidColorBrush(color); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
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) { } }
internal ArtemisSurface(RGBSurface rgbSurface, string name, double scale) { SurfaceEntity = new SurfaceEntity { DeviceEntities = new List <DeviceEntity>() }; EntityId = Guid.NewGuid(); Name = name; Scale = scale; RgbSurface = rgbSurface; IsActive = false; // Devices are not populated here but as they are detected Devices = new List <ArtemisDevice>(); ApplyToEntity(); }
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}"); } }
public void Stop() { try { if (!_started) { return; } if (_surface?.Devices != null) { for (var i = _surface.Devices.Count - 1; i >= 0; i--) { try { var device = _surface.Devices[i]; _surface.Detach(device); device.Dispose(); } catch (Exception ex) { _ = Task.Run(() => _logger?.WriteLog(ex?.ToString())); } } } CorsairDeviceProvider.Instance.Dispose(); CorsairDeviceProvider.Instance.Exception -= Instance_Exception; RazerDeviceProvider.Instance.Dispose(); RazerDeviceProvider.Instance.Exception -= Instance_Exception; LogitechDeviceProvider.Instance.Dispose(); LogitechDeviceProvider.Instance.Exception -= Instance_Exception; AsusDeviceProvider.Instance.Dispose(); AsusDeviceProvider.Instance.Exception -= Instance_Exception; _surface.Exception -= Surface_Exception; _surface.Dispose(); _surface = null; _started = false; } catch (Exception ex) { _ = Task.Run(() => _logger?.WriteLog(ex?.ToString())); } }
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) { 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; }
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)); } }
public void Start() { try { if (_started) { return; } _frameTimeSpan = TimeSpan.FromMilliseconds(1000 / _config.Model.rgbDeviceSettings.updateFrameRate); _colorChangeThreshold = _config.Model.rgbDeviceSettings.colorChangeThreshold; _surface = new RGBSurface(); _surface.Exception += Surface_Exception; LoadDevices(); _started = true; } catch (Exception ex) { _ = Task.Run(() => _logger?.WriteLog(ex?.ToString())); } }
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); } }
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(); }
public void Dispose() { foreach (var device in _surface?.Devices) { try { device.Dispose(); } catch (Exception ex) { _ = Task.Run(() => _logger?.WriteLog(ex?.ToString())); } } _imageByteStream?.Dispose(); _imageByteStream = null; _surface.Exception -= Surface_Exception; _surface?.Dispose(); _surface = null; _started = false; GC.SuppressFinalize(this); }
public RgbService(ILogger logger, ISettingsService settingsService, IPluginManagementService pluginManagementService, IDeviceRepository deviceRepository) { _logger = logger; _pluginManagementService = pluginManagementService; _deviceRepository = deviceRepository; _targetFrameRateSetting = settingsService.GetSetting("Core.TargetFrameRate", 25); Surface = new RGBSurface(); // Let's throw these for now Surface.Exception += SurfaceOnException; Surface.SurfaceLayoutChanged += SurfaceOnLayoutChanged; _targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged; _enabledDevices = new List <ArtemisDevice>(); _devices = new List <ArtemisDevice>(); _ledMap = new Dictionary <Led, ArtemisLed>(); UpdateTrigger = new TimerUpdateTrigger { UpdateFrequency = 1.0 / _targetFrameRateSetting.Value }; Surface.RegisterUpdateTrigger(UpdateTrigger); }
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(); }