Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System;
|
|
using HardwareMonitorStatusWindow.Service;
|
|
using PipeMethodCalls;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HardwareMonitorStatusWindow.StatusWindow;
|
|
|
|
internal static class Data
|
|
{
|
|
private static PipeClient<IHardwareMonitorService> _pipeClient;
|
|
private static IEnumerable<Hardware> _hardware;
|
|
|
|
internal static ObservableCollection<SensorEntry> SensorEntries { get; set; }
|
|
|
|
internal static async Task LoadComputer()
|
|
{
|
|
try
|
|
{
|
|
_pipeClient = new PipeClient<IHardwareMonitorService>(new HardwarePipeSerializer(), HardwareMonitorService.PipeName);
|
|
await _pipeClient.ConnectAsync();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
internal static void RefreshComputer()
|
|
{
|
|
_hardware = _pipeClient.InvokeAsync(service => service.GetHardware()).Result;
|
|
}
|
|
|
|
internal static void CloseComputer()
|
|
{
|
|
_pipeClient.Dispose();
|
|
}
|
|
|
|
internal static IList<Hardware> ComputerHardware => _hardware.ToList();
|
|
|
|
internal static void Load()
|
|
{
|
|
SensorEntries = JsonSerializer.Deserialize<ObservableCollection<SensorEntry>>(Settings.Default.Sensors);
|
|
}
|
|
|
|
internal static void Save()
|
|
{
|
|
Settings.Default.Sensors = JsonSerializer.Serialize(SensorEntries);
|
|
Settings.Default.Save();
|
|
}
|
|
} |