From 853e8eab0d6d9b593dc674020b3701911c866c51 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Tue, 27 Jan 2026 18:58:09 -0500 Subject: [PATCH] Initial WIP commit --- .gitea/workflows/main.yml | 36 ++ .gitignore | 398 ++++++++++++++++ HardwareMonitorStatusWindow.sln.DotSettings | 3 + HardwareMonitorStatusWindow.slnx | 7 + README.md | 1 + Service/Hardware.cs | 41 ++ Service/HardwareMonitorService.cs | 41 ++ Service/HardwarePipeSerializer.cs | 26 + Service/HardwareType.cs | 18 + Service/HardwareUpdateVisitor.cs | 25 + Service/IHardwareMonitorService.cs | 6 + Service/Program.cs | 111 +++++ Service/Sensor.cs | 49 ++ Service/SensorType.cs | 26 + Service/Service.csproj | 20 + Service/app.manifest | 17 + StatusWindow/App.config | 24 + StatusWindow/App.xaml | 7 + StatusWindow/App.xaml.cs | 37 ++ StatusWindow/AssemblyInfo.cs | 24 + StatusWindow/Data.cs | 54 +++ StatusWindow/DataErrorDictionary.cs | 42 ++ StatusWindow/Program.cs | 26 + StatusWindow/Resources.Designer.cs | 446 ++++++++++++++++++ StatusWindow/Resources.resx | 251 ++++++++++ StatusWindow/Resources/Application.ico | Bin 0 -> 67646 bytes StatusWindow/SensorEntry.cs | 133 ++++++ StatusWindow/Settings.Designer.cs | 74 +++ StatusWindow/Settings.settings | 18 + .../SettingsWindow/AboutSettingsPanel.xaml | 20 + .../SettingsWindow/AboutSettingsPanel.xaml.cs | 12 + .../SettingsWindow/GeneralSettingsPanel.xaml | 16 + .../GeneralSettingsPanel.xaml.cs | 35 ++ .../SettingsWindow/HardwareSettingsPanel.xaml | 126 +++++ .../HardwareSettingsPanel.xaml.cs | 112 +++++ .../SettingsWindow/HardwareTypeItem.cs | 10 + StatusWindow/SettingsWindow/SensorTypeItem.cs | 9 + StatusWindow/SettingsWindow/SensorWindow.xaml | 106 +++++ .../SettingsWindow/SensorWindow.xaml.cs | 98 ++++ .../SettingsWindow/UpdateSettingsPanel.xaml | 21 + .../UpdateSettingsPanel.xaml.cs | 38 ++ StatusWindow/StatusWindow.csproj | 69 +++ StatusWindow/StatusWindow.csproj.DotSettings | 2 + StatusWindow/UpdateCheck.cs | 50 ++ StatusWindow/WindowSource.cs | 235 +++++++++ 45 files changed, 2920 insertions(+) create mode 100644 .gitea/workflows/main.yml create mode 100644 .gitignore create mode 100644 HardwareMonitorStatusWindow.sln.DotSettings create mode 100644 HardwareMonitorStatusWindow.slnx create mode 100644 README.md create mode 100644 Service/Hardware.cs create mode 100644 Service/HardwareMonitorService.cs create mode 100644 Service/HardwarePipeSerializer.cs create mode 100644 Service/HardwareType.cs create mode 100644 Service/HardwareUpdateVisitor.cs create mode 100644 Service/IHardwareMonitorService.cs create mode 100644 Service/Program.cs create mode 100644 Service/Sensor.cs create mode 100644 Service/SensorType.cs create mode 100644 Service/Service.csproj create mode 100644 Service/app.manifest create mode 100644 StatusWindow/App.config create mode 100644 StatusWindow/App.xaml create mode 100644 StatusWindow/App.xaml.cs create mode 100644 StatusWindow/AssemblyInfo.cs create mode 100644 StatusWindow/Data.cs create mode 100644 StatusWindow/DataErrorDictionary.cs create mode 100644 StatusWindow/Program.cs create mode 100644 StatusWindow/Resources.Designer.cs create mode 100644 StatusWindow/Resources.resx create mode 100644 StatusWindow/Resources/Application.ico create mode 100644 StatusWindow/SensorEntry.cs create mode 100644 StatusWindow/Settings.Designer.cs create mode 100644 StatusWindow/Settings.settings create mode 100644 StatusWindow/SettingsWindow/AboutSettingsPanel.xaml create mode 100644 StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs create mode 100644 StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml create mode 100644 StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs create mode 100644 StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml create mode 100644 StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs create mode 100644 StatusWindow/SettingsWindow/HardwareTypeItem.cs create mode 100644 StatusWindow/SettingsWindow/SensorTypeItem.cs create mode 100644 StatusWindow/SettingsWindow/SensorWindow.xaml create mode 100644 StatusWindow/SettingsWindow/SensorWindow.xaml.cs create mode 100644 StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml create mode 100644 StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml.cs create mode 100644 StatusWindow/StatusWindow.csproj create mode 100644 StatusWindow/StatusWindow.csproj.DotSettings create mode 100644 StatusWindow/UpdateCheck.cs create mode 100644 StatusWindow/WindowSource.cs diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml new file mode 100644 index 0000000..ca37e80 --- /dev/null +++ b/.gitea/workflows/main.yml @@ -0,0 +1,36 @@ +name: Deploy to Gitea Releases + +on: + push: + branches: + - main + + workflow_dispatch: + +jobs: + deploy-to-gitea-releases: + runs-on: ubuntu-latest + + container: + image: ghcr.io/catthehacker/ubuntu:dotnet-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Get next version + uses: reecetech/version-increment@2024.4.3 + id: version + with: + scheme: calver + + - name: Publish Application + run: dotnet publish HardwareMonitorStatusWindow.csproj -r win-x64 -c Debug -o publish + + - name: Create Velopack Release + run: | + export PATH="$PATH:/root/.dotnet/tools" + dotnet tool install -g vpk + vpk [win] download gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow + vpk [win] pack --channel win-x64 -u HardwareMonitorStatusWindow -v ${{ steps.version.outputs.version }} -p publish --packTitle "Hardware Monitor Status Window" --shortcuts StartMenuRoot --framework net10.0-x64-desktop + vpk [win] upload gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a30d25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/HardwareMonitorStatusWindow.sln.DotSettings b/HardwareMonitorStatusWindow.sln.DotSettings new file mode 100644 index 0000000..b347252 --- /dev/null +++ b/HardwareMonitorStatusWindow.sln.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/HardwareMonitorStatusWindow.slnx b/HardwareMonitorStatusWindow.slnx new file mode 100644 index 0000000..a64e237 --- /dev/null +++ b/HardwareMonitorStatusWindow.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..bcadd84 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# HardwareMonitorStatusWindow \ No newline at end of file diff --git a/Service/Hardware.cs b/Service/Hardware.cs new file mode 100644 index 0000000..a2c8130 --- /dev/null +++ b/Service/Hardware.cs @@ -0,0 +1,41 @@ +namespace HardwareMonitorStatusWindow.Service; + +public class Hardware +{ + public required HardwareType Type { get; set; } + public required string Identifier { get; set; } + public required string Name { get; set; } + public required IEnumerable Sensors { get; set; } + + internal static Hardware Create(LibreHardwareMonitor.Hardware.IHardware hardware) + { + return new Hardware + { + Type = MapHardwareType(hardware.HardwareType), + Name = hardware.Name, + Identifier = hardware.Identifier.ToString(), + Sensors = hardware.Sensors.Select(Sensor.Create) + }; + } + + private static HardwareType MapHardwareType(LibreHardwareMonitor.Hardware.HardwareType hardwareType) + { + return hardwareType switch + { + LibreHardwareMonitor.Hardware.HardwareType.Motherboard => HardwareType.Motherboard, + LibreHardwareMonitor.Hardware.HardwareType.SuperIO => HardwareType.SuperIo, + LibreHardwareMonitor.Hardware.HardwareType.Cpu => HardwareType.Cpu, + LibreHardwareMonitor.Hardware.HardwareType.Memory => HardwareType.Memory, + LibreHardwareMonitor.Hardware.HardwareType.GpuNvidia => HardwareType.GpuNvidia, + LibreHardwareMonitor.Hardware.HardwareType.GpuAmd => HardwareType.GpuAmd, + LibreHardwareMonitor.Hardware.HardwareType.GpuIntel => HardwareType.GpuIntel, + LibreHardwareMonitor.Hardware.HardwareType.Storage => HardwareType.Storage, + LibreHardwareMonitor.Hardware.HardwareType.Network => HardwareType.Network, + LibreHardwareMonitor.Hardware.HardwareType.Cooler => HardwareType.Cooler, + LibreHardwareMonitor.Hardware.HardwareType.EmbeddedController => HardwareType.EmbeddedController, + LibreHardwareMonitor.Hardware.HardwareType.Psu => HardwareType.Psu, + LibreHardwareMonitor.Hardware.HardwareType.Battery => HardwareType.Battery, + _ => throw new ArgumentOutOfRangeException(nameof(hardwareType), hardwareType, null) + }; + } +} \ No newline at end of file diff --git a/Service/HardwareMonitorService.cs b/Service/HardwareMonitorService.cs new file mode 100644 index 0000000..6467176 --- /dev/null +++ b/Service/HardwareMonitorService.cs @@ -0,0 +1,41 @@ +using LibreHardwareMonitor.Hardware; + +namespace HardwareMonitorStatusWindow.Service; + +public class HardwareMonitorService : IHardwareMonitorService +{ + public const string ScheduledTaskName = "HardwareMonitorService"; + public const string PipeName = "HardwareMonitorService"; + + private static readonly Computer Computer; + private static readonly HardwareUpdateVisitor HardwareUpdateVisitor; + + static HardwareMonitorService() + { + Computer = new Computer + { + IsCpuEnabled = true, + IsGpuEnabled = true, + IsMemoryEnabled = true, + IsMotherboardEnabled = true, + IsControllerEnabled = true, + IsNetworkEnabled = true, + IsStorageEnabled = true, + IsBatteryEnabled = true, + IsPsuEnabled = true + }; + + Computer.Open(); + + HardwareUpdateVisitor = new HardwareUpdateVisitor(); + } + + public IEnumerable GetHardware() + { + Computer.Accept(HardwareUpdateVisitor); + + var hardwareEntries = Computer.Hardware.Select(Hardware.Create); + + return hardwareEntries; + } +} \ No newline at end of file diff --git a/Service/HardwarePipeSerializer.cs b/Service/HardwarePipeSerializer.cs new file mode 100644 index 0000000..b21840d --- /dev/null +++ b/Service/HardwarePipeSerializer.cs @@ -0,0 +1,26 @@ +using PipeMethodCalls; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace HardwareMonitorStatusWindow.Service; + +public class HardwarePipeSerializer : IPipeSerializer +{ + private static readonly JsonSerializerOptions JsonSerializerOptions = new() + { + NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals + }; + + public object? Deserialize(byte[] data, Type type) + { + return JsonSerializer.Deserialize(data, type, JsonSerializerOptions); + } + + public byte[] Serialize(object o) + { + using var memoryStream = new MemoryStream(); + using var utf8JsonWriter = new Utf8JsonWriter(memoryStream); + JsonSerializer.Serialize(utf8JsonWriter, o, JsonSerializerOptions); + return memoryStream.ToArray(); + } +} \ No newline at end of file diff --git a/Service/HardwareType.cs b/Service/HardwareType.cs new file mode 100644 index 0000000..55d294e --- /dev/null +++ b/Service/HardwareType.cs @@ -0,0 +1,18 @@ +namespace HardwareMonitorStatusWindow.Service; + +public enum HardwareType +{ + Motherboard, + SuperIo, + Cpu, + Memory, + GpuNvidia, + GpuAmd, + GpuIntel, + Storage, + Network, + Cooler, + EmbeddedController, + Psu, + Battery, +} \ No newline at end of file diff --git a/Service/HardwareUpdateVisitor.cs b/Service/HardwareUpdateVisitor.cs new file mode 100644 index 0000000..42edbbe --- /dev/null +++ b/Service/HardwareUpdateVisitor.cs @@ -0,0 +1,25 @@ +using LibreHardwareMonitor.Hardware; + +namespace HardwareMonitorStatusWindow.Service; + +internal class HardwareUpdateVisitor : IVisitor +{ + public void VisitComputer(IComputer computer) + { + computer.Traverse(this); + } + + public void VisitHardware(IHardware hardware) + { + hardware.Update(); + foreach (var subHardware in hardware.SubHardware) subHardware.Accept(this); + } + + public void VisitSensor(ISensor sensor) + { + } + + public void VisitParameter(IParameter parameter) + { + } +} \ No newline at end of file diff --git a/Service/IHardwareMonitorService.cs b/Service/IHardwareMonitorService.cs new file mode 100644 index 0000000..a4a4dda --- /dev/null +++ b/Service/IHardwareMonitorService.cs @@ -0,0 +1,6 @@ +namespace HardwareMonitorStatusWindow.Service; + +public interface IHardwareMonitorService +{ + IEnumerable GetHardware(); +} \ No newline at end of file diff --git a/Service/Program.cs b/Service/Program.cs new file mode 100644 index 0000000..7f14d7d --- /dev/null +++ b/Service/Program.cs @@ -0,0 +1,111 @@ +using System.IO.Pipes; +using System.Security.AccessControl; +using System.Security.Principal; +using Microsoft.Win32.TaskScheduler; +using PipeMethodCalls; +using Serilog; +using Task = System.Threading.Tasks.Task; + +namespace HardwareMonitorStatusWindow.Service; + +internal class Program +{ + private static async Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); + + Log.Logger.Information("Start"); + + if (args.Contains("--install", StringComparer.InvariantCultureIgnoreCase)) + { + Log.Logger.Information("Starting install..."); + + try + { + using var taskService = new TaskService(); + + var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName); + + if (existingTask == null) + { + var taskDefinition = taskService.NewTask(); + taskDefinition.Principal.RunLevel = TaskRunLevel.Highest; + + taskDefinition.Triggers.Add(new LogonTrigger { Delay = TimeSpan.FromSeconds(30) }); + taskDefinition.Actions.Add(new ExecAction(Environment.ProcessPath!)); + taskDefinition.Settings.RestartInterval = TimeSpan.FromMinutes(1); + taskDefinition.Settings.RestartCount = 3; + taskDefinition.Settings.StartWhenAvailable = true; + taskDefinition.Settings.ExecutionTimeLimit = TimeSpan.Zero; + taskDefinition.Settings.StopIfGoingOnBatteries = false; + taskDefinition.Settings.DisallowStartIfOnBatteries = false; + + taskService.RootFolder.RegisterTaskDefinition(HardwareMonitorService.ScheduledTaskName, taskDefinition); + } + + existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName); + existingTask.Run(); + } + catch (Exception exception) + { + Log.Logger.Error(exception, "Install"); + } + + Log.Logger.Information("Install complete"); + } + else if (args.Contains("--uninstall", StringComparer.InvariantCultureIgnoreCase)) + { + Log.Logger.Information("Starting uninstall..."); + + try + { + using var taskService = new TaskService(); + + var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName); + + existingTask?.Stop(); + + taskService.RootFolder.DeleteTask(HardwareMonitorService.ScheduledTaskName, false); + } + catch (Exception exception) + { + Log.Logger.Error(exception, "Uninstall"); + } + + Log.Logger.Information("Uninstall complete"); + } + else + { + Log.Logger.Information("Starting"); + + try + { + while (true) + { + var pipeSecurity = new PipeSecurity(); + pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow)); + + var pipeWithSecurity = NamedPipeServerStreamAcl.Create(HardwareMonitorService.PipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity); + + var pipeServer = new PipeServer(new HardwarePipeSerializer(), pipeWithSecurity, () => new HardwareMonitorService()); + //var pipeServer = new PipeServer( + // new HardwarePipeSerializer(), + // HardwareMonitorService.PipeName, + // () => new HardwareMonitorService()); + + await pipeServer.WaitForConnectionAsync().ConfigureAwait(false); + + await pipeServer.WaitForRemotePipeCloseAsync().ConfigureAwait(false); + + pipeServer.Dispose(); + } + } + catch (Exception exception) + { + Log.Logger.Error(exception, ""); + } + } + + Log.Logger.Information("Closing"); + } +} \ No newline at end of file diff --git a/Service/Sensor.cs b/Service/Sensor.cs new file mode 100644 index 0000000..930e579 --- /dev/null +++ b/Service/Sensor.cs @@ -0,0 +1,49 @@ +namespace HardwareMonitorStatusWindow.Service; + +public class Sensor +{ + public required SensorType Type { get; set; } + public required string Identifier { get; set; } + public required string Name { get; set; } + public required float? Value { get; set; } + + internal static Sensor Create(LibreHardwareMonitor.Hardware.ISensor sensor) + { + return new Sensor + { + Type = MapSensorType(sensor.SensorType), + Name = sensor.Name, + Identifier = sensor.Identifier.ToString(), + Value = sensor.Value + }; + } + + private static SensorType MapSensorType(LibreHardwareMonitor.Hardware.SensorType sensorType) + { + return sensorType switch + { + LibreHardwareMonitor.Hardware.SensorType.Voltage => SensorType.Voltage, + LibreHardwareMonitor.Hardware.SensorType.Current => SensorType.Current, + LibreHardwareMonitor.Hardware.SensorType.Power => SensorType.Power, + LibreHardwareMonitor.Hardware.SensorType.Clock => SensorType.Clock, + LibreHardwareMonitor.Hardware.SensorType.Temperature => SensorType.Temperature, + LibreHardwareMonitor.Hardware.SensorType.Load => SensorType.Load, + LibreHardwareMonitor.Hardware.SensorType.Frequency => SensorType.Frequency, + LibreHardwareMonitor.Hardware.SensorType.Fan => SensorType.Fan, + LibreHardwareMonitor.Hardware.SensorType.Flow => SensorType.Flow, + LibreHardwareMonitor.Hardware.SensorType.Control => SensorType.Control, + LibreHardwareMonitor.Hardware.SensorType.Level => SensorType.Level, + LibreHardwareMonitor.Hardware.SensorType.Factor => SensorType.Factor, + LibreHardwareMonitor.Hardware.SensorType.Data => SensorType.Data, + LibreHardwareMonitor.Hardware.SensorType.SmallData => SensorType.SmallData, + LibreHardwareMonitor.Hardware.SensorType.Throughput => SensorType.Throughput, + LibreHardwareMonitor.Hardware.SensorType.TimeSpan => SensorType.TimeSpan, + LibreHardwareMonitor.Hardware.SensorType.Timing => SensorType.Timing, + LibreHardwareMonitor.Hardware.SensorType.Energy => SensorType.Energy, + LibreHardwareMonitor.Hardware.SensorType.Noise => SensorType.Noise, + LibreHardwareMonitor.Hardware.SensorType.Conductivity => SensorType.Conductivity, + LibreHardwareMonitor.Hardware.SensorType.Humidity => SensorType.Humidity, + _ => throw new ArgumentOutOfRangeException(nameof(sensorType), sensorType, null) + }; + } +} \ No newline at end of file diff --git a/Service/SensorType.cs b/Service/SensorType.cs new file mode 100644 index 0000000..9cc6c08 --- /dev/null +++ b/Service/SensorType.cs @@ -0,0 +1,26 @@ +namespace HardwareMonitorStatusWindow.Service; + +public enum SensorType +{ + Voltage, + Current, + Power, + Clock, + Temperature, + Load, + Frequency, + Fan, + Flow, + Control, + Level, + Factor, + Data, + SmallData, + Throughput, + TimeSpan, + Timing, + Energy, + Noise, + Conductivity, + Humidity, +} \ No newline at end of file diff --git a/Service/Service.csproj b/Service/Service.csproj new file mode 100644 index 0000000..42be8f8 --- /dev/null +++ b/Service/Service.csproj @@ -0,0 +1,20 @@ + + + + WinExe + net10.0-windows + enable + enable + HardwareMonitorStatusWindow.Service + app.manifest + + + + + + + + + + + diff --git a/Service/app.manifest b/Service/app.manifest new file mode 100644 index 0000000..4d08f0c --- /dev/null +++ b/Service/app.manifest @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StatusWindow/App.config b/StatusWindow/App.config new file mode 100644 index 0000000..7804f4a --- /dev/null +++ b/StatusWindow/App.config @@ -0,0 +1,24 @@ + + + + +
+ + + + + + + + + True + + + True + + + [] + + + + \ No newline at end of file diff --git a/StatusWindow/App.xaml b/StatusWindow/App.xaml new file mode 100644 index 0000000..bf08da7 --- /dev/null +++ b/StatusWindow/App.xaml @@ -0,0 +1,7 @@ + + + + + diff --git a/StatusWindow/App.xaml.cs b/StatusWindow/App.xaml.cs new file mode 100644 index 0000000..503bf5e --- /dev/null +++ b/StatusWindow/App.xaml.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Windows; +using ChrisKaczor.Wpf.Windows.FloatingStatusWindow; + +namespace HardwareMonitorStatusWindow.StatusWindow; + +public partial class App +{ + private List _windowSourceList; + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + StartManager.ManageAutoStart = true; + StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart; + StartManager.AutoStartChanged += (value => + { + Settings.Default.AutoStart = value; + Settings.Default.Save(); + }); + + _windowSourceList = + [ + new WindowSource() + ]; + } + + protected override void OnExit(ExitEventArgs e) + { + _windowSourceList.ForEach(ws => ws.Dispose()); + + base.OnExit(e); + } +} \ No newline at end of file diff --git a/StatusWindow/AssemblyInfo.cs b/StatusWindow/AssemblyInfo.cs new file mode 100644 index 0000000..1618e8e --- /dev/null +++ b/StatusWindow/AssemblyInfo.cs @@ -0,0 +1,24 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using System.Windows; + +[assembly: AssemblyTitle("HardwareMonitorStatusWindow")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HardwareMonitorStatusWindow")] +[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2026")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: SupportedOSPlatform("windows7.0")] +[assembly: NeutralResourcesLanguage("en-US")] + +[assembly: ComVisible(false)] + +[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/StatusWindow/Data.cs b/StatusWindow/Data.cs new file mode 100644 index 0000000..3848542 --- /dev/null +++ b/StatusWindow/Data.cs @@ -0,0 +1,54 @@ +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 _pipeClient; + private static IEnumerable _hardware; + + internal static ObservableCollection SensorEntries { get; set; } + + internal static async Task LoadComputer() + { + try + { + _pipeClient = new PipeClient(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 ComputerHardware => _hardware.ToList(); + + internal static void Load() + { + SensorEntries = JsonSerializer.Deserialize>(Settings.Default.Sensors); + } + + internal static void Save() + { + Settings.Default.Sensors = JsonSerializer.Serialize(SensorEntries); + Settings.Default.Save(); + } +} \ No newline at end of file diff --git a/StatusWindow/DataErrorDictionary.cs b/StatusWindow/DataErrorDictionary.cs new file mode 100644 index 0000000..ed6f4d4 --- /dev/null +++ b/StatusWindow/DataErrorDictionary.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; + +namespace HardwareMonitorStatusWindow.StatusWindow; + +internal class DataErrorDictionary : Dictionary> +{ + public event EventHandler ErrorsChanged; + + private void OnErrorsChanged(string propertyName) + { + ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName)); + } + + public IEnumerable GetErrors(string propertyName) + { + return TryGetValue(propertyName, out var value) ? value : null; + } + + public void AddError(string propertyName, string error) + { + if (!ContainsKey(propertyName)) + this[propertyName] = []; + + if (this[propertyName].Contains(error)) + return; + + this[propertyName].Add(error); + OnErrorsChanged(propertyName); + } + + public void ClearErrors(string propertyName) + { + if (!ContainsKey(propertyName)) + return; + + Remove(propertyName); + OnErrorsChanged(propertyName); + } +} \ No newline at end of file diff --git a/StatusWindow/Program.cs b/StatusWindow/Program.cs new file mode 100644 index 0000000..54e75ed --- /dev/null +++ b/StatusWindow/Program.cs @@ -0,0 +1,26 @@ +using System; +using Serilog; +using Velopack; + +namespace HardwareMonitorStatusWindow.StatusWindow; + +internal class Program +{ + [STAThread] + public static void Main(string[] args) + { + Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); + + Log.Logger.Information("Start"); + + // var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger); + + VelopackApp.Build().Run(); // loggerFactory.CreateLogger("Install") + + var app = new App(); + app.InitializeComponent(); + app.Run(); + + Log.Logger.Information("End"); + } +} \ No newline at end of file diff --git a/StatusWindow/Resources.Designer.cs b/StatusWindow/Resources.Designer.cs new file mode 100644 index 0000000..0b49e09 --- /dev/null +++ b/StatusWindow/Resources.Designer.cs @@ -0,0 +1,446 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace HardwareMonitorStatusWindow.StatusWindow { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HardwareMonitorStatusWindow.StatusWindow.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Add. + /// + public static string AddSensorLink { + get { + return ResourceManager.GetString("AddSensorLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add Sensor. + /// + public static string AddSensorToolTip { + get { + return ResourceManager.GetString("AddSensorToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + public static System.Drawing.Icon ApplicationIcon { + get { + object obj = ResourceManager.GetObject("ApplicationIcon", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized string similar to Hardware Monitor Status Window. + /// + public static string ApplicationName { + get { + return ResourceManager.GetString("ApplicationName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + public static string CancelButton { + get { + return ResourceManager.GetString("CancelButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Checking for update.... + /// + public static string CheckingForUpdate { + get { + return ResourceManager.GetString("CheckingForUpdate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Check for Update. + /// + public static string CheckUpdate { + get { + return ResourceManager.GetString("CheckUpdate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Check _Now. + /// + public static string checkVersionNowButton { + get { + return ResourceManager.GetString("checkVersionNowButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Check for a new version on startup. + /// + public static string checkVersionOnStartupCheckBox { + get { + return ResourceManager.GetString("checkVersionOnStartupCheckBox", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close. + /// + public static string CloseButtonText { + get { + return ResourceManager.GetString("CloseButtonText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Are you sure you want to delete the selected sensors?. + /// + public static string ConfirmDeleteSensors { + get { + return ResourceManager.GetString("ConfirmDeleteSensors", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirm Delete. + /// + public static string ConfirmDeleteTitle { + get { + return ResourceManager.GetString("ConfirmDeleteTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + public static string DeleteSensorLink { + get { + return ResourceManager.GetString("DeleteSensorLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete Sensor. + /// + public static string DeleteSensorToolTip { + get { + return ResourceManager.GetString("DeleteSensorToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Downloading update.... + /// + public static string DownloadingUpdate { + get { + return ResourceManager.GetString("DownloadingUpdate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit. + /// + public static string EditSensorLink { + get { + return ResourceManager.GetString("EditSensorLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit Sensor. + /// + public static string EditSensorToolTip { + get { + return ResourceManager.GetString("EditSensorToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hardware. + /// + public static string HardwareColumnHeader { + get { + return ResourceManager.GetString("HardwareColumnHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hardware Type. + /// + public static string HardwareTypeWatermark { + get { + return ResourceManager.GetString("HardwareTypeWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hardware. + /// + public static string HardwareWatermark { + get { + return ResourceManager.GetString("HardwareWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Installing update.... + /// + public static string InstallingUpdate { + get { + return ResourceManager.GetString("InstallingUpdate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Label. + /// + public static string LabelColumnHeader { + get { + return ResourceManager.GetString("LabelColumnHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Loading.... + /// + public static string Loading { + get { + return ResourceManager.GetString("Loading", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OK. + /// + public static string OkayButton { + get { + return ResourceManager.GetString("OkayButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to About. + /// + public static string optionCategoryAbout { + get { + return ResourceManager.GetString("optionCategoryAbout", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to General. + /// + public static string optionCategoryGeneral { + get { + return ResourceManager.GetString("optionCategoryGeneral", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hardware. + /// + public static string optionCategoryHardware { + get { + return ResourceManager.GetString("optionCategoryHardware", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sensors. + /// + public static string optionCategorySensors { + get { + return ResourceManager.GetString("optionCategorySensors", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Update. + /// + public static string optionCategoryUpdate { + get { + return ResourceManager.GetString("optionCategoryUpdate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sensor. + /// + public static string SensorColumnHeader { + get { + return ResourceManager.GetString("SensorColumnHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sensor Type. + /// + public static string SensorTypeWatermark { + get { + return ResourceManager.GetString("SensorTypeWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sensor. + /// + public static string SensorWatermark { + get { + return ResourceManager.GetString("SensorWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add Sensor. + /// + public static string SensorWindowAdd { + get { + return ResourceManager.GetString("SensorWindowAdd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit Sensor. + /// + public static string SensorWindowEdit { + get { + return ResourceManager.GetString("SensorWindowEdit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Service not installed - restart application. + /// + public static string ServiceNotInstalled { + get { + return ResourceManager.GetString("ServiceNotInstalled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waiting for service to start.... + /// + public static string ServiceNotStarted { + get { + return ResourceManager.GetString("ServiceNotStarted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settings. + /// + public static string SettingsTitle { + get { + return ResourceManager.GetString("SettingsTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Start when Windows starts. + /// + public static string startWithWindowsCheckBox { + get { + return ResourceManager.GetString("startWithWindowsCheckBox", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You are already running the most recent version. + /// + ///No updates are available at this time.. + /// + public static string UpdateCheckCurrent { + get { + return ResourceManager.GetString("UpdateCheckCurrent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version {0} is now available. + /// + ///Would you like to download and install it now?. + /// + public static string UpdateCheckNewVersion { + get { + return ResourceManager.GetString("UpdateCheckNewVersion", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} Update. + /// + public static string UpdateCheckTitle { + get { + return ResourceManager.GetString("UpdateCheckTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version {0}. + /// + public static string Version { + get { + return ResourceManager.GetString("Version", resourceCulture); + } + } + } +} diff --git a/StatusWindow/Resources.resx b/StatusWindow/Resources.resx new file mode 100644 index 0000000..51acf95 --- /dev/null +++ b/StatusWindow/Resources.resx @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Hardware Monitor Status Window + + + About + + + _Check for Update + + + _Start when Windows starts + + + General + + + Settings + + + Close + + + Version {0} + + + Update + + + _Check for a new version on startup + + + Check _Now + + + {0} Update + + + You are already running the most recent version. + +No updates are available at this time. + + + Version {0} is now available. + +Would you like to download and install it now? + + + Loading... + + + Checking for update... + + + Downloading update... + + + Installing update... + + + Confirm Delete + + + OK + + + Cancel + + + Hardware + + + Edit + + + Delete + + + Add Sensor + + + Edit Sensor + + + Delete Sensor + + + Sensors + + + Label + + + Sensor + + + Add + + + Add Sensor + + + Edit Sensor + + + Are you sure you want to delete the selected sensors? + + + Hardware + + + Sensor + + + Sensor Type + + + Hardware + + + Hardware Type + + + + Resources\Application.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Service not installed - restart application + + + Waiting for service to start... + + \ No newline at end of file diff --git a/StatusWindow/Resources/Application.ico b/StatusWindow/Resources/Application.ico new file mode 100644 index 0000000000000000000000000000000000000000..b7d7601dd14bd8b5b5878823be84b50d709905b1 GIT binary patch literal 67646 zcmeI52Yi*)`NuB=0R;sW7h-X=iVFv_ss*)5MJw)wtB&HRqyF6!s&&;>tX5R&w#8~y zaMw{47Z6B762gW+2qR&msEFtP`=0wg$;oSO2858njh~lf1Zc_Ao(Eu|MVG1pMmrlNS}f98AzXj^chH> zf%F+jpMmrlSmQHr$RUR$x_0fF_~kEu*<5NT?bx$t&kj9$^w?3_rhE79n@S0k{@HNO zz`+L}oRFGGJ4ok>`_s~Bv7aT)7W-LJwz$94ty{Nir7r3xo2pG5bkIQ?&WYFv{}OCo zYAKyA_FqWfioFweFL8HB?45X{)nY$S+=odgb?MTjozz6y2+v;Q{*xp2t=0ZX+?PnM z8um`?ow$36`3h;|fd?M=#{&*HU^l6m)VNQ|M)K`p|Epj9Dnsq{;{MGVuy*tv7(swsO8+#RGZ3+FsrH3BWbee?OYEJPuaN$?&p!KHw)ft9?;>SL4d*0m#NQ<1e}LLK zwH)tL*?pWn{GHgN@5OzBbk|;c?bT(^J@;%WZNz7P{r~A=&K!S$w5p0YKOXC?3415* zUSj{FxED*$b?VgVm_7E`W6Rxl-#wvr{hyGH=o`RZ^Evq6x3=u@_xO4fHXqo1$li&& zm)JXLnYe!_{ufI>`}xm*-t-s0_{Byp7@@* z-f_nr=Wf6KcK7njFT0OF{@9HfGsb=R;fHS6uwm}cfBv&O`Q(%RIDwrTciPDAL-tPG zy~KRAR3!dSOMQ3Ub=S5XJ9bR$vdb4hwo(rKgS=i!yNC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8?AcX0-2;`= z?Wmk?2j%+PE2rB|*BEZ6obHy&>9$r*xAlo9p4jq~Q%=bcd(>2FD5tVfeh+a^NQX+d zOSg*qCDKLGdE$4x)KA>|NZq8aV!yAnlbCmqwwKz8HEJuhLOKyG^xh2RlQXpT!=9o> zd2Z5QI(-JxXCQqB(q|xj2GVCBeFoBJAbkeXXCQqB(q|xj1~!y4;MV!ik~S4TVo*lK z<3wU$_{5KiM91*>2PG3?$BFRxTaoA;Ji&4Ji5xeHy&itz5=eF|e}g{`zM?-4J~4UR zyX+q%kITPe^0@pHlgH(s7#){=;!Hk2ktqAbnf_2!lF^SH_l_OgC)(@wiFRzCSauwp zl(OUK6U&aHPy9GxKOOximLDfSvHUpsiRH&h48gJg#NgO}VsPxgVtC9ahR1y3phWN! zKkglSU7uLt{rbcT$NI#I#~owGEn>$Rv14Dj7<{36KbCofKN+<=ZV`Kbb;oUD@BhiM z%rpGySj*$yvG-SZJTUhDpB!WE!H=umag*5lYkQm#`}Y|xGWX~!#gALWUa#)BP3-;E z9d~pygOh=utNOTi?Dgu72gcrC-El?p#>stL;rqpo7e0AN@Zyt)-O! literal 0 HcmV?d00001 diff --git a/StatusWindow/SensorEntry.cs b/StatusWindow/SensorEntry.cs new file mode 100644 index 0000000..22b9ab3 --- /dev/null +++ b/StatusWindow/SensorEntry.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text.Json.Serialization; +using HardwareMonitorStatusWindow.Service; + +namespace HardwareMonitorStatusWindow.StatusWindow; + +public class SensorEntry : INotifyDataErrorInfo, INotifyPropertyChanged +{ + private readonly DataErrorDictionary _dataErrorDictionary; + + public SensorEntry() + { + _dataErrorDictionary = new DataErrorDictionary(); + _dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged; + } + + public string Label + { + get; + set + { + if (!ValidateLabel(value)) + return; + + SetField(ref field, value); + } + } + + public string HardwareId + { + get; + set + { + SetField(ref field, value); + OnPropertyChanged(nameof(Hardware)); + } + } + + public string SensorId + { + get; + set + { + SetField(ref field, value); + OnPropertyChanged(nameof(Sensor)); + } + } + + [JsonIgnore] + public Hardware? Hardware => Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == HardwareId); + + [JsonIgnore] + public Sensor? Sensor => Hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == SensorId); + + [JsonIgnore] + public bool HasErrors => _dataErrorDictionary.Any(); + + public IEnumerable GetErrors(string propertyName) + { + return _dataErrorDictionary.GetErrors(propertyName); + } + + public event EventHandler ErrorsChanged; + + private void DataErrorDictionaryErrorsChanged(object sender, DataErrorsChangedEventArgs e) + { + ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(e.PropertyName)); + } + + private bool ValidateLabel(string newValue) + { + _dataErrorDictionary.ClearErrors(nameof(Label)); + + if (!string.IsNullOrWhiteSpace(newValue)) + return true; + + _dataErrorDictionary.AddError(nameof(Label), "Label cannot be empty"); + + return false; + } + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + protected bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null) + { + if (EqualityComparer.Default.Equals(field, value)) return false; + field = value; + OnPropertyChanged(propertyName); + return true; + } + + public string SensorValueFormat + { + get + { + return Sensor?.Type switch + { + SensorType.Voltage => "{0:F3} V", + SensorType.Current => "{0:F3} A", + SensorType.Clock => "{0:F1} MHz", + SensorType.Load => "{0:F1} %", + SensorType.Temperature => "{0:F1} °C", + SensorType.Fan => "{0:F0} RPM", + SensorType.Flow => "{0:F1} L/h", + SensorType.Control => "{0:F1} %", + SensorType.Level => "{0:F1} %", + SensorType.Power => "{0:F1} W", + SensorType.Data => "{0:F1} GB", + SensorType.SmallData => "{0:F1} MB", + SensorType.Factor => "{0:F3}", + SensorType.Frequency => "{0:F1} Hz", + SensorType.Throughput => "{0:F1} B/s", + SensorType.TimeSpan => "{0:g}", + SensorType.Timing => "{0:F3} ns", + SensorType.Energy => "{0:F0} mWh", + SensorType.Noise => "{0:F0} dBA", + SensorType.Conductivity => "{0:F1} µS/cm", + SensorType.Humidity => "{0:F0} %", + _ => string.Empty + }; + } + } +} \ No newline at end of file diff --git a/StatusWindow/Settings.Designer.cs b/StatusWindow/Settings.Designer.cs new file mode 100644 index 0000000..1753c61 --- /dev/null +++ b/StatusWindow/Settings.Designer.cs @@ -0,0 +1,74 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace HardwareMonitorStatusWindow.StatusWindow { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string WindowSettings { + get { + return ((string)(this["WindowSettings"])); + } + set { + this["WindowSettings"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool AutoStart { + get { + return ((bool)(this["AutoStart"])); + } + set { + this["AutoStart"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CheckVersionAtStartup { + get { + return ((bool)(this["CheckVersionAtStartup"])); + } + set { + this["CheckVersionAtStartup"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("[]")] + public string Sensors { + get { + return ((string)(this["Sensors"])); + } + set { + this["Sensors"] = value; + } + } + } +} diff --git a/StatusWindow/Settings.settings b/StatusWindow/Settings.settings new file mode 100644 index 0000000..5b4ce4d --- /dev/null +++ b/StatusWindow/Settings.settings @@ -0,0 +1,18 @@ + + + + + + + + + True + + + True + + + [] + + + \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml b/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml new file mode 100644 index 0000000..a8b9e48 --- /dev/null +++ b/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs b/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs new file mode 100644 index 0000000..aae025c --- /dev/null +++ b/StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs @@ -0,0 +1,12 @@ +namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow +{ + public partial class AboutSettingsPanel + { + public AboutSettingsPanel() + { + InitializeComponent(); + } + + public override string CategoryName => StatusWindow.Resources.optionCategoryAbout; + } +} \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml b/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml new file mode 100644 index 0000000..3f91b9d --- /dev/null +++ b/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs b/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs new file mode 100644 index 0000000..4667be8 --- /dev/null +++ b/StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs @@ -0,0 +1,35 @@ +using System.Windows; +using ChrisKaczor.Wpf.Application; + +namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow; + +public partial class GeneralSettingsPanel +{ + public GeneralSettingsPanel() + { + InitializeComponent(); + } + + public override string CategoryName => StatusWindow.Resources.optionCategoryGeneral; + + public override void LoadPanel(Window parentWindow) + { + base.LoadPanel(parentWindow); + + MarkLoaded(); + } + + private void OnSaveSettings(object sender, RoutedEventArgs e) + { + SaveSettings(); + } + + private void SaveSettings() + { + if (!HasLoaded) return; + + Settings.Default.Save(); + + Application.Current.SetStartWithWindows(Settings.Default.AutoStart); + } +} \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml b/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml new file mode 100644 index 0000000..dfe9596 --- /dev/null +++ b/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs b/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs new file mode 100644 index 0000000..d5ea377 --- /dev/null +++ b/StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs @@ -0,0 +1,112 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; + +namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow; + +public partial class HardwareSettingsPanel +{ + private CollectionViewSource _collectionViewSource; + + public HardwareSettingsPanel() + { + InitializeComponent(); + } + + public override string CategoryName => StatusWindow.Resources.optionCategorySensors; + + public override void LoadPanel(Window parentWindow) + { + base.LoadPanel(parentWindow); + + if (_collectionViewSource == null) + { + _collectionViewSource = new CollectionViewSource { Source = Data.SensorEntries }; + + SensorDataGrid.ItemsSource = _collectionViewSource.View; + } + + _collectionViewSource.View.Refresh(); + + if (SensorDataGrid.Items.Count > 0) + SensorDataGrid.SelectedIndex = 0; + + SetSensorButtonStates(); + } + + private void HandleSensorDataGridSelectionChanged(object sender, SelectionChangedEventArgs e) + { + SetSensorButtonStates(); + } + + private void SetSensorButtonStates() + { + AddSensorButton.IsEnabled = true; + EditSensorButton.IsEnabled = SensorDataGrid.SelectedItems.Count == 1; + DeleteSensorButton.IsEnabled = SensorDataGrid.SelectedItems.Count > 0; + } + + private void HandleAddSensorButtonClick(object sender, RoutedEventArgs e) + { + AddSensor(); + } + + private void HandleEditSensorButtonClick(object sender, RoutedEventArgs e) + { + EditSelectedSensor(); + } + + private void HandleDeleteSensorButtonClick(object sender, RoutedEventArgs e) + { + DeleteSelectedSensors(); + } + + private void HandleSensorDataGridRowMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + EditSelectedSensor(); + } + + private void AddSensor() + { + var sensorEntry = new SensorEntry(); + + var sensorWindow = new SensorWindow(); + + var result = sensorWindow.Display(sensorEntry, Window.GetWindow(this)); + + if (!result.HasValue || !result.Value) + return; + + SensorDataGrid.SelectedItem = sensorEntry; + + SetSensorButtonStates(); + } + + private void EditSelectedSensor() + { + if (SensorDataGrid.SelectedItem == null) + return; + + var sensorEntry = (SensorEntry)SensorDataGrid.SelectedItem; + + var sensorWindow = new SensorWindow(); + + sensorWindow.Display(sensorEntry, Window.GetWindow(this)); + } + + private void DeleteSelectedSensors() + { + if (MessageBox.Show(ParentWindow!, StatusWindow.Resources.ConfirmDeleteSensors, StatusWindow.Resources.ConfirmDeleteTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) + return; + + var selectedItems = new SensorEntry[SensorDataGrid.SelectedItems.Count]; + + SensorDataGrid.SelectedItems.CopyTo(selectedItems, 0); + + foreach (var sensorEntry in selectedItems) + Data.SensorEntries.Remove(sensorEntry); + + SetSensorButtonStates(); + } +} \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/HardwareTypeItem.cs b/StatusWindow/SettingsWindow/HardwareTypeItem.cs new file mode 100644 index 0000000..aa6961c --- /dev/null +++ b/StatusWindow/SettingsWindow/HardwareTypeItem.cs @@ -0,0 +1,10 @@ + +using HardwareMonitorStatusWindow.Service; + +namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow; + +public class HardwareTypeItem(HardwareType hardwareType) +{ + public HardwareType Value { get; set; } = hardwareType; + public string Name { get; set; } = hardwareType.ToString(); +} \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/SensorTypeItem.cs b/StatusWindow/SettingsWindow/SensorTypeItem.cs new file mode 100644 index 0000000..7c83cf4 --- /dev/null +++ b/StatusWindow/SettingsWindow/SensorTypeItem.cs @@ -0,0 +1,9 @@ +using HardwareMonitorStatusWindow.Service; + +namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow; + +public class SensorTypeItem(SensorType sensorType) +{ + public SensorType Value { get; set; } = sensorType; + public string Name { get; set; } = sensorType.ToString(); +} \ No newline at end of file diff --git a/StatusWindow/SettingsWindow/SensorWindow.xaml b/StatusWindow/SettingsWindow/SensorWindow.xaml new file mode 100644 index 0000000..d696f40 --- /dev/null +++ b/StatusWindow/SettingsWindow/SensorWindow.xaml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +