mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Merge pull request #335 from Aytackydln/asus-remove-system-management
Asus: Remove System.Management
This commit is contained in:
commit
a26eaf9a9a
@ -76,7 +76,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
|
|
||||||
yield return (AsusDeviceType)device.Type switch
|
yield return (AsusDeviceType)device.Type switch
|
||||||
{
|
{
|
||||||
AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name), GetUpdateTrigger()),
|
AsusDeviceType.MB_RGB => new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, "Asus Motherboard"), GetUpdateTrigger()),
|
||||||
AsusDeviceType.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()),
|
AsusDeviceType.MB_ADDRESABLE => new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1, GetUpdateTrigger()),
|
||||||
AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()),
|
AsusDeviceType.VGA_RGB => new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device), GetUpdateTrigger()),
|
||||||
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
||||||
|
|||||||
@ -1,82 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Management;
|
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Asus;
|
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
|
||||||
internal static class WMIHelper
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
private static readonly ManagementObjectSearcher? _systemModelSearcher;
|
|
||||||
private static readonly ManagementObjectSearcher? _mainboardSearcher;
|
|
||||||
private static readonly ManagementObjectSearcher? _graphicsCardSearcher;
|
|
||||||
// ReSharper restore InconsistentNaming
|
|
||||||
|
|
||||||
private static string? _systemModelInfo;
|
|
||||||
private static (string manufacturer, string model)? _mainboardInfo;
|
|
||||||
private static string? _graphicsCardInfo;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
static WMIHelper()
|
|
||||||
{
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
_systemModelSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Model FROM Win32_ComputerSystem");
|
|
||||||
_mainboardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Manufacturer,Product FROM Win32_BaseBoard");
|
|
||||||
_graphicsCardSearcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT Name FROM Win32_VideoController");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
internal static string? GetSystemModelInfo()
|
|
||||||
{
|
|
||||||
if (!OperatingSystem.IsWindows()) return null;
|
|
||||||
|
|
||||||
if ((_systemModelInfo == null) && (_systemModelSearcher != null))
|
|
||||||
foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get())
|
|
||||||
{
|
|
||||||
_systemModelInfo = managementBaseObject["Model"].ToString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _systemModelInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static (string manufacturer, string model)? GetMainboardInfo()
|
|
||||||
{
|
|
||||||
if (!OperatingSystem.IsWindows()) return null;
|
|
||||||
|
|
||||||
if (!_mainboardInfo.HasValue && (_mainboardSearcher != null))
|
|
||||||
foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get())
|
|
||||||
{
|
|
||||||
_mainboardInfo = (managementBaseObject["Manufacturer"].ToString() ?? string.Empty, managementBaseObject["Product"].ToString() ?? string.Empty);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _mainboardInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string? GetGraphicsCardsInfo()
|
|
||||||
{
|
|
||||||
if (!OperatingSystem.IsWindows()) return null;
|
|
||||||
|
|
||||||
if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null))
|
|
||||||
foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get())
|
|
||||||
{
|
|
||||||
_graphicsCardInfo = managementBaseObject["Name"].ToString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _graphicsCardInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@ -13,7 +13,6 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
|
/// The ASUS SDK returns useless names for notebook keyboards, possibly for others as well.
|
||||||
/// Keep a list of those and rely on <see cref="WMIHelper.GetSystemModelInfo()"/> to get the real model
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<string> GENERIC_DEVICE_NAMES = ["NotebookKeyboard"];
|
private static readonly List<string> GENERIC_DEVICE_NAMES = ["NotebookKeyboard"];
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDevi
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? WMIHelper.GetSystemModelInfo() : deviceName;
|
private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Keyboard" : deviceName;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -56,10 +56,6 @@
|
|||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
|
<ProjectReference Include="..\RGB.NET.Core\RGB.NET.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user