mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 13:06:24 +00:00
Fixed warnings
This commit is contained in:
1 parent
57dc9afb32
commit
a0a1521658
118 files changed
+802
-1181
No files matched your search
@@ -47,9 +47,9 @@ namespace RGB.NET.Devices.Novation
|
||||
/// Sends the specified message to the device this queue is performing updates for.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to send.</param>
|
||||
protected virtual void SendMessage(ShortMessage message)
|
||||
protected virtual void SendMessage(ShortMessage? message)
|
||||
{
|
||||
if (message != null)
|
||||
if (message != null)
|
||||
_outputDevice.SendShort(message.Message);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,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(KeyValuePair<object, Color> data);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace RGB.NET.Devices.Novation
|
||||
/// The <see cref="MidiUpdateQueue"/> used to update this <see cref="NovationRGBDevice{TDeviceInfo}"/>.
|
||||
/// </summary>
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
protected MidiUpdateQueue UpdateQueue { get; set; }
|
||||
protected MidiUpdateQueue? UpdateQueue { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace RGB.NET.Devices.Novation
|
||||
|
||||
if (Size == Size.Invalid)
|
||||
{
|
||||
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||
Rectangle ledRectangle = new(this.Select(x => x.LedRectangle));
|
||||
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||
}
|
||||
|
||||
@@ -71,12 +71,12 @@ namespace RGB.NET.Devices.Novation
|
||||
protected abstract void InitializeLayout();
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue?.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
|
||||
/// <summary>
|
||||
/// Resets the <see cref="NovationRGBDevice{TDeviceInfo}"/> back to default.
|
||||
/// </summary>
|
||||
public virtual void Reset() => UpdateQueue.Reset();
|
||||
public virtual void Reset() => UpdateQueue?.Reset();
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose" />
|
||||
/// <inheritdoc cref="AbstractRGBDevice{TDeviceInfo}.Dispose" />
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace RGB.NET.Devices.Novation
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override ShortMessage CreateMessage(KeyValuePair<object, Color> data)
|
||||
protected override ShortMessage? CreateMessage(KeyValuePair<object, Color> data)
|
||||
{
|
||||
(byte mode, byte id) = ((byte, byte))data.Key;
|
||||
if (mode == 0x00) return null;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Novation
|
||||
/// </summary>
|
||||
/// <param name="source">The enum value to get the description from.</param>
|
||||
/// <returns>The value of the <see cref="DeviceIdAttribute"/> of the source.</returns>
|
||||
internal static string GetDeviceId(this Enum source) => source.GetAttribute<DeviceIdAttribute>()?.Id;
|
||||
internal static string? GetDeviceId(this Enum source) => source.GetAttribute<DeviceIdAttribute>()?.Id;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the <see cref="ColorCapabilityAttribute"/>.
|
||||
@@ -36,10 +36,11 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <param name="source">The enum value to get the attribute from</param>
|
||||
/// <typeparam name="T">The generic attribute type</typeparam>
|
||||
/// <returns>The <see cref="Attribute"/>.</returns>
|
||||
private static T GetAttribute<T>(this Enum source)
|
||||
private static T? GetAttribute<T>(this Enum source)
|
||||
where T : Attribute
|
||||
{
|
||||
FieldInfo fi = source.GetType().GetField(source.ToString());
|
||||
FieldInfo? fi = source.GetType().GetField(source.ToString());
|
||||
if (fi == null) return null;
|
||||
T[] attributes = (T[])fi.GetCustomAttributes(typeof(T), false);
|
||||
return attributes.Length > 0 ? attributes[0] : null;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
internal static class LaunchpadIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> LEGACY = new Dictionary<LedId, (byte mode, byte id, int x, int y)>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> LEGACY = new()
|
||||
{
|
||||
{ LedId.Invalid, (0x00, 0xFF, 8, 0) },
|
||||
|
||||
{ LedId.LedMatrix1, (0x90, 0x00, 0, 1) },
|
||||
@@ -93,8 +93,8 @@ namespace RGB.NET.Devices.Novation
|
||||
{ LedId.Custom16, (0x90, 0x78, 8, 8) }, //Scene8
|
||||
};
|
||||
|
||||
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> CURRENT = new Dictionary<LedId, (byte mode, byte id, int x, int y)>
|
||||
{
|
||||
internal static readonly Dictionary<LedId, (byte mode, byte id, int x, int y)> CURRENT = new()
|
||||
{
|
||||
{ LedId.Invalid, (0x00, 0xFF, 8, 0) },
|
||||
|
||||
{ LedId.LedMatrix1, (0x90, 81, 0, 1) },
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private static NovationDeviceProvider _instance;
|
||||
private static NovationDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="NovationDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
@@ -31,18 +31,12 @@ namespace RGB.NET.Devices.Novation
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Gets whether the application has exclusive access to the SDK or not.
|
||||
/// </summary>
|
||||
public bool HasExclusiveAccess => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; }
|
||||
public IEnumerable<IRGBDevice> Devices { get; private set; } = Enumerable.Empty<IRGBDevice>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeviceUpdateTrigger"/> used to trigger the updates for novation devices.
|
||||
/// </summary>
|
||||
public DeviceUpdateTrigger UpdateTrigger { get; private set; }
|
||||
public DeviceUpdateTrigger UpdateTrigger { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,7 +65,7 @@ namespace RGB.NET.Devices.Novation
|
||||
|
||||
try
|
||||
{
|
||||
UpdateTrigger?.Stop();
|
||||
UpdateTrigger.Stop();
|
||||
|
||||
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||
|
||||
@@ -85,7 +79,7 @@ namespace RGB.NET.Devices.Novation
|
||||
|
||||
NovationDevices? deviceId = (NovationDevices?)Enum.GetValues(typeof(NovationDevices))
|
||||
.Cast<Enum>()
|
||||
.FirstOrDefault(x => x.GetDeviceId().ToUpperInvariant().Contains(outCaps.name.ToUpperInvariant()));
|
||||
.FirstOrDefault(x => x.GetDeviceId()?.ToUpperInvariant().Contains(outCaps.name.ToUpperInvariant()) ?? false);
|
||||
|
||||
if (deviceId == null) continue;
|
||||
|
||||
@@ -99,7 +93,7 @@ namespace RGB.NET.Devices.Novation
|
||||
catch { if (throwExceptions) throw; }
|
||||
}
|
||||
|
||||
UpdateTrigger?.Start();
|
||||
UpdateTrigger.Start();
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||
IsInitialized = true;
|
||||
}
|
||||
@@ -118,7 +112,7 @@ namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
foreach (IRGBDevice device in Devices)
|
||||
{
|
||||
NovationLaunchpadRGBDevice novationDevice = device as NovationLaunchpadRGBDevice;
|
||||
NovationLaunchpadRGBDevice? novationDevice = device as NovationLaunchpadRGBDevice;
|
||||
novationDevice?.Reset();
|
||||
}
|
||||
}
|
||||
@@ -126,7 +120,7 @@ namespace RGB.NET.Devices.Novation
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
try { UpdateTrigger?.Dispose(); }
|
||||
try { UpdateTrigger.Dispose(); }
|
||||
catch { /* at least we tried */ }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user