mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Small refactorings
This commit is contained in:
parent
749538741c
commit
93e7e7d004
@ -34,6 +34,7 @@ namespace RGB.NET.Devices.Msi.Exceptions
|
||||
/// <param name="errorCode">The raw error code provided by the SDK.</param>
|
||||
/// <param name="description">The text-description of the error.</param>
|
||||
public MysticLightException(int errorCode, string description)
|
||||
: base($"MSI error code {errorCode} ({description})")
|
||||
{
|
||||
this.ErrorCode = errorCode;
|
||||
this.Description = description;
|
||||
|
||||
@ -7,6 +7,6 @@ namespace RGB.NET.Devices.Msi
|
||||
/// </summary>
|
||||
internal interface IMsiRGBDevice : IRGBDevice
|
||||
{
|
||||
void Initialize(MsiDeviceUpdateQueue updateQueue);
|
||||
void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,11 +46,11 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <summary>
|
||||
/// Initializes the device.
|
||||
/// </summary>
|
||||
public void Initialize(MsiDeviceUpdateQueue updateQueue)
|
||||
public void Initialize(MsiDeviceUpdateQueue updateQueue, int ledCount)
|
||||
{
|
||||
DeviceUpdateQueue = updateQueue;
|
||||
|
||||
InitializeLayout();
|
||||
InitializeLayout(ledCount);
|
||||
|
||||
if (Size == Size.Invalid)
|
||||
{
|
||||
@ -62,7 +62,7 @@ namespace RGB.NET.Devices.Msi
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
||||
/// </summary>
|
||||
protected abstract void InitializeLayout();
|
||||
protected abstract void InitializeLayout(int ledCount);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
|
||||
@ -25,29 +25,19 @@ namespace RGB.NET.Devices.Msi
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
protected override void InitializeLayout(int ledCount)
|
||||
{
|
||||
// Should errors be handled?
|
||||
_MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts);
|
||||
|
||||
for (int i = 0; i < deviceTypes.Length; i++)
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
{
|
||||
// DeviceInfo.MsiDeviceType = "MSI_VGA"
|
||||
if (deviceTypes[i].Equals(DeviceInfo.MsiDeviceType))
|
||||
{
|
||||
for (int j = 0; j < ledCounts[i]; j++)
|
||||
{
|
||||
//Hex3l: Should it be configurable in order to provide style access?
|
||||
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||
const string LED_STYLE = "Steady";
|
||||
//Hex3l: Should it be configurable in order to provide style access?
|
||||
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||
const string LED_STYLE = "Steady";
|
||||
|
||||
//Hex3l: Every led is a video card adapter.
|
||||
//Hex3l: Every led is a video card adapter.
|
||||
|
||||
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, j, LED_STYLE);
|
||||
InitializeLed(LedId.GraphicsCard1 + j, new Rectangle(j * 10, 0, 10, 10));
|
||||
}
|
||||
}
|
||||
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
|
||||
InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10));
|
||||
}
|
||||
|
||||
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
|
||||
@ -58,7 +48,7 @@ namespace RGB.NET.Devices.Msi
|
||||
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.GraphicsCard1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SyncBack()
|
||||
public override void SyncBack()
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -25,27 +25,17 @@ namespace RGB.NET.Devices.Msi
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
protected override void InitializeLayout(int ledCount)
|
||||
{
|
||||
// Should errors be handled?
|
||||
_MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts);
|
||||
|
||||
for (int i = 0; i < deviceTypes.Length; i++)
|
||||
for (int i = 0; i < ledCount; i++)
|
||||
{
|
||||
// DeviceInfo.MsiDeviceType = "MSI_MB"
|
||||
if (deviceTypes[i].Equals(DeviceInfo.MsiDeviceType))
|
||||
{
|
||||
for (int j = 0; j < ledCounts[i]; j++)
|
||||
{
|
||||
//Hex3l: Should it be configurable in order to provide style access?
|
||||
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||
const string LED_STYLE = "Steady";
|
||||
//Hex3l: Should it be configurable in order to provide style access?
|
||||
//Hex3l: Sets led style to "Steady" in order to have a solid color output therefore a controllable led color
|
||||
//Hex3l: This is a string defined by the output of _MsiSDK.GetLedStyle, "Steady" should be always present
|
||||
const string LED_STYLE = "Steady";
|
||||
|
||||
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, j, LED_STYLE);
|
||||
InitializeLed(LedId.Mainboard1 + j, new Rectangle(j * 40, 0, 40, 8));
|
||||
}
|
||||
}
|
||||
_MsiSDK.SetLedStyle(DeviceInfo.MsiDeviceType, i, LED_STYLE);
|
||||
InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8));
|
||||
}
|
||||
|
||||
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
|
||||
|
||||
@ -104,31 +104,32 @@ namespace RGB.NET.Devices.Msi
|
||||
if ((errorCode = _MsiSDK.Initialize()) != 0)
|
||||
ThrowMsiError(errorCode);
|
||||
|
||||
if ((errorCode = _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] _)) != 0)
|
||||
if ((errorCode = _MsiSDK.GetDeviceInfo(out string[] deviceTypes, out int[] ledCounts)) != 0)
|
||||
ThrowMsiError(errorCode);
|
||||
|
||||
foreach (string deviceType in deviceTypes)
|
||||
for (int i = 0; i < deviceTypes.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
string deviceType = deviceTypes[i];
|
||||
int ledCount = ledCounts[i];
|
||||
|
||||
//Hex3l: MSI_MB provide access to the motherboard "leds" where a led must be intended as a led header (JRGB, JRAINBOW etc..) (Tested on MSI X570 Unify)
|
||||
if (deviceType.Equals("MSI_MB"))
|
||||
{
|
||||
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||
IMsiRGBDevice motherboard = new MsiMainboardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.Mainboard, deviceType, "Msi", "Motherboard"));
|
||||
motherboard.Initialize(updateQueue);
|
||||
motherboard.Initialize(updateQueue, ledCount);
|
||||
devices.Add(motherboard);
|
||||
}
|
||||
|
||||
|
||||
if (deviceType.Equals("MSI_VGA"))
|
||||
else if (deviceType.Equals("MSI_VGA"))
|
||||
{
|
||||
//Hex3l: Every led under MSI_VGA should be a different graphics card. Handling all the cards together seems a good way to avoid overlapping of leds
|
||||
//Hex3l: The led name is the name of the card (e.g. NVIDIA GeForce RTX 2080 Ti) we could provide it in device info.
|
||||
|
||||
MsiDeviceUpdateQueue updateQueue = new MsiDeviceUpdateQueue(UpdateTrigger, deviceType);
|
||||
IMsiRGBDevice graphicscard = new MsiGraphicsCardRGBDevice(new MsiRGBDeviceInfo(RGBDeviceType.GraphicsCard, deviceType, "Msi", "GraphicsCard"));
|
||||
graphicscard.Initialize(updateQueue);
|
||||
graphicscard.Initialize(updateQueue, ledCount);
|
||||
devices.Add(graphicscard);
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=enum/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=generic/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=graphicscard/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mainboard/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
Loading…
x
Reference in New Issue
Block a user