diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 1ff0c42..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,63 +0,0 @@
-###############################################################################
-# Set default behavior to automatically normalize line endings.
-###############################################################################
-* text=auto
-
-###############################################################################
-# Set default behavior for command prompt diff.
-#
-# This is need for earlier builds of msysgit that does not have it on by
-# default for csharp files.
-# Note: This is only used by command line
-###############################################################################
-#*.cs diff=csharp
-
-###############################################################################
-# Set the merge driver for project and solution files
-#
-# Merging from the command prompt will add diff markers to the files if there
-# are conflicts (Merging from VS is not affected by the settings below, in VS
-# the diff markers are never inserted). Diff markers may cause the following
-# file extensions to fail to load in VS. An alternative would be to treat
-# these files as binary and thus will always conflict and require user
-# intervention with every merge. To do so, just uncomment the entries below
-###############################################################################
-#*.sln merge=binary
-#*.csproj merge=binary
-#*.vbproj merge=binary
-#*.vcxproj merge=binary
-#*.vcproj merge=binary
-#*.dbproj merge=binary
-#*.fsproj merge=binary
-#*.lsproj merge=binary
-#*.wixproj merge=binary
-#*.modelproj merge=binary
-#*.sqlproj merge=binary
-#*.wwaproj merge=binary
-
-###############################################################################
-# behavior for image files
-#
-# image files are treated as binary by default.
-###############################################################################
-#*.jpg binary
-#*.png binary
-#*.gif binary
-
-###############################################################################
-# diff behavior for common document formats
-#
-# Convert binary document formats to text before diffing them. This feature
-# is only available from the command line. Turn it on by uncommenting the
-# entries below.
-###############################################################################
-#*.doc diff=astextplain
-#*.DOC diff=astextplain
-#*.docx diff=astextplain
-#*.DOCX diff=astextplain
-#*.dot diff=astextplain
-#*.DOT diff=astextplain
-#*.pdf diff=astextplain
-#*.PDF diff=astextplain
-#*.rtf diff=astextplain
-#*.RTF diff=astextplain
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..c61e162
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,36 @@
+name: Deploy to GitHub Releases
+
+on:
+ push:
+ branches:
+ - main
+
+ workflow_dispatch:
+
+jobs:
+ deploy-to-github-releases:
+ runs-on: windows-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: Install .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 10.0.x
+
+ - name: Publish Application
+ run: dotnet publish ProcessCpuUsageStatusWindow.csproj -c Release -o publish
+
+ - name: Create Velopack Release
+ run: |
+ dotnet tool install -g vpk
+ vpk download github --repoUrl https://github.com/ckaczor/ProcessCpuUsageStatusWindow
+ vpk pack -u ProcessCpuUsageStatusWindow -v ${{ steps.version.outputs.version }} -p publish --packTitle "ProcessCpuUsageStatusWindow Status Window" --shortcuts StartMenuRoot --framework net10.0-x64-desktop
+ vpk upload github --repoUrl https://github.com/ckaczor/ProcessCpuUsageStatusWindow --publish --releaseName "${{ steps.version.outputs.version }}" --tag v${{ steps.version.outputs.version }} --token ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 92f5650..8a30d25 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,34 +1,84 @@
## 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
-# Build results
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+# Mono auto generated files
+mono_crash.*
+
+# Build results
[Dd]ebug/
+[Dd]ebugPublic/
[Rr]elease/
+[Rr]eleases/
x64/
-build/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
[Bb]in/
[Oo]bj/
+[Ll]og/
+[Ll]ogs/
-# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
-!packages/*/build/
+# 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
@@ -38,26 +88,41 @@ build/
*.tlh
*.tmp
*.tmp_proj
+*_wpftmp.csproj
*.log
+*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
-*.log
+*.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
@@ -65,6 +130,7 @@ ipch/
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
+*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
@@ -72,9 +138,30 @@ _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*
+_NCrunch_*
.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
# Installshield output folder
[Ee]xpress/
@@ -93,67 +180,219 @@ DocProject/Help/html
publish/
# Publish Web Output
-*.Publish.xml
+*.[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
-# NuGet Packages Directory
-packages/
+# 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/
-# Windows Azure Build Output
-csx
+# 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
-# Windows Store app package directory
+# 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
-sql/
-*.Cache
ClientBin/
-[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
-*.[Pp]ublish.xml
+*.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 ;-)
+# 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
-App_Data/*.mdf
-App_Data/*.ldf
+*.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
-#LightSwitch generated files
-GeneratedArtifacts/
-_Pvt_Extensions/
-ModelManifest.xml
+# Microsoft Fakes
+FakesAssemblies/
-# =========================
-# Windows detritus
-# =========================
+# GhostDoc plugin setting file
+*.GhostDoc.xml
-# Windows image file caches
-Thumbs.db
-ehthumbs.db
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
-# Folder config file
-Desktop.ini
+# Visual Studio 6 build log
+*.plg
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
+# Visual Studio 6 workspace options file
+*.opt
-# Mac desktop service store files
-.DS_Store
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
-.vs
-*.nupkg
-Releases/
\ No newline at end of file
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 4437b85..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "Common"]
- path = Common
- url = https://github.com/ckaczor/Common.git
\ No newline at end of file
diff --git a/App.config b/App.config
index 174f2fe..2214773 100644
--- a/App.config
+++ b/App.config
@@ -1,37 +1,36 @@
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
- 3
-
-
- 00:00:02
-
-
-
-
-
- True
-
-
- True
-
-
- False
-
-
-
+
+
+
+
+ True
+
+
+ True
+
+
+ []
+
+
+ 3
+
+
+ True
+
+
+ 00:00:02
+
+
+
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
index 360eed4..6211ea2 100644
--- a/App.xaml
+++ b/App.xaml
@@ -1,6 +1,6 @@
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ShutdownMode="OnLastWindowClose">
diff --git a/App.xaml.cs b/App.xaml.cs
index a1253dc..c287d15 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,48 +1,38 @@
-using FloatingStatusWindowLibrary;
-using ProcessCpuUsageStatusWindow.Properties;
-using Squirrel;
-using System;
+using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
+using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
+using ProcessCpuUsageStatusWindow.Properties;
-namespace ProcessCpuUsageStatusWindow
+namespace ProcessCpuUsageStatusWindow;
+
+public partial class App
{
- public partial class App
+ private List _windowSourceList;
+
+ protected override void OnStartup(StartupEventArgs e)
{
- private WindowSource _windowSource;
+ base.OnStartup(e);
- public static string UpdateUrl = "https://github.com/ckaczor/ProcessCpuUsageStatusWindow";
-
- [STAThread]
- public static void Main(string[] args)
+ StartManager.ManageAutoStart = true;
+ StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart;
+ StartManager.AutoStartChanged += (value =>
{
- SquirrelAwareApp.HandleEvents(onAppUpdate: version => Common.Settings.Extensions.RestoreSettings());
+ Settings.Default.AutoStart = value;
+ Settings.Default.Save();
+ });
- var application = new App();
- application.InitializeComponent();
- application.Run();
- }
-
- 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();
- };
-
- _windowSource = new WindowSource();
- }
-
- protected override void OnExit(ExitEventArgs e)
- {
- _windowSource.Dispose();
-
- base.OnExit(e);
- }
+ _windowSourceList =
+ [
+ new WindowSource()
+ ];
}
-}
+
+ protected override void OnExit(ExitEventArgs e)
+ {
+ _windowSourceList.ForEach(ws => ws.Dispose());
+
+ base.OnExit(e);
+ }
+}
\ No newline at end of file
diff --git a/Common b/Common
deleted file mode 160000
index ecd3717..0000000
--- a/Common
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit ecd3717eab737ede13023c7c81baa34488a05609
diff --git a/Options/AboutOptionsPanel.xaml b/Options/AboutOptionsPanel.xaml
deleted file mode 100644
index 4789e7e..0000000
--- a/Options/AboutOptionsPanel.xaml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Options/AboutOptionsPanel.xaml.cs b/Options/AboutOptionsPanel.xaml.cs
deleted file mode 100644
index 143fa84..0000000
--- a/Options/AboutOptionsPanel.xaml.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System.Reflection;
-using System.Windows;
-
-namespace ProcessCpuUsageStatusWindow.Options
-{
- public partial class AboutOptionsPanel
- {
- public AboutOptionsPanel()
- {
- InitializeComponent();
- }
-
- public override void LoadPanel(object data)
- {
- base.LoadPanel(data);
-
- ApplicationNameLabel.Text = Properties.Resources.ApplicationName;
-
- var version = UpdateCheck.LocalVersion.ToString();
- VersionLabel.Text = string.Format(Properties.Resources.About_Version, version);
-
- CompanyLabel.Text = ((AssemblyCompanyAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
- }
-
- public override bool ValidatePanel()
- {
- return true;
- }
-
- public override void SavePanel()
- {
- }
-
- public override string CategoryName => Properties.Resources.OptionCategory_About;
-
- private async void HandleCheckForUpdateButtonClick(object sender, RoutedEventArgs e)
- {
- await UpdateCheck.CheckUpdate((status, message) => UpdateMessage.Content = message);
- }
- }
-}
diff --git a/Options/GeneralOptionsPanel.xaml b/Options/GeneralOptionsPanel.xaml
deleted file mode 100644
index 8c50e61..0000000
--- a/Options/GeneralOptionsPanel.xaml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Options/GeneralOptionsPanel.xaml.cs b/Options/GeneralOptionsPanel.xaml.cs
deleted file mode 100644
index 04c8f0e..0000000
--- a/Options/GeneralOptionsPanel.xaml.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Common.Wpf.Extensions;
-using System.Windows;
-
-namespace ProcessCpuUsageStatusWindow.Options
-{
- public partial class GeneralOptionsPanel
- {
- private bool IsV2 { get; }
-
- public GeneralOptionsPanel(bool isV2)
- {
- InitializeComponent();
-
- IsV2 = isV2;
- }
-
- public override void LoadPanel(object data)
- {
- base.LoadPanel(data);
-
- var settings = Properties.Settings.Default;
-
- StartWithWindows.IsChecked = settings.AutoStart;
- NumberOfProcesses.Text = settings.ProcessCount.ToString();
- ShowProcessId.IsChecked = settings.ShowProcessId;
-
- ShowProcessId.Visibility = IsV2 ? Visibility.Visible : Visibility.Collapsed;
- }
-
- public override bool ValidatePanel()
- {
- return true;
- }
-
- public override void SavePanel()
- {
- var settings = Properties.Settings.Default;
-
- if (StartWithWindows.IsChecked.HasValue && settings.AutoStart != StartWithWindows.IsChecked.Value)
- settings.AutoStart = StartWithWindows.IsChecked.Value;
-
- settings.ProcessCount = int.Parse(NumberOfProcesses.Text);
-
- if (ShowProcessId.IsChecked.HasValue && settings.ShowProcessId != ShowProcessId.IsChecked.Value)
- settings.ShowProcessId = ShowProcessId.IsChecked.Value;
-
- Application.Current.SetStartWithWindows(settings.AutoStart);
- }
-
- public override string CategoryName => Properties.Resources.OptionCategory_General;
- }
-}
diff --git a/ProcessCpuUsage.cs b/ProcessCpuUsage.cs
index ba7d664..9c38735 100644
--- a/ProcessCpuUsage.cs
+++ b/ProcessCpuUsage.cs
@@ -1,60 +1,48 @@
using System;
using System.Diagnostics;
-namespace ProcessCpuUsageStatusWindow
+namespace ProcessCpuUsageStatusWindow;
+
+public class ProcessCpuUsage
{
- public class ProcessCpuUsage
+ public string ProcessName { get; private set; }
+ public float PercentUsage { get; private set; }
+ public DateTime LastFound { get; private set; }
+ public bool UsageValid { get; private set; }
+
+ private CounterSample LastSample { get; set; }
+
+ internal ProcessCpuUsage(InstanceData instanceData)
+ : this(instanceData, DateTime.MinValue)
{
- #region Properties
-
- public string ProcessName { get; private set; }
- public float PercentUsage { get; internal set; }
- public DateTime LastFound { get; set; }
- public bool UsageValid { get; private set; }
-
- internal CounterSample LastSample { get; set; }
-
- #endregion
-
- #region Constructor
-
- internal ProcessCpuUsage(InstanceData instanceData)
- : this(instanceData, DateTime.MinValue)
- { }
-
- internal ProcessCpuUsage(InstanceData instanceData, DateTime timestamp)
- {
- // Store the process details
- ProcessName = instanceData.InstanceName;
-
- // Store the initial data
- LastFound = timestamp;
- LastSample = instanceData.Sample;
-
- // We start out as not valid
- UsageValid = false;
- }
-
- #endregion
-
- #region Usage update
-
- internal void UpdateCpuUsage(InstanceData instanceData, DateTime timestamp)
- {
- // Get the new sample
- var newSample = instanceData.Sample;
-
- // Calculate percent usage
- PercentUsage = CounterSample.Calculate(LastSample, newSample) / Environment.ProcessorCount;
-
- // Update the last sample and timestmap
- LastSample = newSample;
- LastFound = timestamp;
-
- // Usage is now valid
- UsageValid = true;
- }
-
- #endregion
}
-}
+
+ internal ProcessCpuUsage(InstanceData instanceData, DateTime timestamp)
+ {
+ // Store the process details
+ ProcessName = instanceData.InstanceName;
+
+ // Store the initial data
+ LastFound = timestamp;
+ LastSample = instanceData.Sample;
+
+ // We start out as not valid
+ UsageValid = false;
+ }
+
+ internal void UpdateCpuUsage(InstanceData instanceData, DateTime timestamp)
+ {
+ // Get the new sample
+ var newSample = instanceData.Sample;
+
+ // Calculate percent usage
+ PercentUsage = CounterSample.Calculate(LastSample, newSample) / Environment.ProcessorCount;
+
+ // Update the last sample and timestamp
+ LastSample = newSample;
+ LastFound = timestamp;
+
+ // Usage is now valid
+ UsageValid = true;
+ }
+}
\ No newline at end of file
diff --git a/ProcessCpuUsageStatusWindow.csproj b/ProcessCpuUsageStatusWindow.csproj
index 510a436..75072e6 100644
--- a/ProcessCpuUsageStatusWindow.csproj
+++ b/ProcessCpuUsageStatusWindow.csproj
@@ -1,202 +1,54 @@
-
-
-
-
- Debug
- AnyCPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}
- WinExe
- Properties
- ProcessCpuUsageStatusWindow
- ProcessCpuUsageStatusWindow
- v4.5
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Native.dll
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Wpf.dll
-
-
- packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll
-
-
- packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll
-
-
- packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\FloatingStatusWindowLibrary.dll
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\Microsoft.Expression.Interactions.dll
- True
-
-
- packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll
-
-
- packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll
-
-
- packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll
-
-
- packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll
-
-
- packages\squirrel.windows.1.7.9\lib\Net45\NuGet.Squirrel.dll
-
-
- packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll
-
-
- packages\Splat.1.6.2\lib\Net45\Splat.dll
-
-
- packages\squirrel.windows.1.7.9\lib\Net45\Squirrel.dll
-
-
-
-
-
- packages\FloatingStatusWindow.1.0.0.9\lib\net45\System.Windows.Interactivity.dll
- True
-
-
-
-
- 4.0
-
-
-
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.dll
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.DataGrid.dll
-
-
- packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.Toolkit.dll
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- AboutOptionsPanel.xaml
-
-
- GeneralOptionsPanel.xaml
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- PublicResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
-
-
-
-
-
-
- {17864d82-457d-4a0a-bc10-1d07f2b3a5d6}
- Common
-
-
-
-
+
+
+ net10.0-windows7.0
+ WinExe
+ true
+ true
+ ProcessCpuUsageStatusWindow.Program
+ Resources\Application.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+ PublicResXFileCodeGenerator
+ Resources.Designer.cs
+
+
\ No newline at end of file
diff --git a/ProcessCpuUsageStatusWindow.nuspec b/ProcessCpuUsageStatusWindow.nuspec
deleted file mode 100644
index 8579a6f..0000000
--- a/ProcessCpuUsageStatusWindow.nuspec
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- ProcessCpuUsageStatusWindow
- CPU Usage Status Window
- $version$
- Chris Kaczor
- A "floating" status window that shows the top X processes by CPU usage.
- https://github.com/ckaczor/ProcessCpuUsageStatusWindow
- https://raw.githubusercontent.com/ckaczor/ProcessCpuUsageStatusWindow/master/LICENSE.md
- cpu
-
-
-
-
-
diff --git a/ProcessCpuUsageStatusWindow.sln b/ProcessCpuUsageStatusWindow.sln
deleted file mode 100644
index 8b0a902..0000000
--- a/ProcessCpuUsageStatusWindow.sln
+++ /dev/null
@@ -1,51 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2036
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessCpuUsageStatusWindow", "ProcessCpuUsageStatusWindow.csproj", "{C3C29363-2E3C-4478-B2A6-125DEA683E0D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{17864D82-457D-4A0A-BC10-1D07F2B3A5D6}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|x64.ActiveCfg = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|x64.Build.0 = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|x86.ActiveCfg = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Debug|x86.Build.0 = Debug|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|Any CPU.Build.0 = Release|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|x64.ActiveCfg = Release|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|x64.Build.0 = Release|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|x86.ActiveCfg = Release|Any CPU
- {C3C29363-2E3C-4478-B2A6-125DEA683E0D}.Release|x86.Build.0 = Release|Any CPU
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.ActiveCfg = Debug|x64
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x64.Build.0 = Debug|x64
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.ActiveCfg = Debug|x86
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Debug|x86.Build.0 = Debug|x86
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|Any CPU.Build.0 = Release|Any CPU
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.ActiveCfg = Release|x64
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x64.Build.0 = Release|x64
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.ActiveCfg = Release|x86
- {17864D82-457D-4A0A-BC10-1D07F2B3A5D6}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {145EFF96-40C2-4FFA-BD07-E514CDBB5E12}
- EndGlobalSection
-EndGlobal
diff --git a/ProcessCpuUsageStatusWindow.sln.DotSettings b/ProcessCpuUsageStatusWindow.sln.DotSettings
new file mode 100644
index 0000000..fb2d54a
--- /dev/null
+++ b/ProcessCpuUsageStatusWindow.sln.DotSettings
@@ -0,0 +1,4 @@
+
+ True
+
+
\ No newline at end of file
diff --git a/ProcessCpuUsageStatusWindow.slnx b/ProcessCpuUsageStatusWindow.slnx
new file mode 100644
index 0000000..c5d4dbe
--- /dev/null
+++ b/ProcessCpuUsageStatusWindow.slnx
@@ -0,0 +1,3 @@
+
+
+
diff --git a/ProcessCpuUsageWatcher.cs b/ProcessCpuUsageWatcher.cs
index e4e61ed..ac0809a 100644
--- a/ProcessCpuUsageWatcher.cs
+++ b/ProcessCpuUsageWatcher.cs
@@ -5,159 +5,131 @@ using System.Linq;
using System.Timers;
using System.Windows.Threading;
-namespace ProcessCpuUsageStatusWindow
+namespace ProcessCpuUsageStatusWindow;
+
+public class ProcessCpuUsageWatcher
{
- public class ProcessCpuUsageWatcher
+ public delegate void ProcessListUpdatedDelegate(Dictionary currentProcessList);
+
+ private Dispatcher _dispatcher;
+ private Timer _processUpdateTimer;
+ private ProcessListUpdatedDelegate _processListUpdatedCallback;
+ private PerformanceCounterCategory _processCategory;
+
+ public Dictionary CurrentProcessList;
+
+ public bool IsV2 => _processCategory.CategoryName == "Process V2";
+
+ public void Initialize(TimeSpan updateInterval, ProcessListUpdatedDelegate callback, Dispatcher dispatcher)
{
- #region Update delegate
+ _dispatcher = dispatcher;
- public delegate void ProcessListUpdatedDelegate(Dictionary currentProcessList);
+ // Create a new dictionary for the process list
+ CurrentProcessList = new Dictionary();
- #endregion
+ // Get the category for process performance info
+ _processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process V2") ??
+ PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process");
- #region Member variables
+ if (_processCategory == null)
+ return;
- private Dispatcher _dispatcher;
- private Timer _processUpdateTimer;
- private ProcessListUpdatedDelegate _processListUpdatedCallback;
- private PerformanceCounterCategory _processCategory;
+ // Read the entire category
+ var processCategoryData = _processCategory.ReadCategory();
- #endregion
+ // Get the processor time data
+ var processorTimeData = processCategoryData["% processor time"];
- #region Properties
+ if (processorTimeData?.Values == null)
+ return;
- public Dictionary CurrentProcessList;
-
- public bool IsV2 => _processCategory.CategoryName == "Process V2";
-
- #endregion
-
- #region Initialize and terminate
-
- public void Initialize(TimeSpan updateInterval, ProcessListUpdatedDelegate callback, Dispatcher dispatcher)
+ // Loop over each instance and add it to the list
+ foreach (InstanceData instanceData in processorTimeData.Values)
{
- _dispatcher = dispatcher;
+ // Create a new process usage object
+ var processCpuUsage = new ProcessCpuUsage(instanceData);
- // Create a new dictionary for the process list
- CurrentProcessList = new Dictionary();
+ // Add to the list
+ CurrentProcessList.Add(processCpuUsage.ProcessName, processCpuUsage);
+ }
- // Get the category for process performance info
- _processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process V2") ??
- PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process");
+ // Save the update callback
+ _processListUpdatedCallback = callback;
- if (_processCategory == null)
- return;
+ // Create a timer to update the process list
+ _processUpdateTimer = new Timer(1000) { AutoReset = false };
+ _processUpdateTimer.Elapsed += HandleProcessUpdateTimerElapsed;
+ _processUpdateTimer.Start();
+ }
- // Read the entire category
- var processCategoryData = _processCategory.ReadCategory();
+ public void Terminate()
+ {
+ // Get rid of the timer
+ if (_processUpdateTimer != null)
+ {
+ _processUpdateTimer.Stop();
+ _processUpdateTimer.Dispose();
+ }
- // Get the processor time data
- var processorTimeData = processCategoryData["% processor time"];
+ // Clear the callback
+ _processListUpdatedCallback = null;
- if (processorTimeData?.Values == null)
- return;
+ // Clear the process list
+ CurrentProcessList = null;
+ }
- // Loop over each instance and add it to the list
- foreach (InstanceData instanceData in processorTimeData.Values)
+ private void HandleProcessUpdateTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ // Update the current process list
+ UpdateCurrentProcessList();
+
+ // Restart the timer
+ _processUpdateTimer.Start();
+ }
+
+ private void UpdateCurrentProcessList()
+ {
+ // Get a timestamp for the current time that we can use to see if a process was found this check
+ var checkStart = DateTime.Now;
+
+ // Read the entire category
+ var processCategoryData = _processCategory.ReadCategory();
+
+ // Get the processor time data
+ var processorTimeData = processCategoryData["% processor time"];
+
+ if (processorTimeData?.Values == null)
+ return;
+
+ // Loop over each instance and add it to the list
+ foreach (InstanceData instanceData in processorTimeData.Values)
+ {
+ // See if we already know about this process
+ if (CurrentProcessList.TryGetValue(instanceData.InstanceName, out var processCpuUsage))
{
- // Create a new process usage object
- var processCpuUsage = new ProcessCpuUsage(instanceData);
-
- // Add to the list
- CurrentProcessList.Add(processCpuUsage.ProcessName, processCpuUsage);
+ // Update the CPU usage with new data
+ processCpuUsage.UpdateCpuUsage(instanceData, checkStart);
}
-
- // Save the update callback
- _processListUpdatedCallback = callback;
-
- // Create a timer to update the process list
- _processUpdateTimer = new Timer(updateInterval.TotalMilliseconds) { AutoReset = false };
- _processUpdateTimer.Elapsed += HandleProcessUpdateTimerElapsed;
- _processUpdateTimer.Start();
- }
-
- public void Terminate()
- {
- // Get rid of the timer
- if (_processUpdateTimer != null)
+ else
{
- _processUpdateTimer.Stop();
- _processUpdateTimer.Dispose();
+ // Create a new CPU usage object
+ var newProcessCpuUsage = new ProcessCpuUsage(instanceData, checkStart);
+
+ // Add it to the list
+ CurrentProcessList.Add(newProcessCpuUsage.ProcessName, newProcessCpuUsage);
}
-
- // Clear the callback
- _processListUpdatedCallback = null;
-
- // Clear the process list
- CurrentProcessList = null;
}
- #endregion
+ // Build a list of cached processes we haven't found this check
+ var oldProcessList = (from processCpuUsage in CurrentProcessList
+ where processCpuUsage.Value.LastFound != checkStart
+ select processCpuUsage.Key).ToList();
- #region Timer handling
+ // Loop over the list and remove the old process
+ foreach (var key in oldProcessList)
+ CurrentProcessList.Remove(key);
- private void HandleProcessUpdateTimerElapsed(object sender, ElapsedEventArgs e)
- {
- // Update the current process list
- UpdateCurrentProcessList();
-
- // Restart the timer
- _processUpdateTimer.Start();
- }
-
- #endregion
-
- #region Process list management
-
- private void UpdateCurrentProcessList()
- {
- // Get a timestamp for the current time that we can use to see if a process was found this check
- var checkStart = DateTime.Now;
-
- // Read the entire category
- var processCategoryData = _processCategory.ReadCategory();
-
- // Get the processor time data
- var processorTimeData = processCategoryData["% processor time"];
-
- if (processorTimeData?.Values == null)
- return;
-
- // Loop over each instance and add it to the list
- foreach (InstanceData instanceData in processorTimeData.Values)
- {
- // See if we already know about this process
- if (CurrentProcessList.ContainsKey(instanceData.InstanceName))
- {
- // Get the previous process usage object
- var processCpuUsage = CurrentProcessList[instanceData.InstanceName];
-
- // Update the CPU usage with new data
- processCpuUsage.UpdateCpuUsage(instanceData, checkStart);
- }
- else
- {
- // Create a new CPU usage object
- var processCpuUsage = new ProcessCpuUsage(instanceData, checkStart);
-
- // Add it to the list
- CurrentProcessList.Add(processCpuUsage.ProcessName, processCpuUsage);
- }
- }
-
- // Build a list of cached processes we haven't found this check
- var oldProcessList = (from processCpuUsage in CurrentProcessList
- where processCpuUsage.Value.LastFound != checkStart
- select processCpuUsage.Key).ToList();
-
- // Loop over the list and remove the old process
- foreach (var key in oldProcessList)
- CurrentProcessList.Remove(key);
-
- // Invoke the callback with the new current process list
- _dispatcher.InvokeAsync(() => _processListUpdatedCallback.Invoke(CurrentProcessList));
- }
-
- #endregion
+ // Invoke the callback with the new current process list
+ _dispatcher.InvokeAsync(() => _processListUpdatedCallback.Invoke(CurrentProcessList));
}
}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..bd56a72
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,27 @@
+using System;
+using Microsoft.Extensions.Logging;
+using Serilog;
+using Velopack;
+
+namespace ProcessCpuUsageStatusWindow;
+
+internal class Program
+{
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger();
+
+ Log.Logger.Information("Start");
+
+ var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
+
+ VelopackApp.Build().Run(loggerFactory.CreateLogger("Install"));
+
+ var app = new App();
+ app.InitializeComponent();
+ app.Run();
+
+ Log.Logger.Information("End");
+ }
+}
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
deleted file mode 100644
index a8354db..0000000
--- a/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-[assembly: AssemblyTitle("ProcessCpuUsageStatusWindow")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Chris Kaczor")]
-[assembly: AssemblyProduct("ProcessCpuUsageStatusWindow")]
-[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
-
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-
-[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
\ No newline at end of file
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index 284df37..7cfd30f 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
// 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", "17.0.0.0")]
+ [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 {
@@ -61,11 +61,20 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
///
- /// Looks up a localized string similar to Version: {0}.
+ /// Looks up a localized string similar to Add.
///
- public static string About_Version {
+ public static string AddItemLink {
get {
- return ResourceManager.GetString("About_Version", resourceCulture);
+ return ResourceManager.GetString("AddItemLink", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Add Item.
+ ///
+ public static string AddItemToolTip {
+ get {
+ return ResourceManager.GetString("AddItemToolTip", resourceCulture);
}
}
@@ -80,7 +89,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
///
- /// Looks up a localized string similar to Process CPU Usage.
+ /// Looks up a localized string similar to Process CPU Usage Status Window.
///
public static string ApplicationName {
get {
@@ -88,6 +97,15 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Cancel.
+ ///
+ public static string CancelButton {
+ get {
+ return ResourceManager.GetString("CancelButton", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Checking for update....
///
@@ -106,6 +124,69 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Check _Now.
+ ///
+ public static string checkVersionNowButton {
+ get {
+ return ResourceManager.GetString("checkVersionNowButton", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Check for a new version on startup.
+ ///
+ public static string checkVersionOnStartupCheckBox {
+ get {
+ return ResourceManager.GetString("checkVersionOnStartupCheckBox", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Close.
+ ///
+ public static string CloseButtonText {
+ get {
+ return ResourceManager.GetString("CloseButtonText", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Are you sure you want to delete the selected items?.
+ ///
+ public static string ConfirmDeleteItemss {
+ get {
+ return ResourceManager.GetString("ConfirmDeleteItemss", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Confirm Delete.
+ ///
+ public static string ConfirmDeleteTitle {
+ get {
+ return ResourceManager.GetString("ConfirmDeleteTitle", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Delete.
+ ///
+ public static string DeleteItemLink {
+ get {
+ return ResourceManager.GetString("DeleteItemLink", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Delete Item.
+ ///
+ public static string DeleteItemToolTip {
+ get {
+ return ResourceManager.GetString("DeleteItemToolTip", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Downloading update....
///
@@ -115,6 +196,24 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Edit.
+ ///
+ public static string EditItemLink {
+ get {
+ return ResourceManager.GetString("EditItemLink", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Edit Item.
+ ///
+ public static string EditItemToolTip {
+ get {
+ return ResourceManager.GetString("EditItemToolTip", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to CPU: {0,4:f1}% - Total.
///
@@ -124,15 +223,6 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
- ///
- /// Looks up a localized string similar to .
- ///
- public static string HeaderLine {
- get {
- return ResourceManager.GetString("HeaderLine", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Installing update....
///
@@ -142,6 +232,33 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Item.
+ ///
+ public static string ItemColumnHeader {
+ get {
+ return ResourceManager.GetString("ItemColumnHeader", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Add Item.
+ ///
+ public static string ItemWindowAdd {
+ get {
+ return ResourceManager.GetString("ItemWindowAdd", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Edit Item.
+ ///
+ public static string ItemWindowEdit {
+ get {
+ return ResourceManager.GetString("ItemWindowEdit", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Loading....
///
@@ -152,11 +269,11 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
///
- /// Looks up a localized string similar to No update found.
+ /// Looks up a localized string similar to Name.
///
- public static string NoUpdate {
+ public static string NameColumnHeader {
get {
- return ResourceManager.GetString("NoUpdate", resourceCulture);
+ return ResourceManager.GetString("NameColumnHeader", resourceCulture);
}
}
@@ -169,58 +286,48 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to OK.
+ ///
+ public static string OkayButton {
+ get {
+ return ResourceManager.GetString("OkayButton", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to About.
///
- public static string OptionCategory_About {
+ public static string optionCategoryAbout {
get {
- return ResourceManager.GetString("OptionCategory_About", resourceCulture);
+ return ResourceManager.GetString("optionCategoryAbout", resourceCulture);
}
}
///
/// Looks up a localized string similar to General.
///
- public static string OptionCategory_General {
+ public static string optionCategoryGeneral {
get {
- return ResourceManager.GetString("OptionCategory_General", resourceCulture);
+ return ResourceManager.GetString("optionCategoryGeneral", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Cancel.
+ /// Looks up a localized string similar to Items.
///
- public static string OptionsWindow_CancelButton {
+ public static string optionCategoryItems {
get {
- return ResourceManager.GetString("OptionsWindow_CancelButton", resourceCulture);
+ return ResourceManager.GetString("optionCategoryItems", resourceCulture);
}
}
///
- /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ /// Looks up a localized string similar to Update.
///
- public static System.Drawing.Icon OptionsWindow_Icon {
+ public static string optionCategoryUpdate {
get {
- object obj = ResourceManager.GetObject("OptionsWindow_Icon", resourceCulture);
- return ((System.Drawing.Icon)(obj));
- }
- }
-
- ///
- /// Looks up a localized string similar to OK.
- ///
- public static string OptionsWindow_OkayButton {
- get {
- return ResourceManager.GetString("OptionsWindow_OkayButton", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Options.
- ///
- public static string OptionsWindow_Title {
- get {
- return ResourceManager.GetString("OptionsWindow_Title", resourceCulture);
+ return ResourceManager.GetString("optionCategoryUpdate", resourceCulture);
}
}
@@ -243,38 +350,69 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
///
- /// Looks up a localized string similar to Restarting application....
+ /// Looks up a localized string similar to Settings.
///
- public static string RestartingAfterUpdate {
+ public static string SettingsTitle {
get {
- return ResourceManager.GetString("RestartingAfterUpdate", resourceCulture);
+ return ResourceManager.GetString("SettingsTitle", resourceCulture);
}
}
///
/// Looks up a localized string similar to Show _process ID.
///
- public static string ShowProcessId {
+ public static string showProcessId {
get {
- return ResourceManager.GetString("ShowProcessId", resourceCulture);
+ return ResourceManager.GetString("showProcessId", resourceCulture);
}
}
///
/// Looks up a localized string similar to _Start when Windows starts.
///
- public static string StartWithWindows {
+ public static string startWithWindowsCheckBox {
get {
- return ResourceManager.GetString("StartWithWindows", resourceCulture);
+ return ResourceManager.GetString("startWithWindowsCheckBox", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Updating application....
+ /// Looks up a localized string similar to You are already running the most recent version.
+ ///
+ ///No updates are available at this time..
///
- public static string Updating {
+ public static string UpdateCheckCurrent {
get {
- return ResourceManager.GetString("Updating", resourceCulture);
+ return ResourceManager.GetString("UpdateCheckCurrent", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Version {0} is now available.
+ ///
+ ///Would you like to download and install it now?.
+ ///
+ public static string UpdateCheckNewVersion {
+ get {
+ return ResourceManager.GetString("UpdateCheckNewVersion", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to {0} Update.
+ ///
+ public static string UpdateCheckTitle {
+ get {
+ return ResourceManager.GetString("UpdateCheckTitle", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Version {0}.
+ ///
+ public static string Version {
+ get {
+ return ResourceManager.GetString("Version", resourceCulture);
}
}
}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
index da9a6ce..c640f50 100644
--- a/Properties/Resources.resx
+++ b/Properties/Resources.resx
@@ -117,77 +117,126 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Version: {0}
-
-
-
- ..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- Process CPU Usage
+ Process CPU Usage Status Window
-
- Checking for update...
+
+ About
_Check for Update
-
- Downloading update...
+
+ _Start when Windows starts
-
- CPU: {0,4:f1}% - Total
+
+ General
-
-
+
+ Settings
-
- Installing update...
+
+ Close
+
+
+ Version {0}
+
+
+ Update
+
+
+ _Check for a new version on startup
+
+
+ Check _Now
+
+
+ {0} Update
+
+
+ You are already running the most recent version.
+
+No updates are available at this time.
+
+
+ Version {0} is now available.
+
+Would you like to download and install it now?
Loading...
-
- No update found
+
+ Checking for update...
-
- _Number of processes:
+
+ Downloading update...
-
- About
+
+ Installing update...
-
- General
+
+ Items
-
- Cancel
+
+ Name
-
- ..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ Item
-
+
+ Add
+
+
+ Edit
+
+
+ Delete
+
+
+ Add Item
+
+
+ Edit Item
+
+
+ Delete Item
+
+
+ Confirm Delete
+
+
+ Are you sure you want to delete the selected items?
+
+
+ Add Item
+
+
+ Edit Item
+
+
OK
-
- Options
+
+ Cancel
+
+
+ CPU: {0,4:f1}% - Total
CPU: {1,4:f1}% - {0}
-
- _Start when Windows starts
-
-
- Updating application...
-
-
- Restarting application...
-
CPU: {1,4:f1}% - {0} ({2})
-
+
+
+ ..\Resources\Application.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
Show _process ID
+
+ _Number of processes:
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index ffe6c05..5d76327 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -23,30 +23,6 @@ namespace ProcessCpuUsageStatusWindow.Properties {
}
}
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("3")]
- public int ProcessCount {
- get {
- return ((int)(this["ProcessCount"]));
- }
- set {
- this["ProcessCount"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("00:00:02")]
- public global::System.TimeSpan UpdateInterval {
- get {
- return ((global::System.TimeSpan)(this["UpdateInterval"]));
- }
- set {
- this["UpdateInterval"] = value;
- }
- }
-
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
@@ -74,18 +50,42 @@ namespace ProcessCpuUsageStatusWindow.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
- public bool FirstRun {
+ public bool CheckVersionAtStartup {
get {
- return ((bool)(this["FirstRun"]));
+ return ((bool)(this["CheckVersionAtStartup"]));
}
set {
- this["FirstRun"] = value;
+ this["CheckVersionAtStartup"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ [global::System.Configuration.DefaultSettingValueAttribute("[]")]
+ public string Items {
+ get {
+ return ((string)(this["Items"]));
+ }
+ set {
+ this["Items"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("3")]
+ public int ProcessCount {
+ get {
+ return ((int)(this["ProcessCount"]));
+ }
+ set {
+ this["ProcessCount"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ShowProcessId {
get {
return ((bool)(this["ShowProcessId"]));
@@ -94,5 +94,17 @@ namespace ProcessCpuUsageStatusWindow.Properties {
this["ShowProcessId"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("00:00:02")]
+ public global::System.TimeSpan UpdateInterval {
+ get {
+ return ((global::System.TimeSpan)(this["UpdateInterval"]));
+ }
+ set {
+ this["UpdateInterval"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 4fafc05..83c884d 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -2,23 +2,26 @@
-
- 3
-
-
- 00:00:02
-
True
-
+
True
+
+ []
+
+
+ 3
+
- False
+ True
+
+
+ 00:00:02
\ No newline at end of file
diff --git a/Resources/ApplicationIcon.ico b/Resources/Application.ico
similarity index 100%
rename from Resources/ApplicationIcon.ico
rename to Resources/Application.ico
diff --git a/SettingsWindow/AboutSettingsPanel.xaml b/SettingsWindow/AboutSettingsPanel.xaml
new file mode 100644
index 0000000..6c9f61a
--- /dev/null
+++ b/SettingsWindow/AboutSettingsPanel.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SettingsWindow/AboutSettingsPanel.xaml.cs b/SettingsWindow/AboutSettingsPanel.xaml.cs
new file mode 100644
index 0000000..360fec0
--- /dev/null
+++ b/SettingsWindow/AboutSettingsPanel.xaml.cs
@@ -0,0 +1,12 @@
+namespace ProcessCpuUsageStatusWindow.SettingsWindow
+{
+ public partial class AboutSettingsPanel
+ {
+ public AboutSettingsPanel()
+ {
+ InitializeComponent();
+ }
+
+ public override string CategoryName => Properties.Resources.optionCategoryAbout;
+ }
+}
\ No newline at end of file
diff --git a/SettingsWindow/GeneralSettingsPanel.xaml b/SettingsWindow/GeneralSettingsPanel.xaml
new file mode 100644
index 0000000..3995f81
--- /dev/null
+++ b/SettingsWindow/GeneralSettingsPanel.xaml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SettingsWindow/GeneralSettingsPanel.xaml.cs b/SettingsWindow/GeneralSettingsPanel.xaml.cs
new file mode 100644
index 0000000..6dd8503
--- /dev/null
+++ b/SettingsWindow/GeneralSettingsPanel.xaml.cs
@@ -0,0 +1,36 @@
+using System.Windows;
+using ChrisKaczor.Wpf.Application;
+using ProcessCpuUsageStatusWindow.Properties;
+
+namespace ProcessCpuUsageStatusWindow.SettingsWindow;
+
+public partial class GeneralSettingsPanel
+{
+ public GeneralSettingsPanel()
+ {
+ InitializeComponent();
+ }
+
+ public override string CategoryName => Properties.Resources.optionCategoryGeneral;
+
+ public override void LoadPanel(Window parentWindow)
+ {
+ base.LoadPanel(parentWindow);
+
+ MarkLoaded();
+ }
+
+ private void OnSaveSettings(object sender, RoutedEventArgs e)
+ {
+ SaveSettings();
+ }
+
+ private void SaveSettings()
+ {
+ if (!HasLoaded) return;
+
+ Settings.Default.Save();
+
+ Application.Current.SetStartWithWindows(Settings.Default.AutoStart);
+ }
+}
\ No newline at end of file
diff --git a/SettingsWindow/UpdateSettingsPanel.xaml b/SettingsWindow/UpdateSettingsPanel.xaml
new file mode 100644
index 0000000..62c2ae7
--- /dev/null
+++ b/SettingsWindow/UpdateSettingsPanel.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SettingsWindow/UpdateSettingsPanel.xaml.cs b/SettingsWindow/UpdateSettingsPanel.xaml.cs
new file mode 100644
index 0000000..367a81a
--- /dev/null
+++ b/SettingsWindow/UpdateSettingsPanel.xaml.cs
@@ -0,0 +1,38 @@
+using System.Windows;
+using System.Windows.Input;
+using ProcessCpuUsageStatusWindow.Properties;
+
+namespace ProcessCpuUsageStatusWindow.SettingsWindow;
+
+public partial class UpdateSettingsPanel
+{
+ public UpdateSettingsPanel()
+ {
+ InitializeComponent();
+ }
+
+ public override string CategoryName => Properties.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();
+ }
+}
\ No newline at end of file
diff --git a/UpdateCheck.cs b/UpdateCheck.cs
index 212612d..cfd303d 100644
--- a/UpdateCheck.cs
+++ b/UpdateCheck.cs
@@ -1,71 +1,50 @@
-using Squirrel;
-using System;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
+using System.Windows;
+using NuGet.Versioning;
+using Serilog;
+using Velopack;
+using Velopack.Sources;
-namespace ProcessCpuUsageStatusWindow
+namespace ProcessCpuUsageStatusWindow;
+
+internal static class UpdateCheck
{
- public static class UpdateCheck
+ private static UpdateManager _updateManager;
+
+ public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GithubSource("https://github.com/ckaczor/ProcessCpuUsageStatusWindow", 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)
{
- public enum UpdateStatus
+ var newVersion = IsInstalled ? await UpdateManager.CheckForUpdatesAsync() : null;
+
+ if (newVersion != null)
{
- Checking,
- None,
- Downloading,
- Installing,
- Restarting
+ var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
+
+ var updateCheckMessage = string.Format(Properties.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);
}
-
- public delegate void UpdateStatusDelegate(UpdateStatus updateStatus, string message);
-
- public static Version LocalVersion => Assembly.GetEntryAssembly().GetName().Version;
-
- public static async Task CheckUpdate(UpdateStatusDelegate onUpdateStatus)
+ else if (showIfCurrent)
{
- try
- {
- onUpdateStatus.Invoke(UpdateStatus.Checking, Properties.Resources.CheckingForUpdate);
+ var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ var updateCheckMessage = string.Format(Properties.Resources.UpdateCheckCurrent, Properties.Resources.ApplicationName);
- using (var updateManager = await UpdateManager.GitHubUpdateManager(App.UpdateUrl))
- {
- var updates = await updateManager.CheckForUpdate();
-
- var lastVersion = updates?.ReleasesToApply?.OrderBy(releaseEntry => releaseEntry.Version).LastOrDefault();
-
- if (lastVersion == null)
- {
- onUpdateStatus.Invoke(UpdateStatus.None, Properties.Resources.NoUpdate);
- return false;
- }
-
- onUpdateStatus.Invoke(UpdateStatus.Downloading, Properties.Resources.DownloadingUpdate);
-
- Common.Settings.Extensions.BackupSettings();
-
- await updateManager.DownloadReleases(new[] { lastVersion });
-
- onUpdateStatus.Invoke(UpdateStatus.Installing, Properties.Resources.InstallingUpdate);
-
- await updateManager.ApplyReleases(updates);
- await updateManager.UpdateApp();
- }
-
- onUpdateStatus.Invoke(UpdateStatus.Restarting, Properties.Resources.RestartingAfterUpdate);
-
- UpdateManager.RestartApp();
-
- return true;
- }
- catch (Exception exception)
- {
- Console.WriteLine(exception);
-
- return false;
- }
+ MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
-}
+}
\ No newline at end of file
diff --git a/WindowSource.cs b/WindowSource.cs
index 6f8b5d7..0dc8bb9 100644
--- a/WindowSource.cs
+++ b/WindowSource.cs
@@ -1,7 +1,8 @@
-using Common.Wpf.Windows;
-using FloatingStatusWindowLibrary;
-using ProcessCpuUsageStatusWindow.Options;
+using ChrisKaczor.Wpf.Windows;
+using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using ProcessCpuUsageStatusWindow.Properties;
+using ProcessCpuUsageStatusWindow.SettingsWindow;
+using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,179 +10,200 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
-namespace ProcessCpuUsageStatusWindow
+namespace ProcessCpuUsageStatusWindow;
+
+internal class WindowSource : IWindowSource, IDisposable
{
- public class WindowSource : IWindowSource, IDisposable
+ private readonly FloatingStatusWindow _floatingStatusWindow;
+ private readonly Dispatcher _dispatcher;
+ private readonly ProcessCpuUsageWatcher _processCpuUsageWatcher;
+
+ internal WindowSource()
{
- private readonly FloatingStatusWindow _floatingStatusWindow;
- private readonly ProcessCpuUsageWatcher _processCpuUsageWatcher;
- private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
+ _floatingStatusWindow = new FloatingStatusWindow(this);
+ _floatingStatusWindow.SetText(Resources.Loading);
- private CategoryWindow _optionsWindow;
+ _dispatcher = Dispatcher.CurrentDispatcher;
- internal WindowSource()
+ _processCpuUsageWatcher = new ProcessCpuUsageWatcher();
+
+ Task.Factory.StartNew(UpdateApp).ContinueWith(task => Start(task.Result.Result));
+ }
+
+ private async Task UpdateApp()
+ {
+ try
{
- _floatingStatusWindow = new FloatingStatusWindow(this);
- _floatingStatusWindow.SetText(Resources.Loading);
+ if (!UpdateCheck.IsInstalled)
+ return false;
- _processCpuUsageWatcher = new ProcessCpuUsageWatcher();
+ if (!Settings.Default.CheckVersionAtStartup)
+ return false;
- Task.Factory.StartNew(UpdateApp).ContinueWith(task => StartUpdate(task.Result.Result));
+ 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));
}
- private void StartUpdate(bool updateRequired)
- {
- if (updateRequired)
- return;
+ return true;
+ }
- Task.Factory.StartNew(() => _processCpuUsageWatcher.Initialize(Settings.Default.UpdateInterval, UpdateDisplay, _dispatcher));
+ private void Start(bool hasUpdate)
+ {
+ Log.Logger.Information("Start: hasUpdate={HasUpdate}", hasUpdate);
+
+ if (hasUpdate)
+ return;
+
+ Log.Logger.Information("Load");
+
+ Load();
+ }
+
+ private void Load()
+ {
+ Task.Factory.StartNew(() => _processCpuUsageWatcher.Initialize(Settings.Default.UpdateInterval, UpdateDisplay, _dispatcher));
+ }
+
+ private static void Save()
+ {
+ }
+
+ public void Dispose()
+ {
+ _processCpuUsageWatcher.Terminate();
+
+ _floatingStatusWindow.Save();
+ _floatingStatusWindow.Dispose();
+ }
+
+ public Guid Id => Guid.Parse("D2DFC480-891F-4C66-B344-69D420561A11");
+
+ 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
+ {
+ new GeneralSettingsPanel(),
+ new UpdateSettingsPanel(),
+ new AboutSettingsPanel()
+ };
+
+ var settingsWindow = new CategoryWindow(categoryPanels, Resources.SettingsTitle, Resources.CloseButtonText);
+
+ settingsWindow.ShowDialog();
+
+ Save();
+ }
+
+ public bool HasRefreshMenu => false;
+
+ public void Refresh()
+ {
+ UpdateDisplay(_processCpuUsageWatcher.CurrentProcessList);
+ }
+
+ public string WindowSettings
+ {
+ get => Settings.Default.WindowSettings;
+ set
+ {
+ Settings.Default.WindowSettings = value;
+ Settings.Default.Save();
}
+ }
- private async Task UpdateApp()
+ private static class PredefinedProcessName
+ {
+ public const string Total = "_Total";
+ public const string Idle = "Idle";
+ public const string IdleWithProcessId = "Idle:0";
+ }
+
+ private void UpdateDisplay(Dictionary currentProcessList)
+ {
+ // Filter the process list to valid ones and exclude the idle and total values
+ var validProcessList = currentProcessList.Values.Where(process =>
+ process.UsageValid && process.ProcessName != PredefinedProcessName.Total &&
+ process.ProcessName != (_processCpuUsageWatcher.IsV2 ? PredefinedProcessName.IdleWithProcessId : PredefinedProcessName.Idle)).ToList();
+
+ // Calculate the total usage by adding up all the processes we know about
+ var totalUsage = validProcessList.Sum(process => process.PercentUsage);
+
+ // Sort the process list by usage and take only the top few
+ var sortedProcessList = validProcessList.OrderByDescending(process => process.PercentUsage).Take(Settings.Default.ProcessCount);
+
+ // Create a new string builder
+ var stringBuilder = new StringBuilder();
+
+ // Loop over all processes in the sorted list
+ foreach (var processCpuUsage in sortedProcessList)
{
- return await UpdateCheck.CheckUpdate(HandleUpdateStatus);
- }
-
- private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message)
- {
- if (status == UpdateCheck.UpdateStatus.None)
- message = Resources.Loading;
-
- _dispatcher.Invoke(() => _floatingStatusWindow.SetText(message));
- }
-
- public void Dispose()
- {
- _processCpuUsageWatcher.Terminate();
-
- _floatingStatusWindow.Save();
- _floatingStatusWindow.Dispose();
- }
-
- public void ShowSettings()
- {
- var panels = new List
- {
- new GeneralOptionsPanel(_processCpuUsageWatcher.IsV2),
- new AboutOptionsPanel()
- };
-
- if (_optionsWindow == null)
- {
- _optionsWindow = new CategoryWindow(null, panels, Resources.ResourceManager, "OptionsWindow");
- _optionsWindow.Closed += (o, args) => { _optionsWindow = null; };
- }
-
- var dialogResult = _optionsWindow.ShowDialog();
-
- if (dialogResult.HasValue && dialogResult.Value)
- {
- Settings.Default.Save();
-
- Refresh();
- }
- }
-
- public void Refresh()
- {
- UpdateDisplay(_processCpuUsageWatcher.CurrentProcessList);
- }
-
- public string Name => Resources.ApplicationName;
-
- public System.Drawing.Icon Icon => Resources.ApplicationIcon;
-
- public bool HasSettingsMenu => true;
- public bool HasRefreshMenu => true;
- public bool HasAboutMenu => false;
-
- public void ShowAbout()
- {
- }
-
- public string WindowSettings
- {
- get => Settings.Default.WindowSettings;
- set
- {
- Settings.Default.WindowSettings = value;
- Settings.Default.Save();
- }
- }
-
- #region Display updating
-
- private static class PredefinedProcessName
- {
- public const string Total = "_Total";
- public const string Idle = "Idle";
- public const string IdleWithProcessId = "Idle:0";
- }
-
- private void UpdateDisplay(Dictionary currentProcessList)
- {
- // Filter the process list to valid ones and exclude the idle and total values
- var validProcessList = (currentProcessList.Values.Where(
- process =>
- process.UsageValid && process.ProcessName != PredefinedProcessName.Total &&
- process.ProcessName != (_processCpuUsageWatcher.IsV2 ? PredefinedProcessName.IdleWithProcessId : PredefinedProcessName.Idle))).ToList();
-
- // Calculate the total usage by adding up all the processes we know about
- var totalUsage = validProcessList.Sum(process => process.PercentUsage);
-
- // Sort the process list by usage and take only the top few
- var sortedProcessList = validProcessList.OrderByDescending(process => process.PercentUsage).Take(Settings.Default.ProcessCount);
-
- // Create a new string builder
- var stringBuilder = new StringBuilder();
-
- // Add the header line (if any)
- if (Resources.HeaderLine.Length > 0)
- {
- stringBuilder.AppendFormat(Resources.HeaderLine, totalUsage);
+ // Move to the next line if it isn't the first line
+ if (stringBuilder.Length != 0)
stringBuilder.AppendLine();
- stringBuilder.AppendLine();
- }
- // Loop over all processes in the sorted list
- foreach (var processCpuUsage in sortedProcessList)
+ if (_processCpuUsageWatcher.IsV2)
{
- // Move to the next line if it isn't the first line
- if (stringBuilder.Length != 0)
- stringBuilder.AppendLine();
+ // Split the process name from the process ID
+ var colonPosition = processCpuUsage.ProcessName.LastIndexOf(':');
- if (_processCpuUsageWatcher.IsV2)
- {
- // Split the process name from the process ID
- var colonPosition = processCpuUsage.ProcessName.LastIndexOf(':');
+ var processName = processCpuUsage.ProcessName[..colonPosition];
+ var processId = processCpuUsage.ProcessName[(colonPosition + 1)..];
- var processName = processCpuUsage.ProcessName.Substring(0, colonPosition);
- var processId = processCpuUsage.ProcessName.Substring(colonPosition + 1);
+ var formatString = Settings.Default.ShowProcessId ? Resources.ProcessLineWithProcessId : Resources.ProcessLine;
- var formatString = Settings.Default.ShowProcessId ? Resources.ProcessLineWithProcessId : Resources.ProcessLine;
-
- // Format the process information into a string to display
- stringBuilder.AppendFormat(formatString, processName, processCpuUsage.PercentUsage, processId);
- }
- else
- {
- // Format the process information into a string to display
- stringBuilder.AppendFormat(Resources.ProcessLine, processCpuUsage.ProcessName, processCpuUsage.PercentUsage);
- }
+ // Format the process information into a string to display
+ stringBuilder.AppendFormat(formatString, processName, processCpuUsage.PercentUsage, processId);
}
-
- // Add the footer line (if any)
- if (Resources.FooterLine.Length > 0)
+ else
{
- stringBuilder.AppendLine();
- stringBuilder.AppendLine();
- stringBuilder.AppendFormat(Resources.FooterLine, totalUsage);
+ // Format the process information into a string to display
+ stringBuilder.AppendFormat(Resources.ProcessLine, processCpuUsage.ProcessName, processCpuUsage.PercentUsage);
}
-
- // Update the window with the text
- _floatingStatusWindow.SetText(stringBuilder.ToString());
}
- #endregion
+ // Add the footer line (if any)
+ if (Resources.FooterLine.Length > 0)
+ {
+ stringBuilder.AppendLine();
+ stringBuilder.AppendLine();
+ stringBuilder.AppendFormat(Resources.FooterLine, totalUsage);
+ }
+
+ // Update the window with the text
+ _floatingStatusWindow.SetText(stringBuilder.ToString());
}
}
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 3e6bf06..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-version: 1.0.{build}
-pull_requests:
- do_not_increment_build_number: true
-skip_tags: true
-image: Visual Studio 2017
-configuration: Release
-assembly_info:
- patch: true
- file: 'Properties\AssemblyInfo.cs'
- assembly_version: '{version}'
- assembly_file_version: '{version}'
-build:
- project: ProcessCpuUsageStatusWindow.sln
- verbosity: minimal
-after_build:
-- ps: >-
- nuget pack ProcessCpuUsageStatusWindow.nuspec -Version $env:APPVEYOR_BUILD_VERSION -Properties Configuration=Release -OutputDirectory bin\Release\
-
- $squirrel = ".\packages\squirrel.windows.*\tools\Squirrel.exe"
-
- .$squirrel -releasify ".\bin\$env:CONFIGURATION\ProcessCpuUsageStatusWindow.$env:APPVEYOR_BUILD_VERSION.nupkg" | Write-Output
-artifacts:
-- path: Releases\*
- name: Releases
-deploy:
-- provider: Environment
- name: GitHub
-install:
-- cmd: git submodule update --init --recursive
-before_build:
-- cmd: nuget restore
\ No newline at end of file
diff --git a/packages.config b/packages.config
deleted file mode 100644
index 4bc1748..0000000
--- a/packages.config
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file