mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
RGB.NET - Updated for latest development branch
This commit is contained in:
parent
81b8f5bf48
commit
606c1b80f2
@ -73,6 +73,9 @@
|
||||
<Reference Include="RGB.NET.Groups">
|
||||
<HintPath>..\..\..\RGB.NET\bin\net5.0\RGB.NET.Groups.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RGB.NET.Layout">
|
||||
<HintPath>..\..\..\RGB.NET\bin\net5.0\RGB.NET.Layout.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Resources\intro-profile.json">
|
||||
|
||||
@ -16,8 +16,6 @@ namespace Artemis.Core
|
||||
builder.Append(rgbDevice.DeviceInfo.Model);
|
||||
builder.Append('-');
|
||||
builder.Append(rgbDevice.DeviceInfo.DeviceType);
|
||||
builder.Append('-');
|
||||
builder.Append(rgbDevice.DeviceInfo.Lighting);
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ namespace Artemis.Core
|
||||
if (!Enabled || Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
|
||||
return;
|
||||
// Ensure the brush is ready
|
||||
if (LayerBrush?.BaseProperties?.PropertiesInitialized == false || LayerBrush?.BrushType != LayerBrushType.Regular)
|
||||
if (LayerBrush?.BaseProperties?.PropertiesInitialized == false)
|
||||
return;
|
||||
|
||||
RenderTimeline(Timeline, canvas);
|
||||
@ -322,6 +322,9 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
ApplyTimeline(timeline);
|
||||
|
||||
if (LayerBrush?.BrushType != LayerBrushType.Regular)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@ namespace Artemis.Core
|
||||
GreenScale = 1;
|
||||
BlueScale = 1;
|
||||
IsEnabled = true;
|
||||
|
||||
|
||||
deviceProvider.DeviceLayoutPaths.TryGetValue(rgbDevice, out string? layoutPath);
|
||||
LayoutPath = layoutPath;
|
||||
|
||||
@ -232,6 +232,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public string? LayoutPath { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layout of the device expanded with Artemis-specific data
|
||||
/// </summary>
|
||||
public ArtemisLayout? Layout { get; internal set; }
|
||||
|
||||
internal DeviceEntity DeviceEntity { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
10
src/Artemis.Core/Models/Surface/ArtemisLayout.cs
Normal file
10
src/Artemis.Core/Models/Surface/ArtemisLayout.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
public class ArtemisLayout
|
||||
{
|
||||
public ArtemisDevice Device { get; set; }
|
||||
public Uri Image { get; set; }
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Services;
|
||||
using Ninject;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
using SkiaSharp;
|
||||
@ -20,7 +21,6 @@ namespace Artemis.Core.LayerBrushes
|
||||
/// </summary>
|
||||
protected RgbNetLayerBrush()
|
||||
{
|
||||
LedGroup = new ListLedGroup();
|
||||
BrushType = LayerBrushType.RgbNet;
|
||||
SupportsTransformation = false;
|
||||
}
|
||||
@ -28,7 +28,10 @@ namespace Artemis.Core.LayerBrushes
|
||||
/// <summary>
|
||||
/// The LED group this layer effect is applied to
|
||||
/// </summary>
|
||||
public ListLedGroup LedGroup { get; internal set; }
|
||||
public ListLedGroup? LedGroup { get; internal set; }
|
||||
|
||||
[Inject]
|
||||
public IRgbService? RgbService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when Artemis needs an instance of the RGB.NET effect you are implementing
|
||||
@ -38,9 +41,14 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal void UpdateLedGroup()
|
||||
{
|
||||
// TODO: This simply renders it on top of the rest, get a ZIndex based on layer position
|
||||
LedGroup.ZIndex = 1;
|
||||
if (LedGroup == null)
|
||||
return;
|
||||
|
||||
if (Layer.Parent != null)
|
||||
LedGroup.ZIndex = Layer.Parent.Children.Count - Layer.Parent.Children.IndexOf(Layer);
|
||||
else
|
||||
LedGroup.ZIndex = 1;
|
||||
|
||||
List<Led> missingLeds = Layer.Leds.Where(l => !LedGroup.ContainsLed(l.RgbLed)).Select(l => l.RgbLed).ToList();
|
||||
List<Led> extraLeds = LedGroup.GetLeds().Where(l => Layer.Leds.All(layerLed => layerLed.RgbLed != l)).ToList();
|
||||
LedGroup.AddLeds(missingLeds);
|
||||
@ -50,7 +58,10 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
LedGroup = new ListLedGroup();
|
||||
if (RgbService == null)
|
||||
throw new ArtemisCoreException("Cannot initialize RGB.NET layer brush because RgbService is not set");
|
||||
|
||||
LedGroup = new ListLedGroup(RgbService.Surface);
|
||||
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
|
||||
|
||||
InitializeProperties();
|
||||
@ -64,8 +75,12 @@ namespace Artemis.Core.LayerBrushes
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (RgbService == null)
|
||||
throw new ArtemisCoreException("Cannot dispose RGB.NET layer brush because RgbService is not set");
|
||||
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
LedGroup.Detach();
|
||||
LedGroup?.Detach(RgbService.Surface);
|
||||
LedGroup = null;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -8,6 +8,13 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
internal class DeviceService : IDeviceService
|
||||
{
|
||||
private readonly IRgbService _rgbService;
|
||||
|
||||
public DeviceService(IRgbService rgbService)
|
||||
{
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
public void IdentifyDevice(ArtemisDevice device)
|
||||
{
|
||||
BlinkDevice(device, 0);
|
||||
@ -16,9 +23,9 @@ namespace Artemis.Core.Services
|
||||
private void BlinkDevice(ArtemisDevice device, int blinkCount)
|
||||
{
|
||||
// Create a LED group way at the top
|
||||
ListLedGroup ledGroup = new(device.Leds.Select(l => l.RgbLed))
|
||||
ListLedGroup ledGroup = new(_rgbService.Surface, device.Leds.Select(l => l.RgbLed))
|
||||
{
|
||||
Brush = new SolidColorBrush(new Color(255, 255, 255)),
|
||||
Brush = new SolidColorBrush(new Color(255, 255, 255)),
|
||||
ZIndex = 999
|
||||
};
|
||||
|
||||
@ -26,7 +33,7 @@ namespace Artemis.Core.Services
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(200);
|
||||
ledGroup.Detach();
|
||||
ledGroup.Detach(_rgbService.Surface);
|
||||
|
||||
if (blinkCount < 5)
|
||||
{
|
||||
|
||||
@ -358,7 +358,7 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ArtemisPluginException(plugin, "Failed to instantiate feature", e);
|
||||
_logger.Warning(new ArtemisPluginException(plugin, "Failed to instantiate feature", e), "Failed to instantiate feature", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
using RGB.NET.Layout;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
@ -26,7 +27,7 @@ namespace Artemis.Core.Services
|
||||
_targetFrameRateSetting = settingsService.GetSetting("Core.TargetFrameRate", 25);
|
||||
_sampleSizeSetting = settingsService.GetSetting("Core.SampleSize", 1);
|
||||
|
||||
Surface = RGBSurface.Instance;
|
||||
Surface = new RGBSurface();
|
||||
|
||||
// Let's throw these for now
|
||||
Surface.Exception += SurfaceOnException;
|
||||
@ -50,7 +51,11 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
Surface.LoadDevices(deviceProvider, RGBDeviceType.All, false, true);
|
||||
// Device provider may have been attached before..?
|
||||
Surface.Detach(deviceProvider.Devices);
|
||||
|
||||
deviceProvider.Initialize(RGBDeviceType.All, true);
|
||||
Surface.Attach(deviceProvider.Devices);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -117,19 +122,19 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
// Apply the application wide brush and decorator
|
||||
BitmapBrush = new BitmapBrush(new Scale(_renderScaleSetting.Value), _sampleSizeSetting);
|
||||
_surfaceLedGroup = new ListLedGroup(artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
|
||||
_surfaceLedGroup = new ListLedGroup(Surface, artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_surfaceLedGroup)
|
||||
{
|
||||
// Clean up the old background
|
||||
_surfaceLedGroup.Detach();
|
||||
_surfaceLedGroup.Detach(Surface);
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
BitmapBrush.Scale = new Scale(_renderScaleSetting.Value);
|
||||
BitmapBrush.Surface = artemisSurface;
|
||||
_surfaceLedGroup = new ListLedGroup(artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
|
||||
_surfaceLedGroup = new ListLedGroup(Surface, artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ namespace Artemis.Core.Services
|
||||
/// <summary>
|
||||
/// Gets the full URL of the end point
|
||||
/// </summary>
|
||||
public string Url => $"{_pluginsModule.ServerUrl.TrimEnd('/')}{_pluginsModule.BaseRoute}{PluginFeature.Plugin.Guid}/{Name}";
|
||||
public string Url => $"{_pluginsModule.ServerUrl?.TrimEnd('/')}{_pluginsModule.BaseRoute}{PluginFeature.Plugin.Guid}/{Name}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin the end point is associated with
|
||||
@ -45,12 +45,12 @@ namespace Artemis.Core.Services
|
||||
/// <summary>
|
||||
/// Gets the mime type of the input this end point accepts
|
||||
/// </summary>
|
||||
public string Accepts { get; protected set; }
|
||||
public string? Accepts { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mime type of the output this end point returns
|
||||
/// </summary>
|
||||
public string Returns { get; protected set; }
|
||||
public string? Returns { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the end point has to process a request
|
||||
|
||||
@ -235,8 +235,8 @@ namespace Artemis.UI.Shared
|
||||
UpdateTransform();
|
||||
|
||||
// Load the device main image
|
||||
if (Device.RgbDevice.DeviceInfo?.Image?.AbsolutePath != null && File.Exists(Device.RgbDevice.DeviceInfo.Image.AbsolutePath))
|
||||
_deviceImage = new BitmapImage(Device.RgbDevice.DeviceInfo.Image);
|
||||
// if (Device.RgbDevice.DeviceInfo?.Image?.AbsolutePath != null && File.Exists(Device.RgbDevice.DeviceInfo.Image.AbsolutePath))
|
||||
// _deviceImage = new BitmapImage(Device.RgbDevice.DeviceInfo.Image);
|
||||
|
||||
// Create all the LEDs
|
||||
foreach (ArtemisLed artemisLed in Device.Leds)
|
||||
|
||||
@ -35,7 +35,7 @@ namespace Artemis.UI.Screens.Settings.Debug
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanOpenImageDirectory => Device.RgbDevice.DeviceInfo.Image != null;
|
||||
public bool CanOpenImageDirectory => Device.Layout?.Image != null;
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
@ -70,7 +70,7 @@ namespace Artemis.UI.Screens.Settings.Debug
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", Path.GetDirectoryName(Device.RgbDevice.DeviceInfo.Image.AbsolutePath));
|
||||
Process.Start(Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", Path.GetDirectoryName(Device.Layout.Image.AbsolutePath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -14,9 +14,10 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
{
|
||||
private readonly IInputService _inputService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ListLedGroup _ledGroup;
|
||||
|
||||
public SurfaceDeviceDetectInputViewModel(ArtemisDevice device, IInputService inputService, IMessageService messageService)
|
||||
public SurfaceDeviceDetectInputViewModel(ArtemisDevice device, IInputService inputService, IMessageService messageService, IRgbService rgbService)
|
||||
{
|
||||
Device = device;
|
||||
Title = $"{Device.RgbDevice.DeviceInfo.DeviceName} - Detect input";
|
||||
@ -24,11 +25,12 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
|
||||
_inputService = inputService;
|
||||
_messageService = messageService;
|
||||
_rgbService = rgbService;
|
||||
_inputService.IdentifyDevice(Device);
|
||||
_inputService.DeviceIdentified += InputServiceOnDeviceIdentified;
|
||||
|
||||
// Create a LED group way at the top
|
||||
_ledGroup = new ListLedGroup(Device.Leds.Select(l => l.RgbLed))
|
||||
_ledGroup = new ListLedGroup(_rgbService.Surface, Device.Leds.Select(l => l.RgbLed))
|
||||
{
|
||||
Brush = new SolidColorBrush(new Color(255, 255, 0)),
|
||||
ZIndex = 999
|
||||
@ -43,7 +45,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
{
|
||||
base.OnDialogClosed(sender, e);
|
||||
_inputService.DeviceIdentified -= InputServiceOnDeviceIdentified;
|
||||
_ledGroup.Detach();
|
||||
_ledGroup.Detach(_rgbService.Surface);
|
||||
}
|
||||
|
||||
private void InputServiceOnDeviceIdentified(object sender, EventArgs e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user