Added generic DeviceInfo to Devices

This commit is contained in:
DarthAffe committed 2017-11-26 09:37:14 +01:00
1 parent 86bc26233b
commit 67fcc8e52e
38 files changed
+210 -246

No files matched your search

@@ -0,0 +1,12 @@
using RGB.NET.Core;
namespace RGB.NET.Devices.Novation
{
/// <summary>
/// Represents a novation RGB-device.
/// </summary>
internal interface INovationRGBDevice : IRGBDevice
{
void Initialize();
}
}
@@ -12,30 +12,31 @@ namespace RGB.NET.Devices.Novation
/// <summary>
/// Represents a generic Novation-device. (launchpad).
/// </summary>
public abstract class NovationRGBDevice : AbstractRGBDevice
public abstract class NovationRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDeviceInfo>, INovationRGBDevice
where TDeviceInfo : NovationRGBDeviceInfo
{
#region Properties & Fields
private readonly OutputDevice _outputDevice;
private readonly NovationRGBDeviceInfo _deviceInfo;
private readonly TDeviceInfo _deviceInfo;
/// <inheritdoc />
/// <summary>
/// Gets information about the <see cref="T:RGB.NET.Devices.Novation.NovationRGBDevice" />.
/// </summary>
public override IRGBDeviceInfo DeviceInfo => _deviceInfo;
public override TDeviceInfo DeviceInfo => _deviceInfo;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="NovationRGBDevice"/> class.
/// Initializes a new instance of the <see cref="NovationRGBDevice{TDeviceInfo}"/> class.
/// </summary>
/// <param name="info">The generic information provided by Novation for the device.</param>
protected NovationRGBDevice(NovationRGBDeviceInfo info)
protected NovationRGBDevice(TDeviceInfo info)
{
_deviceInfo = info;
this._deviceInfo = info;
_outputDevice = new OutputDevice(info.DeviceId);
}
@@ -48,7 +49,7 @@ namespace RGB.NET.Devices.Novation
/// <summary>
/// Initializes the device.
/// </summary>
internal void Initialize()
public void Initialize()
{
InitializeLayout();
@@ -123,12 +124,12 @@ namespace RGB.NET.Devices.Novation
}
/// <summary>
/// Resets the <see cref="NovationRGBDevice"/> back top default.
/// Resets the <see cref="NovationRGBDevice{TDeviceInfo}"/> back top default.
/// </summary>
public virtual void Reset() => SendMessage(0xB0, 0, 0);
/// <summary>
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
/// <returns>The novation-representation of the <see cref="Color"/>.</returns>
@@ -146,7 +147,7 @@ namespace RGB.NET.Devices.Novation
}
/// <summary>
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
/// The conversion uses the full rgb-range.
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
@@ -158,7 +159,7 @@ namespace RGB.NET.Devices.Novation
}
/// <summary>
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice"/>.
/// Convert a <see cref="Color"/> to its novation-representation depending on the <see cref="NovationColorCapabilities"/> of the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
/// The conversion uses only a limited amount of colors (3 red, 3 yellow, 3 green).
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
@@ -178,7 +179,7 @@ namespace RGB.NET.Devices.Novation
}
/// <summary>
/// Sends a message to the <see cref="NovationRGBDevice"/>.
/// Sends a message to the <see cref="NovationRGBDevice{TDeviceInfo}"/>.
/// </summary>
/// <param name="status">The status-code of the message.</param>
/// <param name="data1">The first data-package of the message.</param>
@@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Novation
/// <summary>
/// Represents a Novation launchpad.
/// </summary>
public class NovationLaunchpadRGBDevice : NovationRGBDevice
public class NovationLaunchpadRGBDevice : NovationRGBDevice<NovationLaunchpadRGBDeviceInfo>
{
#region Properties & Fields
/// <summary>
/// Gets information about the <see cref="NovationLaunchpadRGBDevice"/>.
/// </summary>
public NovationLaunchpadRGBDeviceInfo LaunchpadDeviceInfo { get; }
#endregion
#region Constructors
/// <inheritdoc />
@@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Novation
/// <param name="info">The specific information provided by Novation for the launchpad</param>
internal NovationLaunchpadRGBDevice(NovationLaunchpadRGBDeviceInfo info)
: base(info)
{
this.LaunchpadDeviceInfo = info;
}
{ }
#endregion
@@ -54,7 +43,7 @@ namespace RGB.NET.Devices.Novation
InitializeLed(new NovationLedId(this, ledId), rectangle);
}
string model = LaunchpadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
$@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads"));
}
@@ -79,7 +79,7 @@ namespace RGB.NET.Devices.Novation
if (deviceId == null) continue;
NovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
device.Initialize();
devices.Add(device);
}
@@ -59,6 +59,7 @@
<Compile Include="Generic\NovationRGBDeviceInfo.cs" />
<Compile Include="Helper\EnumExtension.cs" />
<Compile Include="Helper\NovationLedIdsExtension.cs" />
<Compile Include="Generic\INovationRGBDevice.cs" />
<Compile Include="Launchpad\NovationLaunchpadRGBDevice.cs" />
<Compile Include="Launchpad\NovationLaunchpadRGBDeviceInfo.cs" />
<Compile Include="NovationDeviceProvider.cs" />