Added Corsair support as a plugin

This commit is contained in:
SpoinkyNL committed 2019-08-11 16:58:43 +02:00
1 parent 1146de1fc5
commit 090c726880
25 files changed
+302 -131

No files matched your search

@@ -52,8 +52,9 @@
<HintPath>..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll</HintPath>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
@@ -67,6 +68,7 @@
<ItemGroup>
<Compile Include="GeneralDataModel.cs" />
<Compile Include="GeneralModule.cs" />
<Compile Include="ColorHelpers.cs" />
<Compile Include="ViewModels\GeneralViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@@ -92,6 +94,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>(robocopy $(TargetDir) %25ProgramData%25\Artemis\plugins\$(ProjectName) /NFL /NDL /NJH /NJS /nc /ns /np) ^&amp; IF %25ERRORLEVEL%25 LEQ 4 exit /B 0</PostBuildEvent>
<PostBuildEvent>(robocopy $(TargetDir) %25ProgramData%25\Artemis\plugins\$(ProjectName) /E /NFL /NDL /NJH /NJS /nc /ns /np) ^&amp; IF %25ERRORLEVEL%25 LEQ 4 exit /B 0</PostBuildEvent>
</PropertyGroup>
</Project>
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace Artemis.Plugins.Modules.General
{
public static class ColorHelpers
{
private static readonly Random _rand = new Random();
/// <summary>
/// Comes up with a 'pure' psuedo-random color
/// </summary>
/// <returns>The color</returns>
public static Color GetRandomRainbowColor()
{
var colors = new List<int>();
for (var i = 0; i < 3; i++)
colors.Add(_rand.Next(0, 256));
var highest = colors.Max();
var lowest = colors.Min();
colors[colors.FindIndex(c => c == highest)] = 255;
colors[colors.FindIndex(c => c == lowest)] = 0;
var returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
return returnColor;
}
public static Color ShiftColor(Color c, int shiftAmount)
{
int newRed = c.R;
int newGreen = c.G;
int newBlue = c.B;
// Red to purple
if (c.R == 255 && c.B < 255 && c.G == 0)
newBlue = newBlue + shiftAmount;
// Purple to blue
else if (c.B == 255 && c.R > 0)
newRed = newRed - shiftAmount;
// Blue to light-blue
else if (c.B == 255 && c.G < 255)
newGreen = newGreen + shiftAmount;
// Light-blue to green
else if (c.G == 255 && c.B > 0)
newBlue = newBlue - shiftAmount;
// Green to yellow
else if (c.G == 255 && c.R < 255)
newRed = newRed + shiftAmount;
// Yellow to red
else if (c.R == 255 && c.G > 0)
newGreen = newGreen - shiftAmount;
newRed = BringIntInColorRange(newRed);
newGreen = BringIntInColorRange(newGreen);
newBlue = BringIntInColorRange(newBlue);
return Color.FromArgb(c.A, newRed, newGreen, newBlue);
}
private static int BringIntInColorRange(int i)
{
return Math.Min(255, Math.Max(0, i));
}
}
}
@@ -19,6 +19,7 @@ namespace Artemis.Plugins.Modules.General
private readonly PluginSettings _settings;
private readonly RGBSurface _surface;
private Dictionary<Led, Color> _colors;
private double _circlePosition;
public GeneralModule(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo)
{
@@ -28,8 +29,9 @@ namespace Artemis.Plugins.Modules.General
_surface = rgbService.Surface;
_colors = new Dictionary<Led, Color>();
rgbService.FinishedLoadedDevices += (sender, args) => PopulateColors();
rgbService.DeviceLoaded += (sender, args) => PopulateColors();
rgbService.DeviceReloaded += (sender, args) => PopulateColors();
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
}
@@ -55,6 +57,14 @@ namespace Artemis.Plugins.Modules.General
public override void Render(double deltaTime, RGBSurface surface, Graphics graphics)
{
_circlePosition += deltaTime * 200;
if (_circlePosition > 500)
_circlePosition = -200;
var rect = new Rectangle((int) _circlePosition * 4, 0 , 200, 200);
graphics.FillEllipse(new SolidBrush(Color.Blue), rect);
return;
// Lets do this in the least performant way possible
foreach (var surfaceLed in _surface.Leds)
{
if (!_colors.ContainsKey(surfaceLed))
@@ -6,6 +6,10 @@
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
@@ -4,5 +4,5 @@
<package id="RGB.NET.Core" version="0.1.25" targetFramework="net472" />
<package id="Stylet" version="1.1.17" targetFramework="net461" />
<package id="System.Drawing.Common" version="4.5.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>