Skip to content

Commit

Permalink
Major 2.0.0 update:
Browse files Browse the repository at this point in the history
- code refactoring
- much more information
  • Loading branch information
ProgrammerLP committed Apr 19, 2024
1 parent 767e4c1 commit 67bbe1f
Show file tree
Hide file tree
Showing 25 changed files with 554 additions and 157 deletions.
8 changes: 7 additions & 1 deletion PLP-SystemInfo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PLP-SystemInfo", "PLP-SystemInfo\PLP-SystemInfo.csproj", "{193C7457-B4BA-4120-9400-5F501F6573A0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PLP-SystemInfo", "PLP-SystemInfo\PLP-SystemInfo.csproj", "{193C7457-B4BA-4120-9400-5F501F6573A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PLP_SystemInfoTest", "PLP_SystemInfoTest\PLP_SystemInfoTest.csproj", "{67F6C47C-DFE3-45D9-9537-FE8433451496}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{193C7457-B4BA-4120-9400-5F501F6573A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{193C7457-B4BA-4120-9400-5F501F6573A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{193C7457-B4BA-4120-9400-5F501F6573A0}.Release|Any CPU.Build.0 = Release|Any CPU
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67F6C47C-DFE3-45D9-9537-FE8433451496}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 13 additions & 0 deletions PLP-SystemInfo/Collections/GraphicsCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PLP_SystemInfo.Models;
using System.Collections.ObjectModel;

namespace PLP_SystemInfo.Collections
{
public class GraphicsCollection : Collection<GraphicsCard>
{
public override string ToString()
{
return base.ToString() + " : " + this.Count + " items";
}
}
}
13 changes: 13 additions & 0 deletions PLP-SystemInfo/Collections/ProcessorCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PLP_SystemInfo.Models;
using System.Collections.ObjectModel;

namespace PLP_SystemInfo.Collections
{
public class ProcessorCollection : Collection<Processor>
{
public override string ToString()
{
return base.ToString() + " : " + this.Count + " items";
}
}
}
13 changes: 13 additions & 0 deletions PLP-SystemInfo/Collections/RamCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PLP_SystemInfo.Models;
using System.Collections.ObjectModel;

namespace PLP_SystemInfo.Collections
{
public class RamCollection : Collection<RAM>
{
public override string ToString()
{
return base.ToString() + " : " + this.Count + " items";
}
}
}
151 changes: 0 additions & 151 deletions PLP-SystemInfo/ComponentInfo.cs

This file was deleted.

41 changes: 41 additions & 0 deletions PLP-SystemInfo/ComponentInfo/BoardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using PLP_SystemInfo.Models;
using System.Management;

namespace PLP_SystemInfo.ComponentInfo
{
public class BoardInfo
{
//Motherboard
public static Board GetMotherboard()
{
string manufacturer = "";
string model = "";

ManagementClass mgc = new ManagementClass("Win32_BaseBoard");
foreach (ManagementObject o in mgc.GetInstances())
{
manufacturer = o["Manufacturer"].ToString();
model = o["Product"].ToString();
}

return new Board(manufacturer, model);
}

public static BIOS GetBIOSInfo()
{
string manufacturer = "";
string versionName = "";
string version = "";

ManagementClass mc = new ManagementClass("Win32_BIOS");
foreach (ManagementObject o in mc.GetInstances())
{
versionName = o["Name"].ToString();
version = o["SystemBiosMajorVersion"].ToString() + "." + o["SystemBiosMinorVersion"].ToString();
manufacturer = o["Manufacturer"].ToString();
}

return new BIOS(manufacturer, versionName, version);
}
}
}
31 changes: 31 additions & 0 deletions PLP-SystemInfo/ComponentInfo/GraphicsInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using PLP_SystemInfo.Collections;
using System;
using System.Management;

namespace PLP_SystemInfo.ComponentInfo
{
public class GraphicsInfo
{
//Graphics
public static GraphicsCollection GetGraphicscardInfo()
{
GraphicsCollection graphics = new GraphicsCollection();

try
{
ManagementClass c = new ManagementClass("Win32_VideoController");
foreach (ManagementObject o in c.GetInstances())
{
graphics.Add(new Models.GraphicsCard(o["Name"].ToString(), o["DriverVersion"].ToString()));
}

}
catch (Exception e)
{
Console.WriteLine("An error occurred while querying for WMI data: " + e.Message);
}

return graphics;
}
}
}
28 changes: 28 additions & 0 deletions PLP-SystemInfo/ComponentInfo/OSInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Management;

namespace PLP_SystemInfo.ComponentInfo
{
public class OSInfo
{
public static string GetOperatingSystemInfo()
{
string osa = "";
string osv = "";

ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_OperatingSystem");
foreach (ManagementObject managementObject in mos.Get())
{
if (managementObject["Caption"] != null)
{
osv = managementObject["Caption"].ToString();
}
if (managementObject["OSArchitecture"] != null)
{
osa = managementObject["OSArchitecture"].ToString();
}
}

return $"{osv} ({osa})";
}
}
}
73 changes: 73 additions & 0 deletions PLP-SystemInfo/ComponentInfo/ProcessorInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using PLP_SystemInfo.Collections;
using System;
using System.Collections.ObjectModel;
using System.Management;

namespace PLP_SystemInfo.ComponentInfo
{
public class ProcessorInfo
{
//Processor
static string GetProcessorArchitecture(int i)
{
switch (i)
{
case 0:
return "x86";
case 1:
return "MIPS";
case 2:
return "Alpha";
case 3:
return "PowerPC";
case 5:
return "ARM";
case 6:
return "ia64";
case 9:
return "x64";
case 12:
return "ARM64";
default: return "unknown";
}
}

static Collection<double> GetCacheSize()
{
Collection<double> result = new Collection<double>();

ManagementClass mgmtc = new ManagementClass("Win32_CacheMemory");
foreach (ManagementObject o in mgmtc.GetInstances())
{
double max = double.Parse(o["MaxCacheSize"].ToString()) / 1024d;
result.Add(max);
}

return result;
}

public static ProcessorCollection GetProcessors()
{
ProcessorCollection processors = new ProcessorCollection();
Collection<double> result = GetCacheSize();

int i = -1;
foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get())
{
i++;
processors.Add(new Models.Processor(
item["Name"].ToString(),
GetProcessorArchitecture(int.Parse(item["Architecture"].ToString())),
Environment.ProcessorCount,
int.Parse(item["NumberOfCores"].ToString()),
double.Parse(item["L2CacheSize"].ToString()) / 1024d,
double.Parse(item["L3CacheSize"].ToString()) / 1024d,
result[i],
double.Parse(item["CurrentClockSpeed"].ToString()) / 1000d,
double.Parse(item["MaxClockSpeed"].ToString()) / 1000d));
}

return processors;
}
}
}
Loading

0 comments on commit 67bbe1f

Please sign in to comment.