Update editorconfig + changes (#771)

This commit is contained in:
PhyxionNL
2022-06-29 19:38:57 +02:00
committed by GitHub
parent 47f33f91d9
commit 38b97e10d0
68 changed files with 1530 additions and 2287 deletions
@@ -48,23 +48,23 @@ namespace LibreHardwareMonitor.Hardware.Memory
{
try
{
var memoryInfo = File.ReadAllLines("/proc/meminfo");
string[] memoryInfo = File.ReadAllLines("/proc/meminfo");
{
var totalMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("MemTotal:"))) / 1024.0f / 1024.0f;
var freeMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("MemFree:"))) / 1024.0f / 1024.0f;
var cachedMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("Cached:"))) / 1024.0f / 1024.0f;
float totalMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("MemTotal:"))) / 1024.0f / 1024.0f;
float freeMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("MemFree:"))) / 1024.0f / 1024.0f;
float cachedMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("Cached:"))) / 1024.0f / 1024.0f;
var usedMemory_GB = totalMemory_GB - freeMemory_GB - cachedMemory_GB;
float usedMemory_GB = totalMemory_GB - freeMemory_GB - cachedMemory_GB;
_physicalMemoryUsed.Value = usedMemory_GB;
_physicalMemoryAvailable.Value = totalMemory_GB;
_physicalMemoryLoad.Value = 100.0f * (usedMemory_GB / totalMemory_GB);
}
{
var totalSwapMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("SwapTotal"))) / 1024.0f / 1024.0f;
var freeSwapMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("SwapFree"))) / 1024.0f / 1024.0f;
var usedSwapMemory_GB = totalSwapMemory_GB - freeSwapMemory_GB;
float totalSwapMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("SwapTotal"))) / 1024.0f / 1024.0f;
float freeSwapMemory_GB = GetMemInfoValue(memoryInfo.First(entry => entry.StartsWith("SwapFree"))) / 1024.0f / 1024.0f;
float usedSwapMemory_GB = totalSwapMemory_GB - freeSwapMemory_GB;
_virtualMemoryUsed.Value = usedSwapMemory_GB;
_virtualMemoryAvailable.Value = totalSwapMemory_GB;
@@ -87,8 +87,8 @@ namespace LibreHardwareMonitor.Hardware.Memory
{
// Example: "MemTotal: 32849676 kB"
var valueWithUnit = line.Split(':').Skip(1).First().Trim();
var valueAsString = valueWithUnit.Split(' ').First();
string valueWithUnit = line.Split(':').Skip(1).First().Trim();
string valueAsString = valueWithUnit.Split(' ').First();
return long.Parse(valueAsString);
}
@@ -46,19 +46,18 @@ namespace LibreHardwareMonitor.Hardware.Memory
public override void Update()
{
Kernel32.MEMORYSTATUSEX status = new Kernel32.MEMORYSTATUSEX { dwLength = (uint)Marshal.SizeOf<Kernel32.MEMORYSTATUSEX>() };
Kernel32.MEMORYSTATUSEX status = new() { dwLength = (uint)Marshal.SizeOf<Kernel32.MEMORYSTATUSEX>() };
if (!Kernel32.GlobalMemoryStatusEx(ref status))
return;
_physicalMemoryUsed.Value = (float)(status.ullTotalPhys - status.ullAvailPhys) / (1024 * 1024 * 1024);
_physicalMemoryAvailable.Value = (float)status.ullAvailPhys / (1024 * 1024 * 1024);
_physicalMemoryLoad.Value = 100.0f - (100.0f * status.ullAvailPhys) / status.ullTotalPhys;
_physicalMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPhys) / status.ullTotalPhys);
_virtualMemoryUsed.Value = (float)(status.ullTotalPageFile - status.ullAvailPageFile) / (1024 * 1024 * 1024);
_virtualMemoryAvailable.Value = (float)status.ullAvailPageFile / (1024 * 1024 * 1024);
_virtualMemoryLoad.Value = 100.0f - (100.0f * status.ullAvailPageFile) / status.ullTotalPageFile;
_virtualMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPageFile) / status.ullTotalPageFile);
}
}
}