mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Don't allow assemblies in the plugin folder to inject protected services
This commit is contained in:
1 parent
f72f145c7e
commit
af2612f294
3 files changed
+49
-81
No files matched your search
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Plugins.Modules.General.ViewModels;
|
||||
using Stylet;
|
||||
|
||||
@@ -14,17 +13,20 @@ namespace Artemis.Plugins.Modules.General
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
|
||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings, ISettingsService settingsService) : base(pluginInfo)
|
||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
||||
{
|
||||
_settings = settings;
|
||||
DisplayName = "General";
|
||||
ExpandsMainDataModel = true;
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
Colors = new Color[1000];
|
||||
|
||||
Hues = new int[1000];
|
||||
for (var i = 0; i < 1000; i++)
|
||||
Hues[i] = ColorHelpers.GetRandomHue();
|
||||
}
|
||||
|
||||
public Color[] Colors { get; set; }
|
||||
public int[] Hues { get; set; }
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
@@ -36,20 +38,21 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
for (var i = 0; i < Colors.Length; i++)
|
||||
for (var i = 0; i < Hues.Length; i++)
|
||||
{
|
||||
var color = Colors[i];
|
||||
Colors[i] = ColorHelpers.ShiftColor(color, (int) (deltaTime * 200));
|
||||
Hues[i]++;
|
||||
if (Hues[i] > 360)
|
||||
Hues[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, Surface surface, Graphics graphics)
|
||||
{
|
||||
// Per-device coloring, slower
|
||||
// RenderPerDevice(surface, graphics);
|
||||
RenderPerDevice(surface, graphics);
|
||||
|
||||
// Per-LED coloring, slowest
|
||||
RenderPerLed(surface, graphics);
|
||||
// RenderPerLed(surface, graphics);
|
||||
}
|
||||
|
||||
public void RenderFullSurface(Surface surface, Graphics graphics)
|
||||
@@ -61,14 +64,7 @@ namespace Artemis.Plugins.Modules.General
|
||||
var index = 0;
|
||||
foreach (var device in surface.Devices)
|
||||
{
|
||||
var color = Colors[index];
|
||||
if (color.A == 0)
|
||||
{
|
||||
color = ColorHelpers.GetRandomRainbowColor();
|
||||
Colors[index] = color;
|
||||
}
|
||||
|
||||
graphics.FillRectangle(new SolidBrush(color), device.RenderRectangle);
|
||||
graphics.FillRectangle(new SolidBrush(ColorHelpers.ColorFromHSV(Hues[index], 1, 1)), device.RenderRectangle);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -78,14 +74,7 @@ namespace Artemis.Plugins.Modules.General
|
||||
var index = 0;
|
||||
foreach (var led in surface.Devices.SelectMany(d => d.Leds))
|
||||
{
|
||||
var color = Colors[index];
|
||||
if (color.A == 0)
|
||||
{
|
||||
color = ColorHelpers.GetRandomRainbowColor();
|
||||
Colors[index] = color;
|
||||
}
|
||||
|
||||
graphics.FillRectangle(new SolidBrush(color), led.AbsoluteRenderRectangle);
|
||||
graphics.FillRectangle(new SolidBrush(ColorHelpers.ColorFromHSV(Hues[index], 1, 1)), led.AbsoluteRenderRectangle);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user