Removed the rest of CS Script and removed old plugin projects

This commit is contained in:
Robert Beekman committed 2019-04-10 16:05:19 +02:00
1 parent aa32c8aae4
commit 90cd27b0c6
47 files changed
+550 -846

No files matched your search

@@ -0,0 +1,89 @@
using System.Collections.Generic;
using System.Drawing;
using Artemis.Core;
using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Modules.General.ViewModels;
using RGB.NET.Core;
using Stylet;
using Color = System.Drawing.Color;
using Rectangle = System.Drawing.Rectangle;
namespace Artemis.Plugins.Modules.General
{
public class GeneralModule : IModule
{
private readonly IRgbService _rgbService;
private readonly RGBSurface _surface;
private Dictionary<Led, Color> _colors;
public GeneralModule()
{
}
public GeneralModule(IRgbService rgbService)
{
_rgbService = rgbService;
_surface = _rgbService.Surface;
_colors = new Dictionary<Led, Color>();
_rgbService.FinishedLoadedDevices += (sender, args) => PopulateColors();
}
// True since the main data model is all this module shows
public bool ExpandsMainDataModel => true;
public void Update(double deltaTime)
{
if (_colors == null)
return;
foreach (var surfaceLed in _surface.Leds)
UpdateLedColor(surfaceLed, deltaTime);
}
public void Render(double deltaTime, RGBSurface surface, Graphics graphics)
{
foreach (var surfaceLed in _surface.Leds)
{
if (!_colors.ContainsKey(surfaceLed))
continue;
var brush = new SolidBrush(_colors[surfaceLed]);
var rectangle = new Rectangle((int) surfaceLed.LedRectangle.X, (int) surfaceLed.LedRectangle.Y, (int) surfaceLed.LedRectangle.Width, (int) surfaceLed.LedRectangle.Height);
graphics.FillRectangle(brush, rectangle);
UpdateLedColor(surfaceLed, deltaTime);
}
}
public IScreen GetMainViewModel()
{
return new GeneralViewModel();
}
public void Dispose()
{
_colors = null;
}
public void LoadPlugin()
{
PopulateColors();
}
private void UpdateLedColor(Led led, double deltaTime)
{
if (_colors.ContainsKey(led))
_colors[led] = ColorHelpers.ShiftColor(_colors[led], (int) (deltaTime * 1000));
else
_colors[led] = ColorHelpers.GetRandomRainbowColor();
}
private void PopulateColors()
{
_colors = new Dictionary<Led, Color>();
foreach (var surfaceLed in _surface.Leds)
_colors.Add(surfaceLed, ColorHelpers.GetRandomRainbowColor());
}
}
}