Refactoring

This commit is contained in:
DarthAffe committed 2021-02-06 17:07:41 +01:00
1 parent a0a1521658
commit 6a4ebb3d2a
37 files changed
+123 -300

No files matched your search

@@ -42,7 +42,7 @@ namespace RGB.NET.Devices.CoolerMaster
/// Indicates if the SDK is initialized and ready to use.
/// </summary>
public bool IsInitialized { get; private set; }
/// <inheritdoc />
public IEnumerable<IRGBDevice> Devices { get; private set; } = Enumerable.Empty<IRGBDevice>();
@@ -72,7 +72,7 @@ namespace RGB.NET.Devices.CoolerMaster
#region Methods
/// <inheritdoc />
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool throwExceptions = false)
{
IsInitialized = false;
@@ -140,38 +140,16 @@ namespace RGB.NET.Devices.CoolerMaster
return true;
}
/// <inheritdoc />
public void ResetDevices()
{
if (IsInitialized)
foreach (IRGBDevice device in Devices)
{
try
{
CoolerMasterRGBDeviceInfo deviceInfo = (CoolerMasterRGBDeviceInfo)device.DeviceInfo;
_CoolerMasterSDK.EnableLedControl(false, deviceInfo.DeviceIndex);
_CoolerMasterSDK.EnableLedControl(true, deviceInfo.DeviceIndex);
}
catch {/* shit happens */}
}
}
/// <inheritdoc />
public void Dispose()
{
try { UpdateTrigger?.Dispose(); }
try { UpdateTrigger.Dispose(); }
catch { /* at least we tried */ }
if (IsInitialized)
foreach (IRGBDevice device in Devices)
{
try
{
CoolerMasterRGBDeviceInfo deviceInfo = (CoolerMasterRGBDeviceInfo)device.DeviceInfo;
_CoolerMasterSDK.EnableLedControl(false, deviceInfo.DeviceIndex);
}
catch {/* shit happens */}
}
foreach (IRGBDevice device in Devices)
try { device.Dispose(); }
catch { /* at least we tried */ }
Devices = Enumerable.Empty<IRGBDevice>();
// DarthAffe 03.03.2020: Should be done but isn't possible due to an weird winodws-hook inside the sdk which corrupts the stack when unloading the dll
//try { _CoolerMasterSDK.UnloadCMSDK(); }
@@ -25,7 +25,6 @@ namespace RGB.NET.Devices.CoolerMaster
/// </summary>
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.</param>
/// <param name="physicalKeyboardLayout">The <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterPhysicalKeyboardLayout" /> of the <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using</param>
internal CoolerMasterKeyboardRGBDeviceInfo(CoolerMasterDevicesIndexes deviceIndex, CoolerMasterPhysicalKeyboardLayout physicalKeyboardLayout)
: base(RGBDeviceType.Keyboard, deviceIndex)
{