diff --git a/anbs_cp/Classes/OsInfo.cs b/anbs_cp/Classes/OsInfo.cs new file mode 100644 index 0000000..adbc3eb --- /dev/null +++ b/anbs_cp/Classes/OsInfo.cs @@ -0,0 +1,340 @@ +using System.Management; +using System.Net.NetworkInformation; +using System.Net.Sockets; + +using anbs_cp.Classes.OsInfos; +using anbs_cp.Enums; +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes; + +/// +/// Информация о системе +/// +public static class OsInfo +{ + /// + /// Конструктор + /// + static OsInfo () + { + Windows = GetWindowsInfo(); + Processors = GetProcessors(); + RAM = GetRAMs(); + Videos = GetVideoAdapterInfos(); + Drives = GetDriveInfos(); + Net = GetNet(); + } + + /// + /// Информация о Windows + /// + public static IOsWindowsInfo Windows { get; } + + /// + /// Список с информацией о процессоре(-ах) + /// + public static List Processors { get; } + + /// + /// Количество оперативной памяти в байтах + /// + public static ulong RAM { get; } + + /// + /// Видеоадаптеры + /// + public static List Videos { get; } + + /// + /// Диски + /// + public static List Drives { get; set; } + + public static List Net { get; set; } + + #region Служебные методы + /// + /// Получает информацию о Windows + /// + /// + private static IOsWindowsInfo GetWindowsInfo () => + new OsWindowsInfo + { + Version = Environment.OSVersion.ToString(), + Is64 = Environment.Is64BitOperatingSystem, + PcName = Environment.MachineName, + WindowsFolder = Environment.SystemDirectory + }; + + /// + /// Получение процессоров + /// + /// Список информации о процессорах + private static List GetProcessors () + { + //Создаю результирующий список + List processorsList = new(); + + //Создаю классы менеджмента + ManagementClass management = new("Win32_Processor"); + ManagementObjectCollection collection = management.GetInstances(); + + //Получаю число процессоров + int processorsCount = collection.Cast() + .Select(static a => a.Properties["ProcessorId"].Value.ToString()).Count(); + + //Перебираю массив данных + for (int ind = 0; ind < processorsCount; ind++) + { + //Создаю элемент информации о процессоре + OsProcessorInfo processor = new() + { + Caption = collection.Cast() + .Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind), + Description = collection.Cast() + .Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind), + DeviceId = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind), + Manufacturer = collection.Cast() + .Select(static a => a.Properties["Manufacturer"].Value.ToString()).ElementAtOrDefault(ind), + MaxClockSpeed = TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["MaxClockSpeed"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"), + Name = collection.Cast() + .Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind), + NumberOfCores = TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["NumberOfCores"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"), + NumberOfLogicalProcessors = TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["NumberOfLogicalProcessors"].Value.ToString()).ElementAtOrDefault(ind) ?? "0") + }; + + //Добавляю в список + processorsList.Add(processor); + } + + //Возвращаю список + return processorsList; + } + + /// + /// Получение общее количество оперативной памяти + /// + /// Список информации о количестве оперативной памяти + private static ulong GetRAMs () + { + //Создаю классы менеджмента + ManagementClass management = new("Win32_ComputerSystem"); + ManagementObjectCollection collection = management.GetInstances(); + + //Получаю результат + return TypeConverter.StrToUInt64(collection.Cast() + .Select(static a => a.Properties["TotalPhysicalMemory"].Value.ToString()).FirstOrDefault() ?? "0"); + } + + /// + /// Получает список видеоадаптеров + /// + /// Список информации о видеоадаптерах + private static List GetVideoAdapterInfos () + { + //Создаю результирующий список + List videosList = new(); + + //Создаю классы менеджмента + ManagementClass management = new("Win32_VideoController"); + ManagementObjectCollection collection = management.GetInstances(); + + //Получаю число адаптеров + int count = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).Count(); + + //Перебираю массив данных + for (int ind = 0; ind < count; ind++) + { + //Создаю элемент информации об адаптере + OsVideoAdapterInfo adapter = new() + { + Caption = collection.Cast() + .Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind), + Description = collection.Cast() + .Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind), + DeviceId = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind), + AdapterRAM = TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["AdapterRAM"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"), + DriverDate = collection.Cast() + .Select(static a => a.Properties["DriverDate"].Value.ToString()).ElementAtOrDefault(ind), + Name = collection.Cast() + .Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind), + CurrentResolution = (TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["CurrentHorizontalResolution"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"), + TypeConverter.StrToInt(collection.Cast() + .Select(static a => a.Properties["CurrentVerticalResolution"].Value.ToString()) + .ElementAtOrDefault(ind) ?? "0")), + SystemName = collection.Cast() + .Select(static a => a.Properties["SystemName"].Value.ToString()).ElementAtOrDefault(ind), + DriverVersion = collection.Cast() + .Select(static a => a.Properties["DriverVersion"].Value.ToString()).ElementAtOrDefault(ind), + InstalledDisplayDrivers = collection.Cast() + .Select(static a => a.Properties["InstalledDisplayDrivers"].Value.ToString()).ElementAtOrDefault(ind), + VideoProcessor = collection.Cast() + .Select(static a => a.Properties["VideoProcessor"].Value.ToString()).ElementAtOrDefault(ind) + }; + + //Добавляю в список + videosList.Add(adapter); + } + + //Возвращаю список + return videosList; + } + + /// + /// Получает список дисков + /// + /// Список информации о дисках + private static List GetDriveInfos () + { + //Создаю результат + List result = new(); + + //Добавление всех HDD/SSD дисков + result.AddRange(GetHDDs()); + + //Добавление всех CD/DVD/BD дисков + result.AddRange(GetCDRom()); + + //Вывожу список + return result; + } + + /// + /// Получаю список HDD/SSD дисков + /// + /// Информация обо всех HDD/SSD дисках + private static List GetHDDs () + { + //Создаю результирующий список + List driveList = new(); + + //Создаю классы менеджмента + ManagementClass management = new("Win32_DiskDrive"); + ManagementObjectCollection collection = management.GetInstances(); + + //Получаю число адаптеров + int count = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).Count(); + + //Перебираю массив данных + for (int ind = 0; ind < count; ind++) + { + //Создаю элемент информации об адаптере + OsDriveInfo drive = new() + { + Type = EDriveType.DtHardDisc, + Caption = collection.Cast() + .Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind), + Description = collection.Cast() + .Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind), + DeviceId = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind), + Name = collection.Cast() + .Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind), + TotalSize = TypeConverter.StrToUInt64(collection.Cast() + .Select(static a => a.Properties["Size"].Value.ToString()).ElementAtOrDefault(ind) ?? "0"), + Model = collection.Cast() + .Select(static a => a.Properties["Model"].Value.ToString()).ElementAtOrDefault(ind) + }; + + //Добавляю в список + driveList.Add(drive); + } + + //Возвращаю список + return driveList; + } + + /// + /// Получаю список CD/DVD/BD дисков + /// + /// Информация обо всех CD/DVD/BD дисках + private static List GetCDRom () + { + //Создаю результирующий список + List driveList = new(); + + //Создаю классы менеджмента + ManagementClass management = new("Win32_CDROMDrive"); + ManagementObjectCollection collection = management.GetInstances(); + + //Получаю число адаптеров + int count = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).Count(); + + //Перебираю массив данных + for (int ind = 0; ind < count; ind++) + { + //Создаю элемент информации об адаптере + OsDriveInfo drive = new() + { + Type = EDriveType.DtCDRom, + Caption = collection.Cast() + .Select(static a => a.Properties["Caption"].Value.ToString()).ElementAtOrDefault(ind), + Description = collection.Cast() + .Select(static a => a.Properties["Description"].Value.ToString()).ElementAtOrDefault(ind), + DeviceId = collection.Cast() + .Select(static a => a.Properties["DeviceID"].Value.ToString()).ElementAtOrDefault(ind), + Name = collection.Cast() + .Select(static a => a.Properties["Name"].Value.ToString()).ElementAtOrDefault(ind), + //Ставится 0, чтобы не проверять корректность загрузки и читаемость диска, а также избежать удлинения получения информации + TotalSize = 0, + Model = collection.Cast() + .Select(static a => a.Properties["Manufacturer"].Value.ToString()).ElementAtOrDefault(ind) + }; + + //Добавляю в список + driveList.Add(drive); + } + + //Возвращаю список + return driveList; + } + + /// + /// Получаю информацию о сети интернет + /// + /// Информация о сети интернет + private static List GetNet () + { + //Создаю результирующий список + List netList = new(); + + //Получаю информацию о всех сетевых интерфейсах + foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces()) + { + //Создаю элемент + OsNetInfo netInfo = new() + { + Name = adapter.Name, + Description = adapter.Description, + MacAddress = adapter.OperationalStatus == OperationalStatus.Up ? adapter.GetPhysicalAddress().ToString() : null + }; + + //Получаю IP-адрес + foreach (UnicastIPAddressInformation info in adapter.GetIPProperties().UnicastAddresses.Where(static info => + info.Address.AddressFamily == AddressFamily.InterNetwork && info.IsDnsEligible)) + { + if (!string.IsNullOrWhiteSpace(netInfo.IPAddress)) + netInfo.IPAddress += ";"; + netInfo.IPAddress += info.Address.ToString(); + } + + //Добавляю адаптер + netList.Add(netInfo); + } + + //Возвращаю список + return netList; + } + #endregion +} \ No newline at end of file diff --git a/anbs_cp/Classes/OsInfos/OsDriveInfo.cs b/anbs_cp/Classes/OsInfos/OsDriveInfo.cs new file mode 100644 index 0000000..b64ef67 --- /dev/null +++ b/anbs_cp/Classes/OsInfos/OsDriveInfo.cs @@ -0,0 +1,59 @@ +using anbs_cp.Enums; +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes.OsInfos; + +/// +/// Информация о дисках +/// +public class OsDriveInfo : IOsDriveInfo +{ + /// + /// Конструктор + /// + public OsDriveInfo() + { + Type = EDriveType.DtHardDisc; + Caption = null; + Description = null; + DeviceId = null; + Name = null; + Model = null; + TotalSize = 0; + } + + /// + /// Тип диска + /// + public EDriveType Type { get; set; } + + /// + /// Заголовок + /// + public string? Caption { get; set; } + + /// + /// Описание + /// + public string? Description { get; set; } + + /// + /// Идентификатор устройства + /// + public string? DeviceId { get; set; } + + /// + /// Имя устройства + /// + public string? Name { get; set; } + + /// + /// Модель + /// + public string? Model { get; set; } + + /// + /// Общий размер + /// + public ulong TotalSize { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Classes/OsInfos/OsNetInfo.cs b/anbs_cp/Classes/OsInfos/OsNetInfo.cs new file mode 100644 index 0000000..5e0eb5f --- /dev/null +++ b/anbs_cp/Classes/OsInfos/OsNetInfo.cs @@ -0,0 +1,39 @@ +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes.OsInfos; + +/// +/// Информация об интернет-соединении +/// +public sealed class OsNetInfo: IOsNetInfo +{ + /// + /// Заголовок + /// + public string? Caption { get => Name; set => _ = value; } + + /// + /// Описание + /// + public string? Description { get; set; } + + /// + /// Идентификатор устройства + /// + public string? DeviceId { get => Name; set => _ = value; } + + /// + /// Имя устройства + /// + public string? Name { get; set; } + + /// + /// IP-адрес + /// + public string? IPAddress { get; set; } + + /// + /// MAC-адрес + /// + public string? MacAddress { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Classes/OsInfos/OsProcessorInfo.cs b/anbs_cp/Classes/OsInfos/OsProcessorInfo.cs new file mode 100644 index 0000000..b99e6af --- /dev/null +++ b/anbs_cp/Classes/OsInfos/OsProcessorInfo.cs @@ -0,0 +1,64 @@ +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes.OsInfos; + +/// +/// Класс информации о процессоре +/// +public sealed class OsProcessorInfo : IOsProcessorInfo +{ + /// + /// Конструктор + /// + public OsProcessorInfo() + { + Caption = null; + Description = null; + DeviceId = null; + Manufacturer = null; + MaxClockSpeed = 0; + Name = null; + NumberOfCores = 0; + NumberOfLogicalProcessors = 0; + } + + /// + /// Заголовок + /// + public string? Caption { get; set; } + + /// + /// Описание + /// + public string? Description { get; set; } + + /// + /// Идентификатор процессора в системе + /// + public string? DeviceId { get; set; } + + /// + /// Производитель + /// + public string? Manufacturer { get; set; } + + /// + /// Максимальная тактовая частота + /// + public int MaxClockSpeed { get; set; } + + /// + /// Имя процессора + /// + public string? Name { get; set; } + + /// + /// Число ядер + /// + public int NumberOfCores { get; set; } + + /// + /// Число потоков + /// + public int NumberOfLogicalProcessors { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Classes/OsInfos/OsVideoAdapterInfo.cs b/anbs_cp/Classes/OsInfos/OsVideoAdapterInfo.cs new file mode 100644 index 0000000..59ede17 --- /dev/null +++ b/anbs_cp/Classes/OsInfos/OsVideoAdapterInfo.cs @@ -0,0 +1,82 @@ +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes.OsInfos; + +/// +/// Информация о видеокарте +/// +internal sealed class OsVideoAdapterInfo : IOsVideoAdapterInfo +{ + /// + /// Конструктор + /// + public OsVideoAdapterInfo() + { + AdapterRAM = 0; + Caption = null; + CurrentResolution = (0, 0); + Description = null; + DeviceId = null; + DriverDate = null; + DriverVersion = null; + InstalledDisplayDrivers = null; + Name = null; + SystemName = null; + VideoProcessor = null; + } + + /// + /// Память + /// + public int AdapterRAM { get; set; } + + /// + /// Заголовок + /// + public string? Caption { get; set; } + + /// + /// Текущее разрешение + /// + public (int, int) CurrentResolution { get; set; } + + /// + /// Описание + /// + public string? Description { get; set; } + + /// + /// Идентификатор устройства + /// + public string? DeviceId { get; set; } + + /// + /// Дата установки драйвера + /// + public string? DriverDate { get; set; } + + /// + /// Версия драйвера + /// + public string? DriverVersion { get; set; } + + /// + /// Название драйверов + /// + public string? InstalledDisplayDrivers { get; set; } + + /// + /// Имя + /// + public string? Name { get; set; } + + /// + /// Имя в системе + /// + public string? SystemName { get; set; } + + /// + /// Видео процессор + /// + public string? VideoProcessor { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Classes/OsInfos/OsWindowsInfo.cs b/anbs_cp/Classes/OsInfos/OsWindowsInfo.cs new file mode 100644 index 0000000..e16e1aa --- /dev/null +++ b/anbs_cp/Classes/OsInfos/OsWindowsInfo.cs @@ -0,0 +1,62 @@ +using anbs_cp.Interfaces.OsInfos; + +namespace anbs_cp.Classes.OsInfos; + +/// +/// Информация о Windows +/// +public sealed class OsWindowsInfo : IOsWindowsInfo +{ + /// + /// Конструктор + /// + public OsWindowsInfo() + { + Version = null; + Is64 = true; + PcName = null; + WindowsFolder = null; + } + + /// + /// Версия + /// + public string? Version { get; set; } + + /// + /// 64-разрядная ОС + /// + public bool Is64 { get; set; } + + /// + /// Имя компьютера + /// + public string? PcName { get; set; } + + /// + /// Путь к папке Windows + /// + public string? WindowsFolder { get; set; } + + #region Реализация интерфейса IBasicInfo + /// + /// Заголовок + /// + public string? Caption { get => Version; set => _= value; } + + /// + /// Описание + /// + public string? Description { get => Version; set => _= value; } + + /// + /// Идентификатор + /// + public string? DeviceId { get => Version; set => _= value; } + + /// + /// Имя + /// + public string? Name { get => Version; set => _= value; } + #endregion +} \ No newline at end of file diff --git a/anbs_cp/Enums/EDriveType.cs b/anbs_cp/Enums/EDriveType.cs new file mode 100644 index 0000000..7b8c049 --- /dev/null +++ b/anbs_cp/Enums/EDriveType.cs @@ -0,0 +1,17 @@ +namespace anbs_cp.Enums; + +/// +/// Тип носителя +/// +public enum EDriveType +{ + /// + /// HDD/SSD/M2 + /// + DtHardDisc = 0, + + /// + /// Диск CD/DVD/BD + /// + DtCDRom = 1 +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsBasicInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsBasicInfo.cs new file mode 100644 index 0000000..986dffd --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsBasicInfo.cs @@ -0,0 +1,27 @@ +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Базовые параметры устройства +/// +public interface IOsBasicInfo +{ + /// + /// Заголовок + /// + public string? Caption { get; set; } + + /// + /// Описание + /// + public string? Description { get; set; } + + /// + /// Идентификатор устройства + /// + public string? DeviceId { get; set; } + + /// + /// Имя устройства + /// + public string? Name { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsDriveInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsDriveInfo.cs new file mode 100644 index 0000000..522dba6 --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsDriveInfo.cs @@ -0,0 +1,24 @@ +using anbs_cp.Enums; + +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Информация о дисках +/// +public interface IOsDriveInfo : IOsBasicInfo +{ + /// + /// Тип диска + /// + public EDriveType Type { get; set; } + + /// + /// Модель + /// + public string? Model { get; set; } + + /// + /// Общий размер + /// + public ulong TotalSize { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsNetInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsNetInfo.cs new file mode 100644 index 0000000..6efac09 --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsNetInfo.cs @@ -0,0 +1,17 @@ +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Информация об интернет-соединении +/// +public interface IOsNetInfo: IOsBasicInfo +{ + /// + /// IP-адрес + /// + public string? IPAddress { get; set; } + + /// + /// MAC-адрес + /// + public string? MacAddress { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsProcessorInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsProcessorInfo.cs new file mode 100644 index 0000000..87ddc7e --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsProcessorInfo.cs @@ -0,0 +1,31 @@ +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Информация о процессоре +/// +public interface IOsProcessorInfo : IOsBasicInfo +{ + /// + /// Заголовок + /// + + /// + /// Производитель + /// + public string? Manufacturer { get; set; } + + /// + /// Максимальная тактовая частота + /// + public int MaxClockSpeed { get; set; } + + /// + /// Число ядер + /// + public int NumberOfCores { get; set; } + + /// + /// Число потоков + /// + public int NumberOfLogicalProcessors { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsVideoAdapterInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsVideoAdapterInfo.cs new file mode 100644 index 0000000..26fced1 --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsVideoAdapterInfo.cs @@ -0,0 +1,42 @@ +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Информация о видеокарте +/// +public interface IOsVideoAdapterInfo : IOsBasicInfo +{ + /// + /// Память + /// + public int AdapterRAM { get; set; } + + /// + /// Текущее разрешение + /// + public (int, int) CurrentResolution { get; set; } + + /// + /// Дата установки драйвера + /// + public string? DriverDate { get; set; } + + /// + /// Версия драйвера + /// + public string? DriverVersion { get; set; } + + /// + /// Название драйверов + /// + public string? InstalledDisplayDrivers { get; set; } + + /// + /// Имя в системе + /// + public string? SystemName { get; set; } + + /// + /// Видео процессор + /// + public string? VideoProcessor { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/Interfaces/OsInfos/IOsWindowsInfo.cs b/anbs_cp/Interfaces/OsInfos/IOsWindowsInfo.cs new file mode 100644 index 0000000..3e3fae4 --- /dev/null +++ b/anbs_cp/Interfaces/OsInfos/IOsWindowsInfo.cs @@ -0,0 +1,27 @@ +namespace anbs_cp.Interfaces.OsInfos; + +/// +/// Информация о Windows +/// +public interface IOsWindowsInfo: IOsBasicInfo +{ + /// + /// Версия + /// + public string? Version { get; set; } + + /// + /// 64-разрядная ОС + /// + public bool Is64 { get; set; } + + /// + /// Имя компьютера + /// + public string? PcName { get; set; } + + /// + /// Путь к папке Windows + /// + public string? WindowsFolder { get; set; } +} \ No newline at end of file diff --git a/anbs_cp/anbs_cp.csproj b/anbs_cp/anbs_cp.csproj index 4033045..dc0c637 100644 --- a/anbs_cp/anbs_cp.csproj +++ b/anbs_cp/anbs_cp.csproj @@ -2,7 +2,7 @@ net7.0 - 2023.104.1 + 2023.115.0 Alexander Babaev ANB Software Components Pack Library of some useful functions in C# language. @@ -15,8 +15,8 @@ True https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack - 2023.104.1 - 2023.104.1 + 2023.115.0 + 2023.115.0 ANBSoftware.ComponentsPack MIT 6.0 @@ -40,6 +40,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -47,4 +48,8 @@ + + + + diff --git a/anbsoftware.componentspack.sln.DotSettings b/anbsoftware.componentspack.sln.DotSettings index 391c6ec..f451ee2 100644 --- a/anbsoftware.componentspack.sln.DotSettings +++ b/anbsoftware.componentspack.sln.DotSettings @@ -1,9 +1,16 @@  + CD + HD + HDD + RA + RAM True True + True True True True + True True True True diff --git a/demo/MainMenu.Designer.cs b/demo/MainMenu.Designer.cs index 133bf74..a13600a 100644 --- a/demo/MainMenu.Designer.cs +++ b/demo/MainMenu.Designer.cs @@ -31,6 +31,7 @@ sealed partial class MainMenu this.CountValueTest = new System.Windows.Forms.Button(); this.SimpleMapperTest = new System.Windows.Forms.Button(); this.FileExtensionTest = new System.Windows.Forms.Button(); + this.OsInfoBtn = new System.Windows.Forms.Button(); this.SuspendLayout(); // // CountValueTest @@ -63,11 +64,22 @@ sealed partial class MainMenu this.FileExtensionTest.UseVisualStyleBackColor = true; this.FileExtensionTest.Click += new System.EventHandler(this.FileExtensionTest_Click); // + // OsInfoBtn + // + this.OsInfoBtn.Location = new System.Drawing.Point(12, 185); + this.OsInfoBtn.Name = "OsInfoBtn"; + this.OsInfoBtn.Size = new System.Drawing.Size(335, 51); + this.OsInfoBtn.TabIndex = 3; + this.OsInfoBtn.Text = "Информация о системе"; + this.OsInfoBtn.UseVisualStyleBackColor = true; + this.OsInfoBtn.Click += new System.EventHandler(this.OsInfoBtn_Click); + // // MainMenu // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(361, 252); + this.Controls.Add(this.OsInfoBtn); this.Controls.Add(this.FileExtensionTest); this.Controls.Add(this.SimpleMapperTest); this.Controls.Add(this.CountValueTest); @@ -86,4 +98,5 @@ sealed partial class MainMenu private Button CountValueTest; private Button SimpleMapperTest; private Button FileExtensionTest; + private Button OsInfoBtn; } diff --git a/demo/MainMenu.cs b/demo/MainMenu.cs index c85a8f8..e4acabc 100644 --- a/demo/MainMenu.cs +++ b/demo/MainMenu.cs @@ -23,4 +23,10 @@ public sealed partial class MainMenu: Form FileHashAndMimeType formTest = new(); formTest.ShowDialog(); } + + private void OsInfoBtn_Click (object sender, EventArgs e) + { + OsInfoFrm formTest = new(); + formTest.ShowDialog(); + } } diff --git a/demo/OsInfoFrm.Designer.cs b/demo/OsInfoFrm.Designer.cs new file mode 100644 index 0000000..3602c5a --- /dev/null +++ b/demo/OsInfoFrm.Designer.cs @@ -0,0 +1,65 @@ +namespace demo; + +sealed partial class OsInfoFrm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.textBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox + // + this.textBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox.Location = new System.Drawing.Point(0, 0); + this.textBox.Multiline = true; + this.textBox.Name = "textBox"; + this.textBox.Size = new System.Drawing.Size(1029, 510); + this.textBox.TabIndex = 0; + // + // OsInfoFrm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1029, 510); + this.Controls.Add(this.textBox); + this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "OsInfoFrm"; + this.Text = "Информация о системе"; + this.Load += new System.EventHandler(this.OsInfoFrm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBox; +} \ No newline at end of file diff --git a/demo/OsInfoFrm.cs b/demo/OsInfoFrm.cs new file mode 100644 index 0000000..df8694b --- /dev/null +++ b/demo/OsInfoFrm.cs @@ -0,0 +1,28 @@ +using anbs_cp.Classes; + +using Newtonsoft.Json; + +namespace demo; +public sealed partial class OsInfoFrm: Form +{ + public OsInfoFrm () + { + InitializeComponent(); + } + + private void OsInfoFrm_Load (object sender, EventArgs e) + { + textBox.Text = @"Процессор(ы) | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.Processors); + textBox.Text += @"Оперативная память | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.RAM); + textBox.Text += @"Видеокарта | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.Videos); + textBox.Text += @"Диски | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.Drives); + textBox.Text += @"Windows | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.Windows); + textBox.Text += @"Net | "; + textBox.Text += JsonConvert.SerializeObject(OsInfo.Net); + } +} diff --git a/demo/OsInfoFrm.resx b/demo/OsInfoFrm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo/OsInfoFrm.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file