Initial WIP commit
Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
This commit is contained in:
36
.gitea/workflows/main.yml
Normal file
36
.gitea/workflows/main.yml
Normal file
@@ -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 }}
|
||||||
398
.gitignore
vendored
Normal file
398
.gitignore
vendored
Normal file
@@ -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
|
||||||
3
HardwareMonitorStatusWindow.sln.DotSettings
Normal file
3
HardwareMonitorStatusWindow.sln.DotSettings
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=dragdrop/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
7
HardwareMonitorStatusWindow.slnx
Normal file
7
HardwareMonitorStatusWindow.slnx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/Solution Items/">
|
||||||
|
<File Path=".gitea/workflows/main.yml" />
|
||||||
|
</Folder>
|
||||||
|
<Project Path="Service/Service.csproj" />
|
||||||
|
<Project Path="StatusWindow/StatusWindow.csproj" />
|
||||||
|
</Solution>
|
||||||
41
Service/Hardware.cs
Normal file
41
Service/Hardware.cs
Normal file
@@ -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<Sensor> 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)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
41
Service/HardwareMonitorService.cs
Normal file
41
Service/HardwareMonitorService.cs
Normal file
@@ -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<Hardware> GetHardware()
|
||||||
|
{
|
||||||
|
Computer.Accept(HardwareUpdateVisitor);
|
||||||
|
|
||||||
|
var hardwareEntries = Computer.Hardware.Select(Hardware.Create);
|
||||||
|
|
||||||
|
return hardwareEntries;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Service/HardwarePipeSerializer.cs
Normal file
26
Service/HardwarePipeSerializer.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Service/HardwareType.cs
Normal file
18
Service/HardwareType.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace HardwareMonitorStatusWindow.Service;
|
||||||
|
|
||||||
|
public enum HardwareType
|
||||||
|
{
|
||||||
|
Motherboard,
|
||||||
|
SuperIo,
|
||||||
|
Cpu,
|
||||||
|
Memory,
|
||||||
|
GpuNvidia,
|
||||||
|
GpuAmd,
|
||||||
|
GpuIntel,
|
||||||
|
Storage,
|
||||||
|
Network,
|
||||||
|
Cooler,
|
||||||
|
EmbeddedController,
|
||||||
|
Psu,
|
||||||
|
Battery,
|
||||||
|
}
|
||||||
25
Service/HardwareUpdateVisitor.cs
Normal file
25
Service/HardwareUpdateVisitor.cs
Normal file
@@ -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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
6
Service/IHardwareMonitorService.cs
Normal file
6
Service/IHardwareMonitorService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace HardwareMonitorStatusWindow.Service;
|
||||||
|
|
||||||
|
public interface IHardwareMonitorService
|
||||||
|
{
|
||||||
|
IEnumerable<Hardware> GetHardware();
|
||||||
|
}
|
||||||
111
Service/Program.cs
Normal file
111
Service/Program.cs
Normal file
@@ -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<IHardwareMonitorService>(new HardwarePipeSerializer(), pipeWithSecurity, () => new HardwareMonitorService());
|
||||||
|
//var pipeServer = new PipeServer<IHardwareMonitorService>(
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
49
Service/Sensor.cs
Normal file
49
Service/Sensor.cs
Normal file
@@ -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)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Service/SensorType.cs
Normal file
26
Service/SensorType.cs
Normal file
@@ -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,
|
||||||
|
}
|
||||||
20
Service/Service.csproj
Normal file
20
Service/Service.csproj
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net10.0-windows</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<RootNamespace>HardwareMonitorStatusWindow.Service</RootNamespace>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.5" />
|
||||||
|
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.3.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
|
<PackageReference Include="TaskScheduler" Version="2.12.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
17
Service/app.manifest
Normal file
17
Service/app.manifest
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
</assembly>
|
||||||
24
StatusWindow/App.config
Normal file
24
StatusWindow/App.config
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="HardwareMonitorStatusWindow.StatusWindow.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
|
<userSettings>
|
||||||
|
<HardwareMonitorStatusWindow.StatusWindow.Settings>
|
||||||
|
<setting name="WindowSettings" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="AutoStart" serializeAs="String">
|
||||||
|
<value>True</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="CheckVersionAtStartup" serializeAs="String">
|
||||||
|
<value>True</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="Sensors" serializeAs="String">
|
||||||
|
<value>[]</value>
|
||||||
|
</setting>
|
||||||
|
</HardwareMonitorStatusWindow.StatusWindow.Settings>
|
||||||
|
</userSettings>
|
||||||
|
</configuration>
|
||||||
7
StatusWindow/App.xaml
Normal file
7
StatusWindow/App.xaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<Application x:Class="HardwareMonitorStatusWindow.StatusWindow.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ShutdownMode="OnLastWindowClose">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
37
StatusWindow/App.xaml.cs
Normal file
37
StatusWindow/App.xaml.cs
Normal file
@@ -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<IDisposable> _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);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
StatusWindow/AssemblyInfo.cs
Normal file
24
StatusWindow/AssemblyInfo.cs
Normal file
@@ -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")]
|
||||||
54
StatusWindow/Data.cs
Normal file
54
StatusWindow/Data.cs
Normal file
@@ -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<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();
|
||||||
|
}
|
||||||
|
}
|
||||||
42
StatusWindow/DataErrorDictionary.cs
Normal file
42
StatusWindow/DataErrorDictionary.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow;
|
||||||
|
|
||||||
|
internal class DataErrorDictionary : Dictionary<string, List<string>>
|
||||||
|
{
|
||||||
|
public event EventHandler<DataErrorsChangedEventArgs> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
StatusWindow/Program.cs
Normal file
26
StatusWindow/Program.cs
Normal file
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
446
StatusWindow/Resources.Designer.cs
generated
Normal file
446
StatusWindow/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,446 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 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.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// 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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
public static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add.
|
||||||
|
/// </summary>
|
||||||
|
public static string AddSensorLink {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AddSensorLink", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string AddSensorToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("AddSensorToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Icon ApplicationIcon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ApplicationIcon", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Hardware Monitor Status Window.
|
||||||
|
/// </summary>
|
||||||
|
public static string ApplicationName {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ApplicationName", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Cancel.
|
||||||
|
/// </summary>
|
||||||
|
public static string CancelButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CancelButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Checking for update....
|
||||||
|
/// </summary>
|
||||||
|
public static string CheckingForUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CheckingForUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Check for Update.
|
||||||
|
/// </summary>
|
||||||
|
public static string CheckUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CheckUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Check _Now.
|
||||||
|
/// </summary>
|
||||||
|
public static string checkVersionNowButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("checkVersionNowButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Check for a new version on startup.
|
||||||
|
/// </summary>
|
||||||
|
public static string checkVersionOnStartupCheckBox {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("checkVersionOnStartupCheckBox", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Close.
|
||||||
|
/// </summary>
|
||||||
|
public static string CloseButtonText {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CloseButtonText", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Are you sure you want to delete the selected sensors?.
|
||||||
|
/// </summary>
|
||||||
|
public static string ConfirmDeleteSensors {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ConfirmDeleteSensors", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Confirm Delete.
|
||||||
|
/// </summary>
|
||||||
|
public static string ConfirmDeleteTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ConfirmDeleteTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Delete.
|
||||||
|
/// </summary>
|
||||||
|
public static string DeleteSensorLink {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DeleteSensorLink", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Delete Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string DeleteSensorToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DeleteSensorToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Downloading update....
|
||||||
|
/// </summary>
|
||||||
|
public static string DownloadingUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DownloadingUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit.
|
||||||
|
/// </summary>
|
||||||
|
public static string EditSensorLink {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("EditSensorLink", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string EditSensorToolTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("EditSensorToolTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Hardware.
|
||||||
|
/// </summary>
|
||||||
|
public static string HardwareColumnHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("HardwareColumnHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Hardware Type.
|
||||||
|
/// </summary>
|
||||||
|
public static string HardwareTypeWatermark {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("HardwareTypeWatermark", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Hardware.
|
||||||
|
/// </summary>
|
||||||
|
public static string HardwareWatermark {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("HardwareWatermark", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Installing update....
|
||||||
|
/// </summary>
|
||||||
|
public static string InstallingUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("InstallingUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Label.
|
||||||
|
/// </summary>
|
||||||
|
public static string LabelColumnHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("LabelColumnHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Loading....
|
||||||
|
/// </summary>
|
||||||
|
public static string Loading {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Loading", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to OK.
|
||||||
|
/// </summary>
|
||||||
|
public static string OkayButton {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OkayButton", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to About.
|
||||||
|
/// </summary>
|
||||||
|
public static string optionCategoryAbout {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("optionCategoryAbout", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to General.
|
||||||
|
/// </summary>
|
||||||
|
public static string optionCategoryGeneral {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("optionCategoryGeneral", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Hardware.
|
||||||
|
/// </summary>
|
||||||
|
public static string optionCategoryHardware {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("optionCategoryHardware", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Sensors.
|
||||||
|
/// </summary>
|
||||||
|
public static string optionCategorySensors {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("optionCategorySensors", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Update.
|
||||||
|
/// </summary>
|
||||||
|
public static string optionCategoryUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("optionCategoryUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string SensorColumnHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SensorColumnHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Sensor Type.
|
||||||
|
/// </summary>
|
||||||
|
public static string SensorTypeWatermark {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SensorTypeWatermark", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string SensorWatermark {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SensorWatermark", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string SensorWindowAdd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SensorWindowAdd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit Sensor.
|
||||||
|
/// </summary>
|
||||||
|
public static string SensorWindowEdit {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SensorWindowEdit", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Service not installed - restart application.
|
||||||
|
/// </summary>
|
||||||
|
public static string ServiceNotInstalled {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ServiceNotInstalled", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Waiting for service to start....
|
||||||
|
/// </summary>
|
||||||
|
public static string ServiceNotStarted {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ServiceNotStarted", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Settings.
|
||||||
|
/// </summary>
|
||||||
|
public static string SettingsTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SettingsTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to _Start when Windows starts.
|
||||||
|
/// </summary>
|
||||||
|
public static string startWithWindowsCheckBox {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("startWithWindowsCheckBox", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to You are already running the most recent version.
|
||||||
|
///
|
||||||
|
///No updates are available at this time..
|
||||||
|
/// </summary>
|
||||||
|
public static string UpdateCheckCurrent {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("UpdateCheckCurrent", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Version {0} is now available.
|
||||||
|
///
|
||||||
|
///Would you like to download and install it now?.
|
||||||
|
/// </summary>
|
||||||
|
public static string UpdateCheckNewVersion {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("UpdateCheckNewVersion", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} Update.
|
||||||
|
/// </summary>
|
||||||
|
public static string UpdateCheckTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("UpdateCheckTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Version {0}.
|
||||||
|
/// </summary>
|
||||||
|
public static string Version {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Version", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
251
StatusWindow/Resources.resx
Normal file
251
StatusWindow/Resources.resx
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="ApplicationName" xml:space="preserve">
|
||||||
|
<value>Hardware Monitor Status Window</value>
|
||||||
|
</data>
|
||||||
|
<data name="optionCategoryAbout" xml:space="preserve">
|
||||||
|
<value>About</value>
|
||||||
|
</data>
|
||||||
|
<data name="CheckUpdate" xml:space="preserve">
|
||||||
|
<value>_Check for Update</value>
|
||||||
|
</data>
|
||||||
|
<data name="startWithWindowsCheckBox" xml:space="preserve">
|
||||||
|
<value>_Start when Windows starts</value>
|
||||||
|
</data>
|
||||||
|
<data name="optionCategoryGeneral" xml:space="preserve">
|
||||||
|
<value>General</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsTitle" xml:space="preserve">
|
||||||
|
<value>Settings</value>
|
||||||
|
</data>
|
||||||
|
<data name="CloseButtonText" xml:space="preserve">
|
||||||
|
<value>Close</value>
|
||||||
|
</data>
|
||||||
|
<data name="Version" xml:space="preserve">
|
||||||
|
<value>Version {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="optionCategoryUpdate" xml:space="preserve">
|
||||||
|
<value>Update</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkVersionOnStartupCheckBox" xml:space="preserve">
|
||||||
|
<value>_Check for a new version on startup</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkVersionNowButton" xml:space="preserve">
|
||||||
|
<value>Check _Now</value>
|
||||||
|
</data>
|
||||||
|
<data name="UpdateCheckTitle" xml:space="preserve">
|
||||||
|
<value>{0} Update</value>
|
||||||
|
</data>
|
||||||
|
<data name="UpdateCheckCurrent" xml:space="preserve">
|
||||||
|
<value>You are already running the most recent version.
|
||||||
|
|
||||||
|
No updates are available at this time.</value>
|
||||||
|
</data>
|
||||||
|
<data name="UpdateCheckNewVersion" xml:space="preserve">
|
||||||
|
<value>Version {0} is now available.
|
||||||
|
|
||||||
|
Would you like to download and install it now?</value>
|
||||||
|
</data>
|
||||||
|
<data name="Loading" xml:space="preserve">
|
||||||
|
<value>Loading...</value>
|
||||||
|
</data>
|
||||||
|
<data name="CheckingForUpdate" xml:space="preserve">
|
||||||
|
<value>Checking for update...</value>
|
||||||
|
</data>
|
||||||
|
<data name="DownloadingUpdate" xml:space="preserve">
|
||||||
|
<value>Downloading update...</value>
|
||||||
|
</data>
|
||||||
|
<data name="InstallingUpdate" xml:space="preserve">
|
||||||
|
<value>Installing update...</value>
|
||||||
|
</data>
|
||||||
|
<data name="ConfirmDeleteTitle" xml:space="preserve">
|
||||||
|
<value>Confirm Delete</value>
|
||||||
|
</data>
|
||||||
|
<data name="OkayButton" xml:space="preserve">
|
||||||
|
<value>OK</value>
|
||||||
|
</data>
|
||||||
|
<data name="CancelButton" xml:space="preserve">
|
||||||
|
<value>Cancel</value>
|
||||||
|
</data>
|
||||||
|
<data name="optionCategoryHardware" xml:space="preserve">
|
||||||
|
<value>Hardware</value>
|
||||||
|
</data>
|
||||||
|
<data name="EditSensorLink" xml:space="preserve">
|
||||||
|
<value>Edit</value>
|
||||||
|
</data>
|
||||||
|
<data name="DeleteSensorLink" xml:space="preserve">
|
||||||
|
<value>Delete</value>
|
||||||
|
</data>
|
||||||
|
<data name="AddSensorToolTip" xml:space="preserve">
|
||||||
|
<value>Add Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="EditSensorToolTip" xml:space="preserve">
|
||||||
|
<value>Edit Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="DeleteSensorToolTip" xml:space="preserve">
|
||||||
|
<value>Delete Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="optionCategorySensors" xml:space="preserve">
|
||||||
|
<value>Sensors</value>
|
||||||
|
</data>
|
||||||
|
<data name="LabelColumnHeader" xml:space="preserve">
|
||||||
|
<value>Label</value>
|
||||||
|
</data>
|
||||||
|
<data name="SensorColumnHeader" xml:space="preserve">
|
||||||
|
<value>Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="AddSensorLink" xml:space="preserve">
|
||||||
|
<value>Add</value>
|
||||||
|
</data>
|
||||||
|
<data name="SensorWindowAdd" xml:space="preserve">
|
||||||
|
<value>Add Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="SensorWindowEdit" xml:space="preserve">
|
||||||
|
<value>Edit Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="ConfirmDeleteSensors" xml:space="preserve">
|
||||||
|
<value>Are you sure you want to delete the selected sensors?</value>
|
||||||
|
</data>
|
||||||
|
<data name="HardwareWatermark" xml:space="preserve">
|
||||||
|
<value>Hardware</value>
|
||||||
|
</data>
|
||||||
|
<data name="SensorWatermark" xml:space="preserve">
|
||||||
|
<value>Sensor</value>
|
||||||
|
</data>
|
||||||
|
<data name="SensorTypeWatermark" xml:space="preserve">
|
||||||
|
<value>Sensor Type</value>
|
||||||
|
</data>
|
||||||
|
<data name="HardwareColumnHeader" xml:space="preserve">
|
||||||
|
<value>Hardware</value>
|
||||||
|
</data>
|
||||||
|
<data name="HardwareTypeWatermark" xml:space="preserve">
|
||||||
|
<value>Hardware Type</value>
|
||||||
|
</data>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="ApplicationIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>Resources\Application.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ServiceNotInstalled" xml:space="preserve">
|
||||||
|
<value>Service not installed - restart application</value>
|
||||||
|
</data>
|
||||||
|
<data name="ServiceNotStarted" xml:space="preserve">
|
||||||
|
<value>Waiting for service to start...</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
BIN
StatusWindow/Resources/Application.ico
Normal file
BIN
StatusWindow/Resources/Application.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
133
StatusWindow/SensorEntry.cs
Normal file
133
StatusWindow/SensorEntry.cs
Normal file
@@ -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<DataErrorsChangedEventArgs> 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<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
if (EqualityComparer<T>.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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
74
StatusWindow/Settings.Designer.cs
generated
Normal file
74
StatusWindow/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 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.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
StatusWindow/Settings.settings
Normal file
18
StatusWindow/Settings.settings
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HardwareMonitorStatusWindow.StatusWindow" GeneratedClassName="Settings">
|
||||||
|
<Profiles />
|
||||||
|
<Settings>
|
||||||
|
<Setting Name="WindowSettings" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="AutoStart" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">True</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="CheckVersionAtStartup" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">True</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="Sensors" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">[]</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
||||||
20
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml
Normal file
20
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.AboutSettingsPanel"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||||
|
xmlns:window="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="150"
|
||||||
|
d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel windows:Spacing.Vertical="10">
|
||||||
|
<TextBlock Text="{x:Static window:Resources.ApplicationName}"
|
||||||
|
FontWeight="Bold" />
|
||||||
|
<TextBlock Text="{Binding Source={x:Static window:UpdateCheck.LocalVersion}, StringFormat={x:Static window:Resources.Version}}"
|
||||||
|
Name="VersionLabel" />
|
||||||
|
<TextBlock Text="Chris Kaczor" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</windows:CategoryPanelBase>
|
||||||
12
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
12
StatusWindow/SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow
|
||||||
|
{
|
||||||
|
public partial class AboutSettingsPanel
|
||||||
|
{
|
||||||
|
public AboutSettingsPanel()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string CategoryName => StatusWindow.Resources.optionCategoryAbout;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml
Normal file
16
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.GeneralSettingsPanel"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||||
|
xmlns:properties="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300"
|
||||||
|
d:DesignWidth="300">
|
||||||
|
<StackPanel windows:Spacing.Vertical="10">
|
||||||
|
<CheckBox Content="{x:Static properties:Resources.startWithWindowsCheckBox}"
|
||||||
|
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=AutoStart}"
|
||||||
|
Click="OnSaveSettings" />
|
||||||
|
</StackPanel>
|
||||||
|
</windows:CategoryPanelBase>
|
||||||
35
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
35
StatusWindow/SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
126
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml
Normal file
126
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<windows:CategoryPanelBase
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:hardwareMonitorStatusWindow="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||||
|
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||||
|
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
|
||||||
|
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||||
|
x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.HardwareSettingsPanel"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300"
|
||||||
|
d:DesignWidth="300">
|
||||||
|
<windows:CategoryPanelBase.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||||
|
<ResourceDictionary
|
||||||
|
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
|
||||||
|
<ResourceDictionary
|
||||||
|
Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</windows:CategoryPanelBase.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<DataGrid Name="SensorDataGrid"
|
||||||
|
SelectionMode="Extended"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.Row="0"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
GridLinesVisibility="None"
|
||||||
|
CanUserResizeRows="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
CanUserSortColumns="False"
|
||||||
|
SelectionUnit="FullRow"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
BorderThickness="1,1,1,1"
|
||||||
|
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
|
||||||
|
Background="{x:Null}"
|
||||||
|
SelectionChanged="HandleSensorDataGridSelectionChanged"
|
||||||
|
d:DataContext="{d:DesignInstance hardwareMonitorStatusWindow:SensorEntry }"
|
||||||
|
dd:DragDrop.IsDragSource="True"
|
||||||
|
dd:DragDrop.IsDropTarget="True">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Binding="{Binding Path=Label}"
|
||||||
|
Header="{x:Static hardwareMonitorStatusWindow:Resources.LabelColumnHeader}"
|
||||||
|
Width="*" />
|
||||||
|
<DataGridTemplateColumn Header="{x:Static hardwareMonitorStatusWindow:Resources.HardwareColumnHeader}"
|
||||||
|
Width="*">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{Binding Path=Hardware.Type}"
|
||||||
|
Height="Auto"
|
||||||
|
FontSize="10"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,2,0,2" />
|
||||||
|
<TextBlock Text="{Binding Path=Hardware.Name}"
|
||||||
|
Height="Auto"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
<DataGridTemplateColumn Header="{x:Static hardwareMonitorStatusWindow:Resources.SensorColumnHeader}"
|
||||||
|
Width="*">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="{Binding Path=Sensor.Type}"
|
||||||
|
Height="Auto"
|
||||||
|
FontSize="10"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,2,0,2" />
|
||||||
|
<TextBlock Text="{Binding Path=Sensor.Name}"
|
||||||
|
Height="Auto"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
<DataGrid.RowStyle>
|
||||||
|
<Style TargetType="DataGridRow"
|
||||||
|
BasedOn="{StaticResource MahApps.Styles.DataGridRow}">
|
||||||
|
<EventSetter Event="MouseDoubleClick"
|
||||||
|
Handler="HandleSensorDataGridRowMouseDoubleClick" />
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
</DataGrid>
|
||||||
|
<Border Grid.Column="0"
|
||||||
|
Grid.Row="1"
|
||||||
|
BorderThickness="1,0,1,1"
|
||||||
|
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||||
|
<controls:Link Name="AddSensorButton"
|
||||||
|
Margin="2"
|
||||||
|
Click="HandleAddSensorButtonClick"
|
||||||
|
Text="{x:Static hardwareMonitorStatusWindow:Resources.AddSensorLink}"
|
||||||
|
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.AddSensorToolTip}">
|
||||||
|
</controls:Link>
|
||||||
|
<controls:Link Name="EditSensorButton"
|
||||||
|
Margin="2"
|
||||||
|
Click="HandleEditSensorButtonClick"
|
||||||
|
Text="{x:Static hardwareMonitorStatusWindow:Resources.EditSensorLink}"
|
||||||
|
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.EditSensorToolTip}">
|
||||||
|
</controls:Link>
|
||||||
|
<controls:Link Name="DeleteSensorButton"
|
||||||
|
Margin="2"
|
||||||
|
Click="HandleDeleteSensorButtonClick"
|
||||||
|
Text="{x:Static hardwareMonitorStatusWindow:Resources.DeleteSensorLink}"
|
||||||
|
ToolTip="{x:Static hardwareMonitorStatusWindow:Resources.DeleteSensorToolTip}">
|
||||||
|
</controls:Link>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</windows:CategoryPanelBase>
|
||||||
112
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs
Normal file
112
StatusWindow/SettingsWindow/HardwareSettingsPanel.xaml.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
10
StatusWindow/SettingsWindow/HardwareTypeItem.cs
Normal file
10
StatusWindow/SettingsWindow/HardwareTypeItem.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
9
StatusWindow/SettingsWindow/SensorTypeItem.cs
Normal file
9
StatusWindow/SettingsWindow/SensorTypeItem.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
106
StatusWindow/SettingsWindow/SensorWindow.xaml
Normal file
106
StatusWindow/SettingsWindow/SensorWindow.xaml
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<Window x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.SensorWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:hardwareMonitorStatusWindow="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
d:DataContext="{d:DesignInstance Type=hardwareMonitorStatusWindow:SensorEntry}"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
|
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="SensorWindow"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
SizeToContent="Height"
|
||||||
|
Width="450"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
FocusManager.FocusedElement="{Binding ElementName=LabelTextBox}">
|
||||||
|
<Window.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||||
|
<ResourceDictionary
|
||||||
|
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
|
||||||
|
<ResourceDictionary
|
||||||
|
Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid Margin="6">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Margin="0,4"
|
||||||
|
windows:Spacing.Vertical="8">
|
||||||
|
<TextBox Name="LabelTextBox"
|
||||||
|
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||||
|
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.LabelColumnHeader}"
|
||||||
|
mah:TextBoxHelper.SelectAllOnFocus="True"
|
||||||
|
Text="{Binding Path=Label, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}" />
|
||||||
|
<ComboBox Name="HardwareTypeComboBox"
|
||||||
|
SelectedValuePath="Value"
|
||||||
|
DisplayMemberPath="Name"
|
||||||
|
VirtualizingPanel.IsVirtualizing="False"
|
||||||
|
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||||
|
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.HardwareTypeWatermark}"
|
||||||
|
SelectionChanged="HardwareTypeComboBox_SelectionChanged">
|
||||||
|
</ComboBox>
|
||||||
|
<ComboBox Name="HardwareComboBox"
|
||||||
|
DisplayMemberPath="Name"
|
||||||
|
VirtualizingPanel.IsVirtualizing="False"
|
||||||
|
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||||
|
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.HardwareWatermark}"
|
||||||
|
SelectionChanged="HardwareComboBox_SelectionChanged">
|
||||||
|
</ComboBox>
|
||||||
|
<ComboBox Name="SensorTypeComboBox"
|
||||||
|
SelectedValuePath="Value"
|
||||||
|
DisplayMemberPath="Name"
|
||||||
|
VirtualizingPanel.IsVirtualizing="False"
|
||||||
|
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||||
|
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorTypeWatermark}"
|
||||||
|
SelectionChanged="SensorTypeComboBox_SelectionChanged">
|
||||||
|
</ComboBox>
|
||||||
|
<ComboBox Name="SensorComboBox"
|
||||||
|
DisplayMemberPath="Name"
|
||||||
|
VirtualizingPanel.IsVirtualizing="False"
|
||||||
|
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||||
|
mah:TextBoxHelper.Watermark="{x:Static hardwareMonitorStatusWindow:Resources.SensorWatermark}">
|
||||||
|
</ComboBox>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Column="0"
|
||||||
|
Grid.Row="1"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Margin="0,5,0,0"
|
||||||
|
HorizontalAlignment="Right">
|
||||||
|
<Button Content="{x:Static hardwareMonitorStatusWindow:Resources.OkayButton}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="75"
|
||||||
|
Margin="0,0,5,0"
|
||||||
|
IsDefault="True"
|
||||||
|
Click="HandleOkayButtonClick">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button"
|
||||||
|
BasedOn="{StaticResource {x:Type Button}}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Text.Length, ElementName=LabelTextBox}"
|
||||||
|
Value="0">
|
||||||
|
<Setter Property="IsEnabled"
|
||||||
|
Value="False" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
<Button Content="{x:Static hardwareMonitorStatusWindow:Resources.CancelButton}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="75"
|
||||||
|
IsCancel="True" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
98
StatusWindow/SettingsWindow/SensorWindow.xaml.cs
Normal file
98
StatusWindow/SettingsWindow/SensorWindow.xaml.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using ChrisKaczor.Wpf.Validation;
|
||||||
|
using HardwareMonitorStatusWindow.Service;
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||||
|
|
||||||
|
public partial class SensorWindow
|
||||||
|
{
|
||||||
|
public SensorWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool? Display(SensorEntry sensorEntry, Window owner)
|
||||||
|
{
|
||||||
|
DataContext = sensorEntry;
|
||||||
|
|
||||||
|
Data.RefreshComputer();
|
||||||
|
|
||||||
|
HardwareTypeComboBox.ItemsSource = Data.ComputerHardware.Where(h => h.Sensors.Any()).DistinctBy(h => h.Type).Select(s => new HardwareTypeItem(s.Type)).OrderBy(s => s.Name);
|
||||||
|
|
||||||
|
var hardware = Data.ComputerHardware.FirstOrDefault(h => h.Identifier.ToString() == sensorEntry.HardwareId);
|
||||||
|
var sensor = hardware?.Sensors.FirstOrDefault(s => s.Identifier.ToString() == sensorEntry.SensorId);
|
||||||
|
|
||||||
|
HardwareTypeComboBox.SelectedValue = hardware?.Type;
|
||||||
|
HardwareComboBox.SelectedItem = hardware;
|
||||||
|
SensorTypeComboBox.SelectedValue = sensor?.Type;
|
||||||
|
SensorComboBox.SelectedItem = sensor;
|
||||||
|
|
||||||
|
Title = string.IsNullOrWhiteSpace(sensorEntry.Label) ? StatusWindow.Resources.SensorWindowAdd : StatusWindow.Resources.SensorWindowEdit;
|
||||||
|
|
||||||
|
Owner = owner;
|
||||||
|
|
||||||
|
return ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!this.IsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var sensorEntry = (SensorEntry)DataContext;
|
||||||
|
|
||||||
|
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||||
|
sensorEntry.HardwareId = hardware.Identifier;
|
||||||
|
|
||||||
|
var sensor = (Sensor)SensorComboBox.SelectedItem;
|
||||||
|
sensorEntry.SensorId = sensor.Identifier;
|
||||||
|
|
||||||
|
if (!Data.SensorEntries.Contains(sensorEntry))
|
||||||
|
Data.SensorEntries.Add(sensorEntry);
|
||||||
|
|
||||||
|
Data.Save();
|
||||||
|
|
||||||
|
DialogResult = true;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HardwareTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (HardwareTypeComboBox.SelectedIndex == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hardwareType = (HardwareTypeItem)HardwareTypeComboBox.SelectedItem;
|
||||||
|
|
||||||
|
HardwareComboBox.SelectedIndex = -1;
|
||||||
|
SensorTypeComboBox.SelectedIndex = -1;
|
||||||
|
SensorComboBox.SelectedIndex = -1;
|
||||||
|
|
||||||
|
HardwareComboBox.ItemsSource = Data.ComputerHardware.Where(h => h.Type == hardwareType.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HardwareComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (HardwareComboBox.SelectedIndex == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||||
|
|
||||||
|
SensorTypeComboBox.SelectedIndex = -1;
|
||||||
|
SensorComboBox.SelectedIndex = -1;
|
||||||
|
|
||||||
|
SensorTypeComboBox.ItemsSource = hardware.Sensors.DistinctBy(s => s.Type).Select(s => new SensorTypeItem(s.Type)).OrderBy(s => s.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SensorTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (SensorTypeComboBox.SelectedIndex == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hardware = (Hardware)HardwareComboBox.SelectedItem;
|
||||||
|
var sensorType = (SensorTypeItem)SensorTypeComboBox.SelectedItem;
|
||||||
|
|
||||||
|
SensorComboBox.ItemsSource = hardware.Sensors.Where(s => s.Type == sensorType.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml
Normal file
21
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<windows:CategoryPanelBase x:Class="HardwareMonitorStatusWindow.StatusWindow.SettingsWindow.UpdateSettingsPanel"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||||
|
xmlns:window="clr-namespace:HardwareMonitorStatusWindow.StatusWindow"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="150"
|
||||||
|
d:DesignWidth="250">
|
||||||
|
<StackPanel windows:Spacing.Vertical="10">
|
||||||
|
<CheckBox Content="{x:Static window:Resources.checkVersionOnStartupCheckBox}"
|
||||||
|
Name="CheckVersionOnStartupCheckBox"
|
||||||
|
IsChecked="{Binding Source={x:Static window:Settings.Default}, Path=CheckVersionAtStartup}"
|
||||||
|
Click="OnSaveSettings" />
|
||||||
|
<Button Content="{x:Static window:Resources.checkVersionNowButton}"
|
||||||
|
IsEnabled="{Binding Source={x:Static window:UpdateCheck.IsInstalled}}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Click="HandleCheckVersionNowButtonClick" />
|
||||||
|
</StackPanel>
|
||||||
|
</windows:CategoryPanelBase>
|
||||||
38
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
38
StatusWindow/SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using HardwareMonitorStatusWindow.StatusWindow;
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||||
|
|
||||||
|
public partial class UpdateSettingsPanel
|
||||||
|
{
|
||||||
|
public UpdateSettingsPanel()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string CategoryName => StatusWindow.Resources.optionCategoryUpdate;
|
||||||
|
|
||||||
|
private async void HandleCheckVersionNowButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var cursor = Cursor;
|
||||||
|
|
||||||
|
Cursor = Cursors.Wait;
|
||||||
|
|
||||||
|
await UpdateCheck.DisplayUpdateInformation(true);
|
||||||
|
|
||||||
|
Cursor = cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSaveSettings(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveSettings()
|
||||||
|
{
|
||||||
|
if (!HasLoaded) return;
|
||||||
|
|
||||||
|
Settings.Default.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
69
StatusWindow/StatusWindow.csproj
Normal file
69
StatusWindow/StatusWindow.csproj
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0-windows7.0</TargetFramework>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||||
|
<StartupObject>HardwareMonitorStatusWindow.StatusWindow.Program</StartupObject>
|
||||||
|
<ApplicationIcon>Resources\Application.ico</ApplicationIcon>
|
||||||
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
|
<RootNamespace>HardwareMonitorStatusWindow.StatusWindow</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Resources\Application.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\Application.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
|
||||||
|
<PackageReference Include="ChrisKaczor.Wpf.Controls.Link" Version="1.0.4" />
|
||||||
|
<PackageReference Include="ChrisKaczor.Wpf.Validation" Version="1.0.4" />
|
||||||
|
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
|
||||||
|
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.7" />
|
||||||
|
<PackageReference Include="gong-wpf-dragdrop" Version="4.0.0" />
|
||||||
|
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.3.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Velopack" Version="0.0.1298" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Service\Service.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Settings.Designer.cs">
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Resources.resx">
|
||||||
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
2
StatusWindow/StatusWindow.csproj.DotSettings
Normal file
2
StatusWindow/StatusWindow.csproj.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=settingswindow/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||||
50
StatusWindow/UpdateCheck.cs
Normal file
50
StatusWindow/UpdateCheck.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
using Serilog;
|
||||||
|
using Velopack;
|
||||||
|
using Velopack.Sources;
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow;
|
||||||
|
|
||||||
|
internal static class UpdateCheck
|
||||||
|
{
|
||||||
|
private static UpdateManager _updateManager;
|
||||||
|
|
||||||
|
public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GithubSource("https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow", null, false));
|
||||||
|
|
||||||
|
public static string LocalVersion => (UpdateManager.CurrentVersion ?? new SemanticVersion(0, 0, 0)).ToString();
|
||||||
|
|
||||||
|
public static bool IsInstalled => UpdateManager.IsInstalled;
|
||||||
|
|
||||||
|
public static async Task DisplayUpdateInformation(bool showIfCurrent)
|
||||||
|
{
|
||||||
|
var newVersion = IsInstalled ? await UpdateManager.CheckForUpdatesAsync() : null;
|
||||||
|
|
||||||
|
if (newVersion != null)
|
||||||
|
{
|
||||||
|
var updateCheckTitle = string.Format(Resources.UpdateCheckTitle, Resources.ApplicationName);
|
||||||
|
|
||||||
|
var updateCheckMessage = string.Format(Resources.UpdateCheckNewVersion, newVersion.TargetFullRelease.Version);
|
||||||
|
|
||||||
|
if (MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log.Logger.Information("Downloading update");
|
||||||
|
|
||||||
|
await UpdateManager.DownloadUpdatesAsync(newVersion);
|
||||||
|
|
||||||
|
Log.Logger.Information("Installing update");
|
||||||
|
|
||||||
|
UpdateManager.ApplyUpdatesAndRestart(newVersion);
|
||||||
|
}
|
||||||
|
else if (showIfCurrent)
|
||||||
|
{
|
||||||
|
var updateCheckTitle = string.Format(Resources.UpdateCheckTitle, Resources.ApplicationName);
|
||||||
|
|
||||||
|
var updateCheckMessage = string.Format(Resources.UpdateCheckCurrent, Resources.ApplicationName);
|
||||||
|
|
||||||
|
MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
235
StatusWindow/WindowSource.cs
Normal file
235
StatusWindow/WindowSource.cs
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
using ChrisKaczor.Wpf.Windows;
|
||||||
|
using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
|
||||||
|
using HardwareMonitorStatusWindow.Service;
|
||||||
|
using HardwareMonitorStatusWindow.StatusWindow.SettingsWindow;
|
||||||
|
using Microsoft.Win32.TaskScheduler;
|
||||||
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Timers;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using Task = System.Threading.Tasks.Task;
|
||||||
|
using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
|
namespace HardwareMonitorStatusWindow.StatusWindow;
|
||||||
|
|
||||||
|
internal class WindowSource : IWindowSource, IDisposable
|
||||||
|
{
|
||||||
|
private readonly FloatingStatusWindow _floatingStatusWindow;
|
||||||
|
private readonly Timer _timer;
|
||||||
|
private readonly Dispatcher _dispatcher;
|
||||||
|
|
||||||
|
internal WindowSource()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var taskService = new TaskService();
|
||||||
|
|
||||||
|
var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName);
|
||||||
|
|
||||||
|
if (existingTask == null)
|
||||||
|
{
|
||||||
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
var path = Path.GetDirectoryName(assembly.Location);
|
||||||
|
|
||||||
|
if (path != null)
|
||||||
|
{
|
||||||
|
var fileName = Path.Combine(path, "Service.exe");
|
||||||
|
|
||||||
|
var startInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = fileName,
|
||||||
|
Arguments = "--install",
|
||||||
|
UseShellExecute = true,
|
||||||
|
Verb = "runas"
|
||||||
|
};
|
||||||
|
|
||||||
|
Process.Start(startInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
_floatingStatusWindow = new FloatingStatusWindow(this);
|
||||||
|
_floatingStatusWindow.SetText(Resources.Loading);
|
||||||
|
|
||||||
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||||
|
|
||||||
|
_timer = new Timer(5000);
|
||||||
|
|
||||||
|
Task.Factory.StartNew(UpdateApp).ContinueWith(t => Start(t.Result.Result));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> UpdateApp()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!UpdateCheck.IsInstalled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!Settings.Default.CheckVersionAtStartup)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Log.Logger.Information("Checking for update");
|
||||||
|
|
||||||
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.CheckingForUpdate));
|
||||||
|
|
||||||
|
var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync();
|
||||||
|
|
||||||
|
if (newVersion == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Log.Logger.Information("Downloading update");
|
||||||
|
|
||||||
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.DownloadingUpdate));
|
||||||
|
|
||||||
|
await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion);
|
||||||
|
|
||||||
|
Log.Logger.Information("Installing update");
|
||||||
|
|
||||||
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.InstallingUpdate));
|
||||||
|
|
||||||
|
UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Logger.Error(e, nameof(UpdateApp));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Start(bool hasUpdate)
|
||||||
|
{
|
||||||
|
Log.Logger.Information("Start: hasUpdate={hasUpdate}", hasUpdate);
|
||||||
|
|
||||||
|
if (hasUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Log.Logger.Information("Load");
|
||||||
|
|
||||||
|
await Load();
|
||||||
|
|
||||||
|
Log.Logger.Information("Starting timer");
|
||||||
|
|
||||||
|
_timer.Elapsed += HandleTimerElapsed;
|
||||||
|
_timer.AutoReset = false;
|
||||||
|
_timer.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Load()
|
||||||
|
{
|
||||||
|
await Data.LoadComputer();
|
||||||
|
|
||||||
|
Data.Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save()
|
||||||
|
{
|
||||||
|
Data.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleTimerElapsed(object? sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer.Enabled = false;
|
||||||
|
_timer.Dispose();
|
||||||
|
|
||||||
|
Data.CloseComputer();
|
||||||
|
|
||||||
|
_floatingStatusWindow.Save();
|
||||||
|
_floatingStatusWindow.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid Id => Guid.Parse("0DB9393F-2710-40A5-A27B-34568696C61A");
|
||||||
|
|
||||||
|
public string Name => Resources.ApplicationName;
|
||||||
|
|
||||||
|
public System.Drawing.Icon Icon => Resources.ApplicationIcon;
|
||||||
|
|
||||||
|
public bool HasSettingsMenu => true;
|
||||||
|
|
||||||
|
public bool HasAboutMenu => false;
|
||||||
|
|
||||||
|
public void ShowAbout()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowSettings()
|
||||||
|
{
|
||||||
|
var categoryPanels = new List<CategoryPanelBase>
|
||||||
|
{
|
||||||
|
new GeneralSettingsPanel(),
|
||||||
|
new HardwareSettingsPanel(),
|
||||||
|
new UpdateSettingsPanel(),
|
||||||
|
new AboutSettingsPanel()
|
||||||
|
};
|
||||||
|
|
||||||
|
var settingsWindow = new CategoryWindow(categoryPanels, Resources.SettingsTitle, Resources.CloseButtonText);
|
||||||
|
|
||||||
|
settingsWindow.ShowDialog();
|
||||||
|
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasRefreshMenu => true;
|
||||||
|
|
||||||
|
public void Refresh()
|
||||||
|
{
|
||||||
|
using (var taskService = new TaskService())
|
||||||
|
{
|
||||||
|
var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName);
|
||||||
|
|
||||||
|
if (existingTask == null)
|
||||||
|
{
|
||||||
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(Resources.ServiceNotInstalled));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingTask.State != TaskState.Running)
|
||||||
|
{
|
||||||
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(Resources.ServiceNotStarted));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var text = new StringBuilder();
|
||||||
|
|
||||||
|
Data.RefreshComputer();
|
||||||
|
|
||||||
|
foreach (var sensorEntry in Data.SensorEntries)
|
||||||
|
{
|
||||||
|
if (text.Length > 0)
|
||||||
|
text.AppendLine();
|
||||||
|
|
||||||
|
text.Append($"{sensorEntry.Label}: {string.Format(sensorEntry.SensorValueFormat, sensorEntry.Sensor.Value)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
||||||
|
|
||||||
|
_timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string WindowSettings
|
||||||
|
{
|
||||||
|
get => Settings.Default.WindowSettings;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Settings.Default.WindowSettings = value;
|
||||||
|
Settings.Default.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user