diff --git a/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs b/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs index ff18fad84..6ba64ab61 100644 --- a/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs +++ b/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs @@ -18,9 +18,12 @@ private static void SetupEvents() public static void SessionListChanged() { - SBMI.PlayingSession = SBMI.SessionManager.CurrentSession; - SetupEvents(); - SetCurrentSession(); + if (SBMI.SessionManager != null) + { + SBMI.PlayingSession = SBMI.SessionManager.CurrentSession; + SetupEvents(); + SetCurrentSession(); + } } private static void SetCurrentSession() diff --git a/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs b/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs index 4c3df6c92..0c153c3f5 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs @@ -1,5 +1,9 @@ -using SBMI = Sucrose.Backgroundog.Manage.Internal; +using System.Diagnostics; +using SBEL = Sucrose.Backgroundog.Extension.Lifecycle; +using SBMI = Sucrose.Backgroundog.Manage.Internal; +using SMR = Sucrose.Memory.Readonly; using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHM = Sucrose.Shared.Space.Helper.Management; namespace Sucrose.Backgroundog.Helper { @@ -20,6 +24,11 @@ public static async Task Start() await Task.Delay(TimeSpan.FromSeconds(IntervalSeconds)); } + Process.GetProcesses() + .Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName)) + .ToList() + .ForEach(Process => SBEL.Resume(Process)); + SBMI.Exit = false; SBMI.Initialize.Stop(); diff --git a/src/Project/Sucrose.Backgroundog/Helper/Condition.cs b/src/Project/Sucrose.Backgroundog/Helper/Condition.cs index 4759fc2ac..f1569def0 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Condition.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Condition.cs @@ -1,14 +1,17 @@ using Skylark.Enum; using Skylark.Standard.Extension.Storage; +using System.Diagnostics; using SBEL = Sucrose.Backgroundog.Extension.Lifecycle; using SBMI = Sucrose.Backgroundog.Manage.Internal; using SBMM = Sucrose.Backgroundog.Manage.Manager; using SMMM = Sucrose.Manager.Manage.Manager; +using SMR = Sucrose.Memory.Readonly; using SSDECPT = Sucrose.Shared.Dependency.Enum.CategoryPerformanceType; using SSDENPT = Sucrose.Shared.Dependency.Enum.NetworkPerformanceType; using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType; using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHM = Sucrose.Shared.Space.Helper.Management; using SSSHP = Sucrose.Shared.Space.Helper.Processor; namespace Sucrose.Backgroundog.Helper @@ -70,6 +73,14 @@ private static void Lifecycle() if (SBMI.Live != null && !SBMI.Live.HasExited) { SBEL.Resume(SBMI.Live); + + if (SMR.WebViewLive.Contains(SBMI.Live.ProcessName) || SMR.CefSharpLive.Contains(SBMI.Live.ProcessName)) + { + Process.GetProcesses() + .Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName)) + .ToList() + .ForEach(Process => SBEL.Resume(Process)); + } } if (!string.IsNullOrEmpty(SMMM.App)) diff --git a/src/Project/Sucrose.Backgroundog/Helper/Performance.cs b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs index f541330f2..8e536cd7b 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Performance.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs @@ -1,14 +1,17 @@ using Skylark.Enum; using Skylark.Standard.Extension.Storage; +using System.Diagnostics; using SBEL = Sucrose.Backgroundog.Extension.Lifecycle; using SBMI = Sucrose.Backgroundog.Manage.Internal; using SBMM = Sucrose.Backgroundog.Manage.Manager; using SMMM = Sucrose.Manager.Manage.Manager; +using SMR = Sucrose.Memory.Readonly; using SSDECPT = Sucrose.Shared.Dependency.Enum.CategoryPerformanceType; using SSDENPT = Sucrose.Shared.Dependency.Enum.NetworkPerformanceType; using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType; using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHM = Sucrose.Shared.Space.Helper.Management; using SSSHP = Sucrose.Shared.Space.Helper.Processor; namespace Sucrose.Backgroundog.Helper @@ -60,6 +63,14 @@ private static void Lifecycle() if (SBMI.Live != null && !SBMI.Live.HasExited) { SBEL.Suspend(SBMI.Live); + + if (SMR.WebViewLive.Contains(SBMI.Live.ProcessName) || SMR.CefSharpLive.Contains(SBMI.Live.ProcessName)) + { + Process.GetProcesses() + .Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName)) + .ToList() + .ForEach(Process => SBEL.Suspend(Process)); + } } if (!string.IsNullOrEmpty(SMMM.App)) diff --git a/src/Project/Sucrose.Backgroundog/Helper/Specification.cs b/src/Project/Sucrose.Backgroundog/Helper/Specification.cs index 536f86615..e9b52eda6 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Specification.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Specification.cs @@ -12,6 +12,7 @@ using SMMM = Sucrose.Manager.Manage.Manager; using SSDSHHS = Sucrose.Shared.Dependency.Struct.Host.HostStruct; using SSSHN = Sucrose.Shared.Space.Helper.Network; +using SSWW = Sucrose.Shared.Watchdog.Watch; using SWUP = Skylark.Wing.Utility.Power; using SystemInformation = System.Windows.Forms.SystemInformation; @@ -25,305 +26,370 @@ public static async Task Start() { _ = Task.Run(() => { - if (SBMI.CpuManagement) + try { - SBMI.CpuManagement = false; + if (SBMI.CpuManagement) + { + SBMI.CpuManagement = false; - ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_Processor"); + ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_Processor"); - foreach (ManagementObject Object in Searcher.Get().Cast()) - { - SBMI.CpuData.State = true; - SBMI.CpuData.Core = Convert.ToInt32(Object["NumberOfCores"]); - SBMI.CpuData.Fullname = Object["Name"].ToString().TrimStart().TrimEnd(); - SBMI.CpuData.Thread = Convert.ToInt32(Object["NumberOfLogicalProcessors"]); - break; + foreach (ManagementObject Object in Searcher.Get().Cast()) + { + SBMI.CpuData.State = true; + SBMI.CpuData.Core = Convert.ToInt32(Object["NumberOfCores"]); + SBMI.CpuData.Fullname = Object["Name"].ToString().TrimStart().TrimEnd(); + SBMI.CpuData.Thread = Convert.ToInt32(Object["NumberOfLogicalProcessors"]); + break; + } } } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - if (SBMI.BiosManagement) + try { - SBMI.BiosManagement = false; + if (SBMI.BiosManagement) + { + SBMI.BiosManagement = false; - ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_BIOS"); + ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_BIOS"); - foreach (ManagementObject Object in Searcher.Get().Cast()) - { - SBMI.BiosData.State = true; - SBMI.BiosData.Name = Object["Name"].ToString(); - SBMI.BiosData.Caption = Object["Caption"].ToString(); - SBMI.BiosData.Version = Object["Version"].ToString(); - SBMI.BiosData.Description = Object["Description"].ToString(); - SBMI.BiosData.ReleaseDate = Object["ReleaseDate"].ToString(); - SBMI.BiosData.Manufacturer = Object["Manufacturer"].ToString(); - SBMI.BiosData.SerialNumber = Object["SerialNumber"].ToString(); - SBMI.BiosData.CurrentLanguage = Object["CurrentLanguage"].ToString(); - - break; + foreach (ManagementObject Object in Searcher.Get().Cast()) + { + SBMI.BiosData.State = true; + SBMI.BiosData.Name = Object["Name"].ToString(); + SBMI.BiosData.Caption = Object["Caption"].ToString(); + SBMI.BiosData.Version = Object["Version"].ToString(); + SBMI.BiosData.Description = Object["Description"].ToString(); + SBMI.BiosData.ReleaseDate = Object["ReleaseDate"].ToString(); + SBMI.BiosData.Manufacturer = Object["Manufacturer"].ToString(); + SBMI.BiosData.SerialNumber = Object["SerialNumber"].ToString(); + SBMI.BiosData.CurrentLanguage = Object["CurrentLanguage"].ToString(); + + break; + } } } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - DateTime Date = DateTime.Now; + try + { + DateTime Date = DateTime.Now; - SBMI.DateData = new() + SBMI.DateData = new() + { + State = true, + Day = Date.Day, + Hour = Date.Hour, + Year = Date.Year, + Month = Date.Month, + Minute = Date.Minute, + Second = Date.Second, + Millisecond = Date.Millisecond + }; + } + catch (Exception Exception) { - State = true, - Day = Date.Day, - Hour = Date.Hour, - Year = Date.Year, - Month = Date.Month, - Minute = Date.Minute, - Second = Date.Second, - Millisecond = Date.Millisecond - }; + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - if (SBMI.AudioManagement) + try { - SBMI.AudioManagement = false; + if (SBMI.AudioManagement) + { + SBMI.AudioManagement = false; - SBMI.SessionManager.SessionListChanged += (s, e) => SBEAS.SessionListChanged(); - } + SBMI.SessionManager = new(); + + SBMI.SessionManager.SessionListChanged += (s, e) => SBEAS.SessionListChanged(); + } - SBEAS.SessionListChanged(); + SBEAS.SessionListChanged(); + } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - SBMI.BatteryData.ACPowerStatus = $"{SWUP.GetACPowerStatus()}"; - SBMI.BatteryData.SavingMode = SWUP.IsBatterySavingMode; - SBMI.BatteryData.SaverStatus = $"{SWUP.GetBatterySaverStatus()}"; - - SBMI.BatteryData.LifePercent = SystemInformation.PowerStatus.BatteryLifePercent; - SBMI.BatteryData.PowerLineStatus = SystemInformation.PowerStatus.PowerLineStatus; - SBMI.BatteryData.FullLifetime = SystemInformation.PowerStatus.BatteryFullLifetime; - SBMI.BatteryData.ChargeStatus = SystemInformation.PowerStatus.BatteryChargeStatus; - SBMI.BatteryData.LifeRemaining = SystemInformation.PowerStatus.BatteryLifeRemaining; + try + { + SBMI.BatteryData.ACPowerStatus = $"{SWUP.GetACPowerStatus()}"; + SBMI.BatteryData.SavingMode = SWUP.IsBatterySavingMode; + SBMI.BatteryData.SaverStatus = $"{SWUP.GetBatterySaverStatus()}"; + + SBMI.BatteryData.LifePercent = SystemInformation.PowerStatus.BatteryLifePercent; + SBMI.BatteryData.PowerLineStatus = SystemInformation.PowerStatus.PowerLineStatus; + SBMI.BatteryData.FullLifetime = SystemInformation.PowerStatus.BatteryFullLifetime; + SBMI.BatteryData.ChargeStatus = SystemInformation.PowerStatus.BatteryChargeStatus; + SBMI.BatteryData.LifeRemaining = SystemInformation.PowerStatus.BatteryLifeRemaining; + } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - if (SSSHN.GetHostEntry()) + try { - List Hosts = SSSHN.GetHost(); - - foreach (SSDSHHS Host in Hosts) + if (SSSHN.GetHostEntry()) { - if (SMMM.PingType == Host.Name) + List Hosts = SSSHN.GetHost(); + + foreach (SSDSHHS Host in Hosts) { - SBMI.NetworkData.PingData = PingExtension.Send(Host.Address, 1000); - SBMI.NetworkData.Ping = SBMI.NetworkData.PingData.RoundTrip; - break; + if (SMMM.PingType == Host.Name) + { + SBMI.NetworkData.PingData = PingExtension.Send(Host.Address, 1000); + SBMI.NetworkData.Ping = SBMI.NetworkData.PingData.RoundTrip; + break; + } } } + else + { + SBMI.NetworkData.Ping = 0; + SBMI.NetworkData.PingData = new(); + } } - else + catch (Exception Exception) { - SBMI.NetworkData.Ping = 0; - SBMI.NetworkData.PingData = new(); + SSWW.Watch_CatchException(Exception); } }); _ = Task.Run(() => { - string[] Interfaces = SSSHN.InstanceNetworkInterfaces(); + try + { + string[] Interfaces = SSSHN.InstanceNetworkInterfaces(); - SMMI.SystemSettingManager.SetSetting(SMC.NetworkInterfaces, Interfaces); + SMMI.SystemSettingManager.SetSetting(SMC.NetworkInterfaces, Interfaces); - if (Interfaces.Contains(SMMM.NetworkAdapter)) - { - foreach (string Name in Interfaces) + if (Interfaces.Contains(SMMM.NetworkAdapter)) { - if (SMMM.NetworkAdapter == Name) + foreach (string Name in Interfaces) { - if (SMMM.NetworkAdapter != SBMI.NetworkData.Name) + if (SMMM.NetworkAdapter == Name) { - SBMI.NetworkData.State = true; - SBMI.NetworkData.Name = SMMM.NetworkAdapter; + if (SMMM.NetworkAdapter != SBMI.NetworkData.Name) + { + SBMI.NetworkData.State = true; + SBMI.NetworkData.Name = SMMM.NetworkAdapter; - SBMI.UploadCounter = new("Network Interface", "Bytes Sent/sec", Name); - SBMI.DownloadCounter = new("Network Interface", "Bytes Received/sec", Name); - } + SBMI.UploadCounter = new("Network Interface", "Bytes Sent/sec", Name); + SBMI.DownloadCounter = new("Network Interface", "Bytes Received/sec", Name); + } - SBMI.NetworkData.Upload = SBMI.UploadCounter.NextValue(); - SBMI.NetworkData.Download = SBMI.DownloadCounter.NextValue(); + SBMI.NetworkData.Upload = SBMI.UploadCounter.NextValue(); + SBMI.NetworkData.Download = SBMI.DownloadCounter.NextValue(); - SBMI.NetworkData.UploadData = StorageExtension.AutoConvert(SBMI.NetworkData.Upload, StorageType.Byte, ModeStorageType.Palila); - SBMI.NetworkData.DownloadData = StorageExtension.AutoConvert(SBMI.NetworkData.Download, StorageType.Byte, ModeStorageType.Palila); + SBMI.NetworkData.UploadData = StorageExtension.AutoConvert(SBMI.NetworkData.Upload, StorageType.Byte, ModeStorageType.Palila); + SBMI.NetworkData.DownloadData = StorageExtension.AutoConvert(SBMI.NetworkData.Download, StorageType.Byte, ModeStorageType.Palila); - SBMI.NetworkData.FormatUploadData = Numeric.Numeral(SBMI.NetworkData.UploadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.UploadData.Text; - SBMI.NetworkData.FormatDownloadData = Numeric.Numeral(SBMI.NetworkData.DownloadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.DownloadData.Text; + SBMI.NetworkData.FormatUploadData = Numeric.Numeral(SBMI.NetworkData.UploadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.UploadData.Text; + SBMI.NetworkData.FormatDownloadData = Numeric.Numeral(SBMI.NetworkData.DownloadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.DownloadData.Text; - break; + break; + } } } + else + { + SBMI.NetworkData.State = false; + SBMI.NetworkData.Name = SMMM.NetworkAdapter; + } } - else + catch (Exception Exception) { - SBMI.NetworkData.State = false; - SBMI.NetworkData.Name = SMMM.NetworkAdapter; + SSWW.Watch_CatchException(Exception); } }); _ = Task.Run(() => { - if (SBMI.MotherboardManagement) + try { - SBMI.MotherboardManagement = false; + if (SBMI.MotherboardManagement) + { + SBMI.MotherboardManagement = false; - ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_BaseBoard"); + ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_BaseBoard"); - foreach (ManagementObject Object in Searcher.Get().Cast()) - { - SBMI.MotherboardData.State = true; - SBMI.MotherboardData.Product = Object["Product"].ToString(); - SBMI.MotherboardData.Version = Object["Version"].ToString(); - SBMI.MotherboardData.Manufacturer = Object["Manufacturer"].ToString(); + foreach (ManagementObject Object in Searcher.Get().Cast()) + { + SBMI.MotherboardData.State = true; + SBMI.MotherboardData.Product = Object["Product"].ToString(); + SBMI.MotherboardData.Version = Object["Version"].ToString(); + SBMI.MotherboardData.Manufacturer = Object["Manufacturer"].ToString(); - break; + break; + } } } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); _ = Task.Run(() => { - SBMI.Computer.Accept(new SBEUV()); - - foreach (IHardware Hardware in SBMI.Computer.Hardware) + try { - if (Hardware.HardwareType == HardwareType.Cpu) - { - Hardware.Update(); + SBMI.Computer.Accept(new SBEUV()); - foreach (ISensor Sensor in Hardware.Sensors) - { - if (Sensor.SensorType == SensorType.Load && Sensor.Name == "CPU Total") - { - SBMI.CpuData.State = true; - SBMI.CpuData.Min = Sensor.Min; - SBMI.CpuData.Max = Sensor.Max; - SBMI.CpuData.Now = Sensor.Value; - SBMI.CpuData.Name = Hardware.Name; - - break; - } - } - } - else if (Hardware.HardwareType == HardwareType.Memory) + foreach (IHardware Hardware in SBMI.Computer.Hardware) { - Hardware.Update(); - - SBMI.MemoryData.State = true; - SBMI.MemoryData.Name = Hardware.Name; - - foreach (ISensor Sensor in Hardware.Sensors) + if (Hardware.HardwareType == HardwareType.Cpu) { - switch (Sensor.Name) + Hardware.Update(); + + foreach (ISensor Sensor in Hardware.Sensors) { - case "Memory Used" when Sensor.SensorType == SensorType.Data: - SBMI.MemoryData.MemoryUsed = Sensor.Value; - break; - case "Memory Available" when Sensor.SensorType == SensorType.Data: - SBMI.MemoryData.MemoryAvailable = Sensor.Value; - break; - case "Memory" when Sensor.SensorType == SensorType.Load: - SBMI.MemoryData.MemoryLoad = Sensor.Value; - break; - case "Virtual Memory Used" when Sensor.SensorType == SensorType.Data: - SBMI.MemoryData.VirtualMemoryUsed = Sensor.Value; - break; - case "Virtual Memory Available" when Sensor.SensorType == SensorType.Data: - SBMI.MemoryData.VirtualMemoryAvailable = Sensor.Value; - break; - case "Virtual Memory" when Sensor.SensorType == SensorType.Load: - SBMI.MemoryData.VirtualMemoryLoad = Sensor.Value; - break; - default: + if (Sensor.SensorType == SensorType.Load && Sensor.Name == "CPU Total") + { + SBMI.CpuData.State = true; + SBMI.CpuData.Min = Sensor.Min; + SBMI.CpuData.Max = Sensor.Max; + SBMI.CpuData.Now = Sensor.Value; + SBMI.CpuData.Name = Hardware.Name; + break; + } } } - } - else if (Hardware.HardwareType == HardwareType.Battery) - { - Hardware.Update(); - - if (Hardware.Sensors.Any()) + else if (Hardware.HardwareType == HardwareType.Memory) { - SBMI.BatteryData.State = true; - SBMI.BatteryData.Name = Hardware.Name; + Hardware.Update(); + + SBMI.MemoryData.State = true; + SBMI.MemoryData.Name = Hardware.Name; foreach (ISensor Sensor in Hardware.Sensors) { switch (Sensor.Name) { - case "Charge Level" when Sensor.SensorType == SensorType.Level: - SBMI.BatteryData.ChargeLevel = Sensor.Value; - break; - case "Discharge Level" when Sensor.SensorType == SensorType.Level: - SBMI.BatteryData.DischargeLevel = Sensor.Value; - break; - case "Voltage" when Sensor.SensorType == SensorType.Voltage: - SBMI.BatteryData.Voltage = Sensor.Value; - break; - case "Charge Current" when Sensor.SensorType == SensorType.Current: - SBMI.BatteryData.ChargeCurrent = Sensor.Value; - break; - case "Discharge Current" when Sensor.SensorType == SensorType.Current: - SBMI.BatteryData.DischargeCurrent = Sensor.Value; + case "Memory Used" when Sensor.SensorType == SensorType.Data: + SBMI.MemoryData.MemoryUsed = Sensor.Value; break; - case "Charge / Discharge Current" when Sensor.SensorType == SensorType.Current: - SBMI.BatteryData.ChargeDischargeCurrent = Sensor.Value; + case "Memory Available" when Sensor.SensorType == SensorType.Data: + SBMI.MemoryData.MemoryAvailable = Sensor.Value; break; - case "Designed Capacity" when Sensor.SensorType == SensorType.Energy: - SBMI.BatteryData.DesignedCapacity = Sensor.Value; + case "Memory" when Sensor.SensorType == SensorType.Load: + SBMI.MemoryData.MemoryLoad = Sensor.Value; break; - case "Full Charged Capacity" when Sensor.SensorType == SensorType.Energy: - SBMI.BatteryData.FullChargedCapacity = Sensor.Value; + case "Virtual Memory Used" when Sensor.SensorType == SensorType.Data: + SBMI.MemoryData.VirtualMemoryUsed = Sensor.Value; break; - case "Remaining Capacity" when Sensor.SensorType == SensorType.Energy: - SBMI.BatteryData.RemainingCapacity = Sensor.Value; + case "Virtual Memory Available" when Sensor.SensorType == SensorType.Data: + SBMI.MemoryData.VirtualMemoryAvailable = Sensor.Value; break; - case "Charge Rate" when Sensor.SensorType == SensorType.Power: - SBMI.BatteryData.ChargeRate = Sensor.Value; - break; - case "Discharge Rate" when Sensor.SensorType == SensorType.Power: - SBMI.BatteryData.DischargeRate = Sensor.Value; - break; - case "Charge / Discharge Rate" when Sensor.SensorType == SensorType.Power: - SBMI.BatteryData.ChargeDischargeRate = Sensor.Value; - break; - case "Degradation Level" when Sensor.SensorType == SensorType.Level: - SBMI.BatteryData.DegradationLevel = Sensor.Value; - break; - case "Remaining Time (Estimated)" when Sensor.SensorType == SensorType.TimeSpan: - SBMI.BatteryData.RemainingTimeEstimated = Sensor.Value; + case "Virtual Memory" when Sensor.SensorType == SensorType.Load: + SBMI.MemoryData.VirtualMemoryLoad = Sensor.Value; break; default: break; } } } - else + else if (Hardware.HardwareType == HardwareType.Battery) { - SBMI.BatteryData.State = false; + Hardware.Update(); + + if (Hardware.Sensors.Any()) + { + SBMI.BatteryData.State = true; + SBMI.BatteryData.Name = Hardware.Name; + + foreach (ISensor Sensor in Hardware.Sensors) + { + switch (Sensor.Name) + { + case "Charge Level" when Sensor.SensorType == SensorType.Level: + SBMI.BatteryData.ChargeLevel = Sensor.Value; + break; + case "Discharge Level" when Sensor.SensorType == SensorType.Level: + SBMI.BatteryData.DischargeLevel = Sensor.Value; + break; + case "Voltage" when Sensor.SensorType == SensorType.Voltage: + SBMI.BatteryData.Voltage = Sensor.Value; + break; + case "Charge Current" when Sensor.SensorType == SensorType.Current: + SBMI.BatteryData.ChargeCurrent = Sensor.Value; + break; + case "Discharge Current" when Sensor.SensorType == SensorType.Current: + SBMI.BatteryData.DischargeCurrent = Sensor.Value; + break; + case "Charge / Discharge Current" when Sensor.SensorType == SensorType.Current: + SBMI.BatteryData.ChargeDischargeCurrent = Sensor.Value; + break; + case "Designed Capacity" when Sensor.SensorType == SensorType.Energy: + SBMI.BatteryData.DesignedCapacity = Sensor.Value; + break; + case "Full Charged Capacity" when Sensor.SensorType == SensorType.Energy: + SBMI.BatteryData.FullChargedCapacity = Sensor.Value; + break; + case "Remaining Capacity" when Sensor.SensorType == SensorType.Energy: + SBMI.BatteryData.RemainingCapacity = Sensor.Value; + break; + case "Charge Rate" when Sensor.SensorType == SensorType.Power: + SBMI.BatteryData.ChargeRate = Sensor.Value; + break; + case "Discharge Rate" when Sensor.SensorType == SensorType.Power: + SBMI.BatteryData.DischargeRate = Sensor.Value; + break; + case "Charge / Discharge Rate" when Sensor.SensorType == SensorType.Power: + SBMI.BatteryData.ChargeDischargeRate = Sensor.Value; + break; + case "Degradation Level" when Sensor.SensorType == SensorType.Level: + SBMI.BatteryData.DegradationLevel = Sensor.Value; + break; + case "Remaining Time (Estimated)" when Sensor.SensorType == SensorType.TimeSpan: + SBMI.BatteryData.RemainingTimeEstimated = Sensor.Value; + break; + default: + break; + } + } + } + else + { + SBMI.BatteryData.State = false; + } } - } - else if (Hardware.HardwareType == HardwareType.Motherboard) - { - Hardware.Update(); + else if (Hardware.HardwareType == HardwareType.Motherboard) + { + Hardware.Update(); - SBMI.MotherboardData.State = true; - SBMI.MotherboardData.Name = Hardware.Name; + SBMI.MotherboardData.State = true; + SBMI.MotherboardData.Name = Hardware.Name; + } } } + catch (Exception Exception) + { + SSWW.Watch_CatchException(Exception); + } }); //_ = Task.Run(() => diff --git a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs index eda973f33..a8e2c74cf 100644 --- a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs +++ b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs @@ -63,7 +63,7 @@ internal static class Internal public static readonly int THREAD_SUSPEND_RESUME = 0x0002; - public static NowPlayingSessionManager SessionManager = new(); + public static NowPlayingSessionManager SessionManager = null; public static SBSDCS CpuData = new() { diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Management.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Management.cs index d73101c2e..e6315cba9 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Management.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/Helper/Management.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using SMR = Sucrose.Memory.Readonly; using SSECSMI = Sucrose.Shared.Engine.CefSharp.Manage.Internal; -using SSEHM = Sucrose.Shared.Engine.Helper.Management; +using SSSHM = Sucrose.Shared.Space.Helper.Management; namespace Sucrose.Shared.Engine.CefSharp.Helper { @@ -10,7 +10,7 @@ internal static class Management public static void SetProcesses() { Process.GetProcesses() - .Where(Process => Process.ProcessName.Contains(SMR.CefSharpProcessName) && SSEHM.GetCommandLine(Process).Contains(SMR.AppName) && !SSECSMI.Processes.Contains(Process.Id)) + .Where(Process => Process.ProcessName.Contains(SMR.CefSharpProcessName) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName) && !SSECSMI.Processes.Contains(Process.Id)) .ToList() .ForEach(Process => SSECSMI.Processes.Add(Process.Id)); } diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Management.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Management.cs index 230cdad41..dcbcbd053 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Management.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/Helper/Management.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using SMR = Sucrose.Memory.Readonly; -using SSEHM = Sucrose.Shared.Engine.Helper.Management; using SSEWVMI = Sucrose.Shared.Engine.WebView.Manage.Internal; +using SSSHM = Sucrose.Shared.Space.Helper.Management; namespace Sucrose.Shared.Engine.WebView.Helper { @@ -10,7 +10,7 @@ internal static class Management public static void SetProcesses() { Process.GetProcesses() - .Where(Process => Process.ProcessName.Contains(SMR.WebViewProcessName) && SSEHM.GetCommandLine(Process).Contains(SMR.AppName) && !SSEWVMI.Processes.Contains(Process.Id)) + .Where(Process => Process.ProcessName.Contains(SMR.WebViewProcessName) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName) && !SSEWVMI.Processes.Contains(Process.Id)) .ToList() .ForEach(Process => SSEWVMI.Processes.Add(Process.Id)); } diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Manager.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Manager.cs index b0cca991a..857f11ccf 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Manager.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Manage/Manager.cs @@ -3,13 +3,13 @@ using SEEST = Skylark.Enum.ExpandScreenType; using SEST = Skylark.Enum.ScreenType; using SEWTT = Skylark.Enum.WindowsThemeType; +using SHS = Skylark.Helper.Skymath; using SMC = Sucrose.Memory.Constant; using SMMI = Sucrose.Manager.Manage.Internal; using SMR = Sucrose.Memory.Readonly; using SSDEDT = Sucrose.Shared.Dependency.Enum.DisplayType; using SSDEST = Sucrose.Shared.Dependency.Enum.StretchType; using SWHWT = Skylark.Wing.Helper.WindowsTheme; -using SHS = Skylark.Helper.Skymath; namespace Sucrose.Shared.Engine.Manage { diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems index 54452dc9e..eaa77b1ab 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems @@ -14,7 +14,6 @@ - diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Management.cs b/src/Shared/Sucrose.Shared.Space/Helper/Management.cs similarity index 94% rename from src/Shared/Engine/Sucrose.Shared.Engine/Helper/Management.cs rename to src/Shared/Sucrose.Shared.Space/Helper/Management.cs index a2f5dea59..5b964ed9d 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Management.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Management.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Management; -namespace Sucrose.Shared.Engine.Helper +namespace Sucrose.Shared.Space.Helper { internal static class Management { diff --git a/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems b/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems index e639f3540..91ad0c12d 100644 --- a/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems +++ b/src/Shared/Sucrose.Shared.Space/Sucrose.Shared.Space.projitems @@ -11,6 +11,7 @@ +