Add Network (NIC) support (updated) (#52)

* [Core] Add Network (NIC) support - All credits to XiaofengdiZhu (https://github.com/XiaofengdiZhu/openhardwaremonitor/commits/EditeByXiaofengdizhu)

* [Core] NIC: Rename InternetSpeed to Throughput, drop non physical devices (like loopback), fix alltime stats for adapter
This commit is contained in:
LORDofDOOM
2018-08-26 10:51:09 +02:00
committed by Phyxion
parent f6d3338cda
commit 4ce099c5bf
17 changed files with 730 additions and 404 deletions
+37
View File
@@ -576,6 +576,8 @@ namespace OpenHardwareMonitor.GUI {
case SensorType.Data:
format = "{0:F1} GB";
break;
case SensorType.SmallData:␍ format = "{0:F0} MB";
break;
case SensorType.Factor:
format = "{0:F3}";
break;
@@ -585,6 +587,41 @@ namespace OpenHardwareMonitor.GUI {
unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
formatted = string.Format("{0:F1} °F",
UnitManager.CelsiusToFahrenheit(sensor.Value));
} else if(sensor.SensorType == SensorType.Throughput)
{
string result = "-";
switch (sensor.Name){
case "Connection Speed": {
switch (sensor.Value){
case 100000000:
result = "100Mbps";
break;
case 1000000000:
result = "1Gbps";
break;
default: {
if (sensor.Value < 1024)
result = string.Format("{0:F0} bps", sensor.Value);
else if(sensor.Value < 1048576)
result = string.Format("{0:F1} Kbps", sensor.Value / 1024);
else if(sensor.Value < 1073741824)
result = string.Format("{0:F1} Mbps", sensor.Value / 1048576);
else
result = string.Format("{0:F1} Gbps", sensor.Value / 1073741824);
}
break;
}
}
break;
default:{
if (sensor.Value < 1048576)
result = string.Format("{0:F1} KB/s", sensor.Value / 1024);
else
result = string.Format("{0:F1} MB/s", sensor.Value / 1048576);
}
break;
}
formatted = result;
} else {
formatted = string.Format(format, sensor.Value);
}