Reference local build of RGB.NET

Rewrote UI LED-rendering, performance needs some work
This commit is contained in:
SpoinkyNL committed 2019-08-19 22:03:37 +02:00
1 parent f0db2d7942
commit b3e035cfb3
20 files changed
+169 -132

No files matched your search

+11 -4
View File
@@ -73,17 +73,22 @@
<Reference Include="Ninject.Extensions.Factory, Version=3.3.2.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="RGB.NET.Brushes, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RGB.NET.Brushes.0.1.25\lib\net45\RGB.NET.Brushes.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Brushes.dll</HintPath>
</Reference>
<Reference Include="RGB.NET.Core, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RGB.NET.Core.0.1.25\lib\net45\RGB.NET.Core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Core.dll</HintPath>
</Reference>
<Reference Include="RGB.NET.Decorators, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RGB.NET.Decorators.0.1.25\lib\net45\RGB.NET.Decorators.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Decorators.dll</HintPath>
</Reference>
<Reference Include="RGB.NET.Groups, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RGB.NET.Groups.0.1.25\lib\net45\RGB.NET.Groups.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Groups.dll</HintPath>
</Reference>
<Reference Include="Stylet, Version=1.1.22.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Stylet.1.1.22\lib\net45\Stylet.dll</HintPath>
@@ -108,6 +113,8 @@
<Compile Include="Constants.cs" />
<Compile Include="Events\DeviceEventArgs.cs" />
<Compile Include="Exceptions\ArtemisCoreException.cs" />
<Compile Include="Extensions\RgbColorExtensions.cs" />
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
<Compile Include="Models\DataModelDescription.cs" />
<Compile Include="Ninject\PluginSettingsProvider.cs" />
<Compile Include="Plugins\Abstract\ModuleDataModel.cs" />
@@ -0,0 +1,14 @@
using RGB.NET.Core;
using Color = System.Windows.Media.Color;
namespace Artemis.Core.Extensions
{
public static class RgbColorExtensions
{
public static Color ToMediaColor(this global::RGB.NET.Core.Color color)
{
var (_, r, g, b) = color.GetRGBBytes();
return Color.FromRgb(r, g, b);
}
}
}
@@ -0,0 +1,12 @@
using System.Drawing;
namespace Artemis.Core.Extensions
{
public static class RgbRectangleExtensions
{
public static Rectangle ToDrawingRectangle(this global::RGB.NET.Core.Rectangle rectangle)
{
return new Rectangle((int) rectangle.X, (int) rectangle.Y, (int) rectangle.Width, (int) rectangle.Height);
}
}
}
@@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Linq;
using RGB.NET.Core;
using RGB.NET.Groups;
@@ -21,7 +22,8 @@ namespace Artemis.Core.RGB.NET
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color)
{
var pixel = _bitmap.GetPixel((int) (renderTarget.Rectangle.X + renderTarget.Rectangle.Width / 2), (int) (renderTarget.Rectangle.Y + renderTarget.Rectangle.Height / 2));
var point = renderTarget.Point;
var pixel = _bitmap.GetPixel((int) point.X, (int) point.Y);
return new Color(pixel.A, pixel.R, pixel.G, pixel.B);
}
+24 -21
View File
@@ -38,30 +38,33 @@ namespace Artemis.Core.Services
public RGBSurface Surface { get; set; }
public GraphicsDecorator GraphicsDecorator { get; private set; }
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
{
Surface.LoadDevices(deviceProvider);
Surface.AlignDevices();
Surface.LoadDevices(deviceProvider);
Surface.AlignDevices();
lock (_loadedDevices)
{
foreach (var surfaceDevice in deviceProvider.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
if (deviceProvider.Devices == null)
return;
// 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);
lock (_loadedDevices)
{
foreach (var surfaceDevice in deviceProvider.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
// 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()
@@ -91,7 +94,7 @@ namespace Artemis.Core.Services
{
DeviceReloaded?.Invoke(this, e);
}
#endregion
}
}
-4
View File
@@ -7,10 +7,6 @@
<package id="Ninject.Extensions.ChildKernel" version="3.3.0" targetFramework="net461" />
<package id="Ninject.Extensions.Conventions" version="3.3.0" targetFramework="net461" />
<package id="Ninject.Extensions.Factory" version="3.3.2" targetFramework="net461" />
<package id="RGB.NET.Brushes" version="0.1.25" targetFramework="net472" />
<package id="RGB.NET.Core" version="0.1.25" targetFramework="net472" />
<package id="RGB.NET.Decorators" version="0.1.25" targetFramework="net472" />
<package id="RGB.NET.Groups" version="0.1.25" targetFramework="net472" />
<package id="Stylet" version="1.1.22" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.5.1" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />