Changed update-Pprameter away from dictionary

This commit is contained in:
DarthAffe committed 2021-03-03 23:06:22 +01:00
1 parent 9c8d67740d
commit 2222808c23
27 files changed
+133 -149

No files matched your search

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using RGB.NET.Core;
using Sanford.Multimedia.Midi;
@@ -26,10 +25,10 @@ namespace RGB.NET.Devices.Novation
#region Methods
/// <inheritdoc />
protected override ShortMessage CreateMessage(KeyValuePair<object, Color> data)
protected override ShortMessage CreateMessage(object key, in Color color)
{
(byte mode, byte id) = ((byte, byte))data.Key;
return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(data.Value)));
(byte mode, byte id) = ((byte, byte))key;
return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(color)));
}
/// <summary>
@@ -38,9 +37,9 @@ namespace RGB.NET.Devices.Novation
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
protected virtual int ConvertColor(Color color)
protected virtual int ConvertColor(in Color color)
{
(double hue, double saturation, double value) = color.GetHSV();
(double hue, double _, double value) = color.GetHSV();
if ((hue >= 330) || (hue < 30))
return (int)Math.Ceiling(value * 3); // red with brightness 1, 2 or 3
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using RGB.NET.Core;
using Sanford.Multimedia.Midi;
@@ -37,10 +36,10 @@ namespace RGB.NET.Devices.Novation
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
{
foreach (KeyValuePair<object, Color> data in dataSet)
SendMessage(CreateMessage(data));
foreach ((object key, Color color) in dataSet)
SendMessage(CreateMessage(key, color));
}
/// <summary>
@@ -59,7 +58,7 @@ namespace RGB.NET.Devices.Novation
/// </summary>
/// <param name="data">The data set to create the message from.</param>
/// <returns>The message created out of the data set.</returns>
protected abstract ShortMessage? CreateMessage(KeyValuePair<object, Color> data);
protected abstract ShortMessage? CreateMessage(object key, in Color color);
/// <inheritdoc />
public override void Dispose()
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using RGB.NET.Core;
using Sanford.Multimedia.Midi;
@@ -152,12 +151,12 @@ namespace RGB.NET.Devices.Novation
#region Methods
/// <inheritdoc />
protected override ShortMessage? CreateMessage(KeyValuePair<object, Color> data)
protected override ShortMessage? CreateMessage(object key, in Color color)
{
(byte mode, byte id) = ((byte, byte))data.Key;
(byte mode, byte id) = ((byte, byte))key;
if (mode == 0x00) return null;
return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(data.Value)));
return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(color)));
}
/// <summary>
@@ -166,7 +165,7 @@ namespace RGB.NET.Devices.Novation
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
protected virtual int ConvertColor(Color color)
protected virtual int ConvertColor(in Color color)
{
int bestVelocity = 0;
double bestMatchDistance = double.MaxValue;