Small refactorings to unify code styling

This commit is contained in:
DarthAffe committed 2018-01-14 11:57:45 +01:00
1 parent ac0350a9f8
commit efe77cedbc
10 files changed
+80 -101

No files matched your search

@@ -60,6 +60,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// <summary>
/// Gets or sets a function to get the culture for a specific device.
/// </summary>
// ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global
public Func<CultureInfo> GetCulture { get; set; } = CultureHelper.GetCurrentCulture;
#endregion
@@ -34,15 +34,15 @@ namespace RGB.NET.Devices.CoolerMaster
if (leds.Count > 0)
{
// 6 by 22 seems hard-coded but it's what the CM SDK expects regardless of keyboard size
_CoolerMasterSDK.COLOR_MATRIX matrix = new _CoolerMasterSDK.COLOR_MATRIX { KeyColor = new _CoolerMasterSDK.KEY_COLOR[6, 22] };
_CoolerMasterColorMatrix colorMatrix = new _CoolerMasterColorMatrix { KeyColor = new _CoolerMasterKeyColor[_CoolerMasterColorMatrix.ROWS, _CoolerMasterColorMatrix.COLUMNS] };
foreach (Led led in leds)
{
(int row, int column) = ((int, int))led.CustomData;
matrix.KeyColor[row, column] = new _CoolerMasterSDK.KEY_COLOR(led.Color.R, led.Color.G, led.Color.B);
colorMatrix.KeyColor[row, column] = new _CoolerMasterKeyColor(led.Color.R, led.Color.G, led.Color.B);
}
_CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex);
_CoolerMasterSDK.SetAllLedColor(matrix);
_CoolerMasterSDK.SetAllLedColor(colorMatrix);
_CoolerMasterSDK.RefreshLed(false);
}
}
@@ -15,7 +15,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// <summary>
/// Gets the <see cref="CoolerMasterPhysicalKeyboardLayout"/> of the <see cref="CoolerMasterKeyboardRGBDevice"/>.
/// </summary>
public CoolerMasterPhysicalKeyboardLayout PhysicalLayout { get; private set; }
public CoolerMasterPhysicalKeyboardLayout PhysicalLayout { get; }
/// <summary>
/// Gets the <see cref="CoolerMasterLogicalKeyboardLayout"/> of the <see cref="CoolerMasterKeyboardRGBDevice"/>.
@@ -0,0 +1,22 @@
using System.Runtime.InteropServices;
namespace RGB.NET.Devices.CoolerMaster.Native
{
// ReSharper disable once InconsistentNaming
internal struct _CoolerMasterColorMatrix
{
#region Constants
internal const int ROWS = 6;
internal const int COLUMNS = 22;
#endregion
#region Properties & Fields
[MarshalAs(UnmanagedType.ByValArray, SizeConst = ROWS * COLUMNS)]
public _CoolerMasterKeyColor[,] KeyColor;
#endregion
}
}
@@ -0,0 +1,30 @@
// ReSharper disable UnusedMethodReturnValue.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable NotAccessedField.Global
namespace RGB.NET.Devices.CoolerMaster.Native
{
// ReSharper disable once InconsistentNaming
internal struct _CoolerMasterKeyColor
{
#region Properties & Fields
public byte R;
public byte G;
public byte B;
#endregion
#region Constructors
internal _CoolerMasterKeyColor(byte r, byte g, byte b)
{
this.R = r;
this.G = g;
this.B = b;
}
#endregion
}
}
@@ -74,31 +74,6 @@ namespace RGB.NET.Devices.CoolerMaster.Native
#region SDK-METHODS
#region Structs
// ReSharper disable InconsistentNaming
internal struct KEY_COLOR
{
public byte r;
public byte g;
public byte b;
public KEY_COLOR(byte colR, byte colG, byte colB)
{
r = colR;
g = colG;
b = colB;
}
}
internal struct COLOR_MATRIX
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 132)] public KEY_COLOR[,] KeyColor;
}
// ReSharper restore InconsistentNaming
#endregion
#region Pointers
private static GetSDKVersionPointer _getSDKVersionPointer;
@@ -141,7 +116,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
private delegate bool SetAllLedColorPointer(COLOR_MATRIX colorMatrix);
private delegate bool SetAllLedColorPointer(_CoolerMasterColorMatrix colorMatrix);
#endregion
@@ -150,66 +125,42 @@ namespace RGB.NET.Devices.CoolerMaster.Native
/// <summary>
/// CM-SDK: Get SDK Dll's Version.
/// </summary>
internal static int GetSDKVersion()
{
return _getSDKVersionPointer();
}
internal static int GetSDKVersion() => _getSDKVersionPointer();
/// <summary>
/// CM-SDK: set operating device
/// </summary>
internal static void SetControlDevice(CoolerMasterDevicesIndexes devicesIndexes)
{
_setControlDevicenPointer(devicesIndexes);
}
internal static void SetControlDevice(CoolerMasterDevicesIndexes devicesIndexes) => _setControlDevicenPointer(devicesIndexes);
/// <summary>
/// CM-SDK: verify if the deviced is plugged in
/// </summary>
internal static bool IsDevicePlugged()
{
return _isDevicePlugPointer();
}
internal static bool IsDevicePlugged() => _isDevicePlugPointer();
/// <summary>
/// CM-SDK: Obtain current device layout
/// </summary>
internal static CoolerMasterPhysicalKeyboardLayout GetDeviceLayout()
{
return _getDeviceLayoutPointer();
}
internal static CoolerMasterPhysicalKeyboardLayout GetDeviceLayout() => _getDeviceLayoutPointer();
/// <summary>
/// CM-SDK: set control over device’s LED
/// </summary>
internal static bool EnableLedControl(bool value)
{
return _enableLedControlPointer(value);
}
internal static bool EnableLedControl(bool value) => _enableLedControlPointer(value);
/// <summary>
/// CM-SDK: Print out the lights setting from Buffer to LED
/// </summary>
internal static bool RefreshLed(bool autoRefresh)
{
return _refreshLedPointer(autoRefresh);
}
internal static bool RefreshLed(bool autoRefresh) => _refreshLedPointer(autoRefresh);
/// <summary>
/// CM-SDK: Set single Key LED color
/// </summary>
internal static bool SetLedColor(int row, int column, byte r, byte g, byte b)
{
return _setLedColorPointer(row, column, r, g, b);
}
internal static bool SetLedColor(int row, int column, byte r, byte g, byte b) => _setLedColorPointer(row, column, r, g, b);
/// <summary>
/// CM-SDK: Set Keyboard "every LED" color
/// </summary>
internal static bool SetAllLedColor(COLOR_MATRIX colorMatrix)
{
return _setAllLedColorPointer(colorMatrix);
}
internal static bool SetAllLedColor(_CoolerMasterColorMatrix colorMatrix) => _setAllLedColorPointer(colorMatrix);
// ReSharper restore EventExceptionNotDocumented
@@ -60,7 +60,9 @@
<Compile Include="Keyboard\CoolerMasterKeyboardRGBDeviceInfo.cs" />
<Compile Include="Keyboard\CoolerMasterKeyboardLedMappings.cs" />
<Compile Include="Mouse\CoolerMasterMouseLedMappings.cs" />
<Compile Include="Native\_CoolerMasterColorMatrix.cs" />
<Compile Include="Native\_CoolerMasterSDK.cs" />
<Compile Include="Native\_CoolerMasterKeyColor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>