mirror of
https://github.com/ckaczor/ProcessCpuUsageStatusWindow.git
synced 2026-03-10 12:01:38 -04:00
Modernize project
This commit is contained in:
63
.gitattributes
vendored
63
.gitattributes
vendored
@@ -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
|
||||
36
.github/workflows/main.yml
vendored
Normal file
36
.github/workflows/main.yml
vendored
Normal file
@@ -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 }}
|
||||
317
.gitignore
vendored
317
.gitignore
vendored
@@ -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/
|
||||
# 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
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "Common"]
|
||||
path = Common
|
||||
url = https://github.com/ckaczor/Common.git
|
||||
67
App.config
67
App.config
@@ -1,37 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<?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="ProcessCpuUsageStatusWindow.Properties.Settings"
|
||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
||||
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="ProcessCpuUsageStatusWindow.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<ProcessCpuUsageStatusWindow.Properties.Settings>
|
||||
<setting name="ProcessCount" serializeAs="String">
|
||||
<value>3</value>
|
||||
</setting>
|
||||
<setting name="UpdateInterval" serializeAs="String">
|
||||
<value>00:00:02</value>
|
||||
</setting>
|
||||
<setting name="WindowSettings" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="AutoStart" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="FirstRun" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="ShowProcessId" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</ProcessCpuUsageStatusWindow.Properties.Settings>
|
||||
</userSettings>
|
||||
<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="Items" serializeAs="String">
|
||||
<value>[]</value>
|
||||
</setting>
|
||||
<setting name="ProcessCount" serializeAs="String">
|
||||
<value>3</value>
|
||||
</setting>
|
||||
<setting name="ShowProcessId" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="UpdateInterval" serializeAs="String">
|
||||
<value>00:00:02</value>
|
||||
</setting>
|
||||
</ProcessCpuUsageStatusWindow.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
2
App.xaml
2
App.xaml
@@ -1,6 +1,6 @@
|
||||
<Application x:Class="ProcessCpuUsageStatusWindow.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ShutdownMode="OnLastWindowClose">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
|
||||
68
App.xaml.cs
68
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<IDisposable> _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);
|
||||
}
|
||||
}
|
||||
1
Common
1
Common
Submodule Common deleted from ecd3717eab
@@ -1,46 +0,0 @@
|
||||
<windows:CategoryPanel x:Class="ProcessCpuUsageStatusWindow.Options.AboutOptionsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
|
||||
xmlns:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="[Application Name]"
|
||||
Name="ApplicationNameLabel"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
Grid.Row="0" />
|
||||
<TextBlock Text="[Application Version]"
|
||||
Margin="0,6,0,0"
|
||||
Name="VersionLabel"
|
||||
VerticalAlignment="Top"
|
||||
Grid.Row="1" />
|
||||
<TextBlock Text="[Company]"
|
||||
Margin="0,6,0,0"
|
||||
Name="CompanyLabel"
|
||||
VerticalAlignment="Top"
|
||||
Grid.Row="2" />
|
||||
<StackPanel Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="0,20,0,0"
|
||||
Orientation="Horizontal">
|
||||
<Button Content="{x:Static properties:Resources.CheckUpdate}"
|
||||
HorizontalAlignment="Left"
|
||||
Padding="6,2"
|
||||
Click="HandleCheckForUpdateButtonClick"
|
||||
VerticalContentAlignment="Center" />
|
||||
<Label Name="UpdateMessage" Content="" VerticalContentAlignment="Center" Padding="6,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</windows:CategoryPanel>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<windows:CategoryPanel x:Class="ProcessCpuUsageStatusWindow.Options.GeneralOptionsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
|
||||
xmlns:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Content="{x:Static properties:Resources.StartWithWindows}"
|
||||
Name="StartWithWindows"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="2" />
|
||||
<Label Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Content="{x:Static properties:Resources.NumberOfProcesses}"
|
||||
Margin="0,4,6,4"
|
||||
Padding="0"
|
||||
VerticalContentAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Target="{x:Reference NumberOfProcesses}" />
|
||||
<xctk:IntegerUpDown Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
x:Name="NumberOfProcesses"
|
||||
Minimum="1"
|
||||
Maximum="20"
|
||||
TextAlignment="Left"
|
||||
Margin="0,12,6,12"
|
||||
Width="50"
|
||||
VerticalContentAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" />
|
||||
<CheckBox Content="{x:Static properties:Resources.ShowProcessId}"
|
||||
Name="ShowProcessId"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Grid.Column="0"
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
</windows:CategoryPanel>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,202 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C3C29363-2E3C-4478-B2A6-125DEA683E0D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ProcessCpuUsageStatusWindow</RootNamespace>
|
||||
<AssemblyName>ProcessCpuUsageStatusWindow</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Common.Native, Version=1.0.6627.16339, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Native.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Common.Wpf, Version=1.0.6627.16340, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.1.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
|
||||
<HintPath>packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
|
||||
<HintPath>packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FloatingStatusWindowLibrary, Version=1.0.0.9, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\FloatingStatusWindowLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\Microsoft.Expression.Interactions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\squirrel.windows.1.7.9\lib\Net45\NuGet.Squirrel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpCompress, Version=0.17.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
|
||||
<HintPath>packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Squirrel, Version=1.7.9.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\squirrel.windows.1.7.9\lib\Net45\Squirrel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Xceed.Wpf.AvalonDock, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.DataGrid, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.Toolkit, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Options\AboutOptionsPanel.xaml.cs">
|
||||
<DependentUpon>AboutOptionsPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Options\GeneralOptionsPanel.xaml.cs">
|
||||
<DependentUpon>GeneralOptionsPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UpdateCheck.cs" />
|
||||
<Compile Include="WindowSource.cs" />
|
||||
<Page Include="Options\AboutOptionsPanel.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Options\GeneralOptionsPanel.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ProcessCpuUsage.cs" />
|
||||
<Compile Include="ProcessCpuUsageWatcher.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="appveyor.yml" />
|
||||
<None Include="LICENSE.md" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="ProcessCpuUsageStatusWindow.nuspec" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
<None Include="Resources\ApplicationIcon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="Common\Common.csproj">
|
||||
<Project>{17864d82-457d-4a0a-bc10-1d07f2b3a5d6}</Project>
|
||||
<Name>Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0-windows7.0</TargetFramework>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
<StartupObject>ProcessCpuUsageStatusWindow.Program</StartupObject>
|
||||
<ApplicationIcon>Resources\Application.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Application.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.CategoryWindow" Version="1.0.2" />
|
||||
<PackageReference Include="ChrisKaczor.Wpf.Windows.FloatingStatusWindow" Version="2.0.0.8" />
|
||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
<PackageReference Include="Velopack" Version="0.0.626" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".github\workflows\main.yml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>ProcessCpuUsageStatusWindow</id>
|
||||
<title>CPU Usage Status Window</title>
|
||||
<version>$version$</version>
|
||||
<authors>Chris Kaczor</authors>
|
||||
<description>A "floating" status window that shows the top X processes by CPU usage.</description>
|
||||
<projectUrl>https://github.com/ckaczor/ProcessCpuUsageStatusWindow</projectUrl>
|
||||
<licenseUrl>https://raw.githubusercontent.com/ckaczor/ProcessCpuUsageStatusWindow/master/LICENSE.md</licenseUrl>
|
||||
<tags>cpu</tags>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="bin\$configuration$\**\*" target="lib\net45" exclude="*.pdb;*.nupkg;*.vshost.*" />
|
||||
</files>
|
||||
</package>
|
||||
@@ -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
|
||||
4
ProcessCpuUsageStatusWindow.sln.DotSettings
Normal file
4
ProcessCpuUsageStatusWindow.sln.DotSettings
Normal file
@@ -0,0 +1,4 @@
|
||||
<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/=Kaczor/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
</wpf:ResourceDictionary>
|
||||
3
ProcessCpuUsageStatusWindow.slnx
Normal file
3
ProcessCpuUsageStatusWindow.slnx
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution>
|
||||
<Project Path="ProcessCpuUsageStatusWindow.csproj" />
|
||||
</Solution>
|
||||
@@ -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<string, ProcessCpuUsage> currentProcessList);
|
||||
|
||||
private Dispatcher _dispatcher;
|
||||
private Timer _processUpdateTimer;
|
||||
private ProcessListUpdatedDelegate _processListUpdatedCallback;
|
||||
private PerformanceCounterCategory _processCategory;
|
||||
|
||||
public Dictionary<string, ProcessCpuUsage> 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<string, ProcessCpuUsage> currentProcessList);
|
||||
// Create a new dictionary for the process list
|
||||
CurrentProcessList = new Dictionary<string, ProcessCpuUsage>();
|
||||
|
||||
#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<string, ProcessCpuUsage> 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<string, ProcessCpuUsage>();
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
27
Program.cs
Normal file
27
Program.cs
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
250
Properties/Resources.Designer.cs
generated
250
Properties/Resources.Designer.cs
generated
@@ -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 {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version: {0}.
|
||||
/// Looks up a localized string similar to Add.
|
||||
/// </summary>
|
||||
public static string About_Version {
|
||||
public static string AddItemLink {
|
||||
get {
|
||||
return ResourceManager.GetString("About_Version", resourceCulture);
|
||||
return ResourceManager.GetString("AddItemLink", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add Item.
|
||||
/// </summary>
|
||||
public static string AddItemToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("AddItemToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +89,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Process CPU Usage.
|
||||
/// Looks up a localized string similar to Process CPU Usage Status Window.
|
||||
/// </summary>
|
||||
public static string ApplicationName {
|
||||
get {
|
||||
@@ -88,6 +97,15 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -106,6 +124,69 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 items?.
|
||||
/// </summary>
|
||||
public static string ConfirmDeleteItemss {
|
||||
get {
|
||||
return ResourceManager.GetString("ConfirmDeleteItemss", 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 DeleteItemLink {
|
||||
get {
|
||||
return ResourceManager.GetString("DeleteItemLink", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete Item.
|
||||
/// </summary>
|
||||
public static string DeleteItemToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("DeleteItemToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Downloading update....
|
||||
/// </summary>
|
||||
@@ -115,6 +196,24 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit.
|
||||
/// </summary>
|
||||
public static string EditItemLink {
|
||||
get {
|
||||
return ResourceManager.GetString("EditItemLink", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit Item.
|
||||
/// </summary>
|
||||
public static string EditItemToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("EditItemToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to CPU: {0,4:f1}% - Total.
|
||||
/// </summary>
|
||||
@@ -124,15 +223,6 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to .
|
||||
/// </summary>
|
||||
public static string HeaderLine {
|
||||
get {
|
||||
return ResourceManager.GetString("HeaderLine", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Installing update....
|
||||
/// </summary>
|
||||
@@ -142,6 +232,33 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Item.
|
||||
/// </summary>
|
||||
public static string ItemColumnHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("ItemColumnHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add Item.
|
||||
/// </summary>
|
||||
public static string ItemWindowAdd {
|
||||
get {
|
||||
return ResourceManager.GetString("ItemWindowAdd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit Item.
|
||||
/// </summary>
|
||||
public static string ItemWindowEdit {
|
||||
get {
|
||||
return ResourceManager.GetString("ItemWindowEdit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Loading....
|
||||
/// </summary>
|
||||
@@ -152,11 +269,11 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No update found.
|
||||
/// Looks up a localized string similar to Name.
|
||||
/// </summary>
|
||||
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 {
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 OptionCategory_About {
|
||||
public static string optionCategoryAbout {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionCategory_About", resourceCulture);
|
||||
return ResourceManager.GetString("optionCategoryAbout", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to General.
|
||||
/// </summary>
|
||||
public static string OptionCategory_General {
|
||||
public static string optionCategoryGeneral {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionCategory_General", resourceCulture);
|
||||
return ResourceManager.GetString("optionCategoryGeneral", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cancel.
|
||||
/// Looks up a localized string similar to Items.
|
||||
/// </summary>
|
||||
public static string OptionsWindow_CancelButton {
|
||||
public static string optionCategoryItems {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionsWindow_CancelButton", resourceCulture);
|
||||
return ResourceManager.GetString("optionCategoryItems", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// Looks up a localized string similar to Update.
|
||||
/// </summary>
|
||||
public static System.Drawing.Icon OptionsWindow_Icon {
|
||||
public static string optionCategoryUpdate {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("OptionsWindow_Icon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to OK.
|
||||
/// </summary>
|
||||
public static string OptionsWindow_OkayButton {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionsWindow_OkayButton", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Options.
|
||||
/// </summary>
|
||||
public static string OptionsWindow_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionsWindow_Title", resourceCulture);
|
||||
return ResourceManager.GetString("optionCategoryUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,38 +350,69 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Restarting application....
|
||||
/// Looks up a localized string similar to Settings.
|
||||
/// </summary>
|
||||
public static string RestartingAfterUpdate {
|
||||
public static string SettingsTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("RestartingAfterUpdate", resourceCulture);
|
||||
return ResourceManager.GetString("SettingsTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show _process ID.
|
||||
/// </summary>
|
||||
public static string ShowProcessId {
|
||||
public static string showProcessId {
|
||||
get {
|
||||
return ResourceManager.GetString("ShowProcessId", resourceCulture);
|
||||
return ResourceManager.GetString("showProcessId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Start when Windows starts.
|
||||
/// </summary>
|
||||
public static string StartWithWindows {
|
||||
public static string startWithWindowsCheckBox {
|
||||
get {
|
||||
return ResourceManager.GetString("StartWithWindows", resourceCulture);
|
||||
return ResourceManager.GetString("startWithWindowsCheckBox", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
public static string Updating {
|
||||
public static string UpdateCheckCurrent {
|
||||
get {
|
||||
return ResourceManager.GetString("Updating", resourceCulture);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,77 +117,126 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Version" xml:space="preserve">
|
||||
<value>Version: {0}</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\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ApplicationName" xml:space="preserve">
|
||||
<value>Process CPU Usage</value>
|
||||
<value>Process CPU Usage Status Window</value>
|
||||
</data>
|
||||
<data name="CheckingForUpdate" xml:space="preserve">
|
||||
<value>Checking for update...</value>
|
||||
<data name="optionCategoryAbout" xml:space="preserve">
|
||||
<value>About</value>
|
||||
</data>
|
||||
<data name="CheckUpdate" xml:space="preserve">
|
||||
<value>_Check for Update</value>
|
||||
</data>
|
||||
<data name="DownloadingUpdate" xml:space="preserve">
|
||||
<value>Downloading update...</value>
|
||||
<data name="startWithWindowsCheckBox" xml:space="preserve">
|
||||
<value>_Start when Windows starts</value>
|
||||
</data>
|
||||
<data name="FooterLine" xml:space="preserve">
|
||||
<value>CPU: {0,4:f1}% - Total</value>
|
||||
<data name="optionCategoryGeneral" xml:space="preserve">
|
||||
<value>General</value>
|
||||
</data>
|
||||
<data name="HeaderLine" xml:space="preserve">
|
||||
<value />
|
||||
<data name="SettingsTitle" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="InstallingUpdate" xml:space="preserve">
|
||||
<value>Installing update...</value>
|
||||
<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="NoUpdate" xml:space="preserve">
|
||||
<value>No update found</value>
|
||||
<data name="CheckingForUpdate" xml:space="preserve">
|
||||
<value>Checking for update...</value>
|
||||
</data>
|
||||
<data name="NumberOfProcesses" xml:space="preserve">
|
||||
<value>_Number of processes:</value>
|
||||
<data name="DownloadingUpdate" xml:space="preserve">
|
||||
<value>Downloading update...</value>
|
||||
</data>
|
||||
<data name="OptionCategory_About" xml:space="preserve">
|
||||
<value>About</value>
|
||||
<data name="InstallingUpdate" xml:space="preserve">
|
||||
<value>Installing update...</value>
|
||||
</data>
|
||||
<data name="OptionCategory_General" xml:space="preserve">
|
||||
<value>General</value>
|
||||
<data name="optionCategoryItems" xml:space="preserve">
|
||||
<value>Items</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_CancelButton" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
<data name="NameColumnHeader" xml:space="preserve">
|
||||
<value>Name</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="ItemColumnHeader" xml:space="preserve">
|
||||
<value>Item</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_OkayButton" xml:space="preserve">
|
||||
<data name="AddItemLink" xml:space="preserve">
|
||||
<value>Add</value>
|
||||
</data>
|
||||
<data name="EditItemLink" xml:space="preserve">
|
||||
<value>Edit</value>
|
||||
</data>
|
||||
<data name="DeleteItemLink" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="AddItemToolTip" xml:space="preserve">
|
||||
<value>Add Item</value>
|
||||
</data>
|
||||
<data name="EditItemToolTip" xml:space="preserve">
|
||||
<value>Edit Item</value>
|
||||
</data>
|
||||
<data name="DeleteItemToolTip" xml:space="preserve">
|
||||
<value>Delete Item</value>
|
||||
</data>
|
||||
<data name="ConfirmDeleteTitle" xml:space="preserve">
|
||||
<value>Confirm Delete</value>
|
||||
</data>
|
||||
<data name="ConfirmDeleteItemss" xml:space="preserve">
|
||||
<value>Are you sure you want to delete the selected items?</value>
|
||||
</data>
|
||||
<data name="ItemWindowAdd" xml:space="preserve">
|
||||
<value>Add Item</value>
|
||||
</data>
|
||||
<data name="ItemWindowEdit" xml:space="preserve">
|
||||
<value>Edit Item</value>
|
||||
</data>
|
||||
<data name="OkayButton" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_Title" xml:space="preserve">
|
||||
<value>Options</value>
|
||||
<data name="CancelButton" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="FooterLine" xml:space="preserve">
|
||||
<value>CPU: {0,4:f1}% - Total</value>
|
||||
</data>
|
||||
<data name="ProcessLine" xml:space="preserve">
|
||||
<value>CPU: {1,4:f1}% - {0}</value>
|
||||
</data>
|
||||
<data name="StartWithWindows" xml:space="preserve">
|
||||
<value>_Start when Windows starts</value>
|
||||
</data>
|
||||
<data name="Updating" xml:space="preserve">
|
||||
<value>Updating application...</value>
|
||||
</data>
|
||||
<data name="RestartingAfterUpdate" xml:space="preserve">
|
||||
<value>Restarting application...</value>
|
||||
</data>
|
||||
<data name="ProcessLineWithProcessId" xml:space="preserve">
|
||||
<value>CPU: {1,4:f1}% - {0} ({2})</value>
|
||||
</data>
|
||||
<data name="ShowProcessId" xml:space="preserve">
|
||||
<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="showProcessId" xml:space="preserve">
|
||||
<value>Show _process ID</value>
|
||||
</data>
|
||||
<data name="NumberOfProcesses" xml:space="preserve">
|
||||
<value>_Number of processes:</value>
|
||||
</data>
|
||||
</root>
|
||||
70
Properties/Settings.Designer.cs
generated
70
Properties/Settings.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,23 +2,26 @@
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ProcessCpuUsageStatusWindow.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="ProcessCount" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">3</Value>
|
||||
</Setting>
|
||||
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="User">
|
||||
<Value Profile="(Default)">00:00:02</Value>
|
||||
</Setting>
|
||||
<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="FirstRun" Type="System.Boolean" Scope="User">
|
||||
<Setting Name="CheckVersionAtStartup" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="Items" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">[]</Value>
|
||||
</Setting>
|
||||
<Setting Name="ProcessCount" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">3</Value>
|
||||
</Setting>
|
||||
<Setting Name="ShowProcessId" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="User">
|
||||
<Value Profile="(Default)">00:00:02</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
21
SettingsWindow/AboutSettingsPanel.xaml
Normal file
21
SettingsWindow/AboutSettingsPanel.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<windows:CategoryPanelBase x:Class="ProcessCpuUsageStatusWindow.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:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:processcpuusagestatuswindow="clr-namespace:ProcessCpuUsageStatusWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<StackPanel windows:Spacing.Vertical="10">
|
||||
<TextBlock Text="{x:Static properties:Resources.ApplicationName}"
|
||||
FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Source={x:Static processcpuusagestatuswindow:UpdateCheck.LocalVersion}, StringFormat={x:Static properties:Resources.Version}}"
|
||||
Name="VersionLabel" />
|
||||
<TextBlock Text="Chris Kaczor" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</windows:CategoryPanelBase>
|
||||
12
SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
12
SettingsWindow/AboutSettingsPanel.xaml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace ProcessCpuUsageStatusWindow.SettingsWindow
|
||||
{
|
||||
public partial class AboutSettingsPanel
|
||||
{
|
||||
public AboutSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.optionCategoryAbout;
|
||||
}
|
||||
}
|
||||
50
SettingsWindow/GeneralSettingsPanel.xaml
Normal file
50
SettingsWindow/GeneralSettingsPanel.xaml
Normal file
@@ -0,0 +1,50 @@
|
||||
<windows:CategoryPanelBase x:Class="ProcessCpuUsageStatusWindow.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:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
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>
|
||||
<StackPanel>
|
||||
<CheckBox
|
||||
Content="{x:Static properties:Resources.startWithWindowsCheckBox}"
|
||||
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=AutoStart}"
|
||||
Margin="0,0,0,16"
|
||||
Click="OnSaveSettings" />
|
||||
<StackPanel
|
||||
Margin="0,0,0,10"
|
||||
Orientation="Horizontal">
|
||||
<Label Content="{x:Static properties:Resources.NumberOfProcesses}"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
Padding="0" />
|
||||
<mah:NumericUpDown Width="75"
|
||||
Maximum="20"
|
||||
Minimum="1"
|
||||
Value="{Binding Source={x:Static properties:Settings.Default}, Path=ProcessCount}"
|
||||
ValueChanged="OnSaveSettings" />
|
||||
</StackPanel>
|
||||
<CheckBox
|
||||
Content="{x:Static properties:Resources.showProcessId}"
|
||||
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=ShowProcessId}"
|
||||
Click="OnSaveSettings" />
|
||||
</StackPanel>
|
||||
</windows:CategoryPanelBase>
|
||||
36
SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
36
SettingsWindow/GeneralSettingsPanel.xaml.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
21
SettingsWindow/UpdateSettingsPanel.xaml
Normal file
21
SettingsWindow/UpdateSettingsPanel.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<windows:CategoryPanelBase x:Class="ProcessCpuUsageStatusWindow.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:properties="clr-namespace:ProcessCpuUsageStatusWindow.Properties"
|
||||
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.CategoryWindow"
|
||||
xmlns:processcpuusagestatuswindow="clr-namespace:ProcessCpuUsageStatusWindow"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150"
|
||||
d:DesignWidth="250">
|
||||
<StackPanel windows:Spacing.Vertical="10">
|
||||
<CheckBox Content="{x:Static properties:Resources.checkVersionOnStartupCheckBox}"
|
||||
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=CheckVersionAtStartup}"
|
||||
Click="OnSaveSettings" />
|
||||
<Button Content="{x:Static properties:Resources.checkVersionNowButton}"
|
||||
IsEnabled="{Binding Source={x:Static processcpuusagestatuswindow:UpdateCheck.IsInstalled}}"
|
||||
HorizontalAlignment="Left"
|
||||
Click="HandleCheckVersionNowButtonClick" />
|
||||
</StackPanel>
|
||||
</windows:CategoryPanelBase>
|
||||
38
SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
38
SettingsWindow/UpdateSettingsPanel.xaml.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
101
UpdateCheck.cs
101
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<bool> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
328
WindowSource.cs
328
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<bool> 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<CategoryPanelBase>
|
||||
{
|
||||
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<bool> 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<string, ProcessCpuUsage> 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<CategoryPanel>
|
||||
{
|
||||
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<string, ProcessCpuUsage> 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());
|
||||
}
|
||||
}
|
||||
31
appveyor.yml
31
appveyor.yml
@@ -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
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
|
||||
<package id="Extended.Wpf.Toolkit" version="3.2.0" targetFramework="net45" />
|
||||
<package id="FloatingStatusWindow" version="1.0.0.9" targetFramework="net45" />
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net45" />
|
||||
<package id="SharpCompress" version="0.17.1" targetFramework="net45" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="net45" />
|
||||
<package id="squirrel.windows" version="1.7.9" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user