mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Working on render logic
This commit is contained in:
1 parent
c2c849201d
commit
9badc666e8
8 files changed
+50
-19
No files matched your search
@@ -64,12 +64,17 @@ namespace Artemis.Core.Services
|
||||
foreach (var module in modules)
|
||||
module.Update(args.DeltaTime);
|
||||
|
||||
// If there is no graphics decorator, skip the frame
|
||||
if (_rgbService.GraphicsDecorator == null)
|
||||
return;
|
||||
|
||||
// Render all active modules
|
||||
using (var g = _rgbService.GraphicsDecorator.GetGraphics())
|
||||
{
|
||||
// If there are no graphics, skip the frame
|
||||
if (g == null)
|
||||
return;
|
||||
|
||||
g.Clear(Color.Black);
|
||||
foreach (var module in modules)
|
||||
module.Render(args.DeltaTime, _rgbService.Surface, g);
|
||||
|
||||
@@ -25,5 +25,7 @@ namespace Artemis.Core.Services.Interfaces
|
||||
/// Occurs when a single device has reloaded
|
||||
/// </summary>
|
||||
event EventHandler<DeviceEventArgs> DeviceReloaded;
|
||||
|
||||
void UpdateGraphicsDecorator();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ namespace Artemis.Core.Services
|
||||
private readonly List<IRGBDevice> _loadedDevices;
|
||||
private readonly ILogger _logger;
|
||||
private readonly TimerUpdateTrigger _updateTrigger;
|
||||
private ListLedGroup _background;
|
||||
|
||||
internal RgbService(ILogger logger)
|
||||
{
|
||||
@@ -58,7 +59,7 @@ namespace Artemis.Core.Services
|
||||
_logger.Warning("Device provider {deviceProvider} has no devices", deviceProvider.GetType().Name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lock (_loadedDevices)
|
||||
{
|
||||
foreach (var surfaceDevice in deviceProvider.Devices)
|
||||
@@ -74,11 +75,6 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
var background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
|
||||
GraphicsDecorator = new GraphicsDecorator(background);
|
||||
background.Brush.AddDecorator(GraphicsDecorator);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -99,6 +95,23 @@ namespace Artemis.Core.Services
|
||||
public event EventHandler<DeviceEventArgs> DeviceLoaded;
|
||||
public event EventHandler<DeviceEventArgs> DeviceReloaded;
|
||||
|
||||
public void UpdateGraphicsDecorator()
|
||||
{
|
||||
// Clean up the old background if present
|
||||
if (_background != null)
|
||||
{
|
||||
_background.RemoveAllDecorators();
|
||||
_background.Detach();
|
||||
}
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
_background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
|
||||
GraphicsDecorator = new GraphicsDecorator(_background);
|
||||
_background.Brush.RemoveAllDecorators();
|
||||
|
||||
_background.Brush.AddDecorator(GraphicsDecorator);
|
||||
}
|
||||
|
||||
private void OnDeviceLoaded(DeviceEventArgs e)
|
||||
{
|
||||
DeviceLoaded?.Invoke(this, e);
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Artemis.Core.Services.Storage
|
||||
deviceConfiguration.ApplyToDevice();
|
||||
}
|
||||
// Update the RGB service's graphics decorator to work with the new surface configuration
|
||||
_rgbService.GraphicsDecorator.UpdateBitmap();
|
||||
_rgbService.UpdateGraphicsDecorator();
|
||||
|
||||
OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(_activeSurfaceConfiguration));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user