mirror of
https://github.com/ckaczor/ProcessCpuUsageStatusWindow.git
synced 2026-01-14 01:25:41 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eebd23f702 | |||
| ebd9dc607b | |||
| f93983e992 | |||
| d9d0f33788 | |||
| 8f550463b7 | |||
| 15a1ae0e36 |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "Common"]
|
||||
path = Common
|
||||
url = https://github.com/ckaczor/Common.git
|
||||
url = https://github.com/ckaczor/Common.git
|
||||
63
App.config
63
App.config
@@ -1,30 +1,37 @@
|
||||
<?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.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>
|
||||
</ProcessCpuUsageStatusWindow.Properties.Settings>
|
||||
</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.8" />
|
||||
</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>
|
||||
</configuration>
|
||||
46
Options/AboutOptionsPanel.xaml
Normal file
46
Options/AboutOptionsPanel.xaml
Normal file
@@ -0,0 +1,46 @@
|
||||
<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>
|
||||
41
Options/AboutOptionsPanel.xaml.cs
Normal file
41
Options/AboutOptionsPanel.xaml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
Options/GeneralOptionsPanel.xaml
Normal file
57
Options/GeneralOptionsPanel.xaml
Normal file
@@ -0,0 +1,57 @@
|
||||
<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>
|
||||
52
Options/GeneralOptionsPanel.xaml.cs
Normal file
52
Options/GeneralOptionsPanel.xaml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -103,22 +103,22 @@
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Xceed.Wpf.AvalonDock, Version=3.2.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.AvalonDock.dll</HintPath>
|
||||
<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\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
|
||||
<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\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
|
||||
<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\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
|
||||
<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\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.DataGrid.dll</HintPath>
|
||||
<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\FloatingStatusWindow.1.0.0.9\lib\net45\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
<HintPath>packages\Extended.Wpf.Toolkit.3.2.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -130,7 +130,22 @@
|
||||
<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" />
|
||||
@@ -149,8 +164,9 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="appveyor.yml" />
|
||||
<None Include="LICENSE.md" />
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
public Dictionary<string, ProcessCpuUsage> CurrentProcessList;
|
||||
|
||||
public bool IsV2 => _processCategory.CategoryName == "Process V2";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize and terminate
|
||||
@@ -40,18 +42,19 @@ namespace ProcessCpuUsageStatusWindow
|
||||
CurrentProcessList = new Dictionary<string, ProcessCpuUsage>();
|
||||
|
||||
// Get the category for process performance info
|
||||
_processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process");
|
||||
_processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process V2") ??
|
||||
PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process");
|
||||
|
||||
if (_processCategory == null)
|
||||
return;
|
||||
|
||||
// Read the entire category
|
||||
InstanceDataCollectionCollection processCategoryData = _processCategory.ReadCategory();
|
||||
var processCategoryData = _processCategory.ReadCategory();
|
||||
|
||||
// Get the processor time data
|
||||
InstanceDataCollection processorTimeData = processCategoryData["% processor time"];
|
||||
var processorTimeData = processCategoryData["% processor time"];
|
||||
|
||||
if (processorTimeData == null || processorTimeData.Values == null)
|
||||
if (processorTimeData?.Values == null)
|
||||
return;
|
||||
|
||||
// Loop over each instance and add it to the list
|
||||
@@ -109,15 +112,15 @@ namespace ProcessCpuUsageStatusWindow
|
||||
private void UpdateCurrentProcessList()
|
||||
{
|
||||
// Get a timestamp for the current time that we can use to see if a process was found this check
|
||||
DateTime checkStart = DateTime.Now;
|
||||
var checkStart = DateTime.Now;
|
||||
|
||||
// Read the entire category
|
||||
InstanceDataCollectionCollection processCategoryData = _processCategory.ReadCategory();
|
||||
var processCategoryData = _processCategory.ReadCategory();
|
||||
|
||||
// Get the processor time data
|
||||
InstanceDataCollection processorTimeData = processCategoryData["% processor time"];
|
||||
var processorTimeData = processCategoryData["% processor time"];
|
||||
|
||||
if (processorTimeData == null || processorTimeData.Values == null)
|
||||
if (processorTimeData?.Values == null)
|
||||
return;
|
||||
|
||||
// Loop over each instance and add it to the list
|
||||
@@ -127,7 +130,7 @@ namespace ProcessCpuUsageStatusWindow
|
||||
if (CurrentProcessList.ContainsKey(instanceData.InstanceName))
|
||||
{
|
||||
// Get the previous process usage object
|
||||
ProcessCpuUsage processCpuUsage = CurrentProcessList[instanceData.InstanceName];
|
||||
var processCpuUsage = CurrentProcessList[instanceData.InstanceName];
|
||||
|
||||
// Update the CPU usage with new data
|
||||
processCpuUsage.UpdateCpuUsage(instanceData, checkStart);
|
||||
@@ -144,8 +147,8 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
// 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();
|
||||
where processCpuUsage.Value.LastFound != checkStart
|
||||
select processCpuUsage.Key).ToList();
|
||||
|
||||
// Loop over the list and remove the old process
|
||||
foreach (var key in oldProcessList)
|
||||
@@ -157,4 +160,4 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,21 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ProcessCpuUsageStatusWindow")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCompany("Chris Kaczor")]
|
||||
[assembly: AssemblyProduct("ProcessCpuUsageStatusWindow")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
|
||||
176
Properties/Resources.Designer.cs
generated
176
Properties/Resources.Designer.cs
generated
@@ -19,10 +19,10 @@ 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", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
public class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProcessCpuUsageStatusWindow.Properties.Resources", typeof(Resources).Assembly);
|
||||
@@ -51,7 +51,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
@@ -60,10 +60,19 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version: {0}.
|
||||
/// </summary>
|
||||
public static string About_Version {
|
||||
get {
|
||||
return ResourceManager.GetString("About_Version", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon ApplicationIcon {
|
||||
public static System.Drawing.Icon ApplicationIcon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ApplicationIcon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
@@ -73,16 +82,43 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Process CPU Usage.
|
||||
/// </summary>
|
||||
internal static string ApplicationName {
|
||||
public static string ApplicationName {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Checking for update....
|
||||
/// </summary>
|
||||
public static string CheckingForUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("CheckingForUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Check for Update.
|
||||
/// </summary>
|
||||
public static string CheckUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("CheckUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Downloading update....
|
||||
/// </summary>
|
||||
public static string DownloadingUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("DownloadingUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to CPU: {0,4:f1}% - Total.
|
||||
/// </summary>
|
||||
internal static string FooterLine {
|
||||
public static string FooterLine {
|
||||
get {
|
||||
return ResourceManager.GetString("FooterLine", resourceCulture);
|
||||
}
|
||||
@@ -91,34 +127,152 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to .
|
||||
/// </summary>
|
||||
internal static string HeaderLine {
|
||||
public static string HeaderLine {
|
||||
get {
|
||||
return ResourceManager.GetString("HeaderLine", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Installing update....
|
||||
/// </summary>
|
||||
public static string InstallingUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("InstallingUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Loading....
|
||||
/// </summary>
|
||||
internal static string Loading {
|
||||
public static string Loading {
|
||||
get {
|
||||
return ResourceManager.GetString("Loading", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No update found.
|
||||
/// </summary>
|
||||
public static string NoUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("NoUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Number of processes:.
|
||||
/// </summary>
|
||||
public static string NumberOfProcesses {
|
||||
get {
|
||||
return ResourceManager.GetString("NumberOfProcesses", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to About.
|
||||
/// </summary>
|
||||
public static string OptionCategory_About {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionCategory_About", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to General.
|
||||
/// </summary>
|
||||
public static string OptionCategory_General {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionCategory_General", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cancel.
|
||||
/// </summary>
|
||||
public static string OptionsWindow_CancelButton {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionsWindow_CancelButton", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
public static System.Drawing.Icon OptionsWindow_Icon {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to CPU: {1,4:f1}% - {0}.
|
||||
/// </summary>
|
||||
internal static string ProcessLine {
|
||||
public static string ProcessLine {
|
||||
get {
|
||||
return ResourceManager.GetString("ProcessLine", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to CPU: {1,4:f1}% - {0} ({2}).
|
||||
/// </summary>
|
||||
public static string ProcessLineWithProcessId {
|
||||
get {
|
||||
return ResourceManager.GetString("ProcessLineWithProcessId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Restarting application....
|
||||
/// </summary>
|
||||
public static string RestartingAfterUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("RestartingAfterUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show _process ID.
|
||||
/// </summary>
|
||||
public static string ShowProcessId {
|
||||
get {
|
||||
return ResourceManager.GetString("ShowProcessId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Start when Windows starts.
|
||||
/// </summary>
|
||||
public static string StartWithWindows {
|
||||
get {
|
||||
return ResourceManager.GetString("StartWithWindows", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Updating application....
|
||||
/// </summary>
|
||||
internal static string Updating {
|
||||
public static string Updating {
|
||||
get {
|
||||
return ResourceManager.GetString("Updating", resourceCulture);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,9 @@
|
||||
<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>
|
||||
@@ -124,19 +127,67 @@
|
||||
<data name="ApplicationName" xml:space="preserve">
|
||||
<value>Process CPU Usage</value>
|
||||
</data>
|
||||
<data name="CheckingForUpdate" xml:space="preserve">
|
||||
<value>Checking for update...</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>
|
||||
<data name="FooterLine" xml:space="preserve">
|
||||
<value>CPU: {0,4:f1}% - Total</value>
|
||||
</data>
|
||||
<data name="HeaderLine" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="InstallingUpdate" xml:space="preserve">
|
||||
<value>Installing update...</value>
|
||||
</data>
|
||||
<data name="Loading" xml:space="preserve">
|
||||
<value>Loading...</value>
|
||||
</data>
|
||||
<data name="NoUpdate" xml:space="preserve">
|
||||
<value>No update found</value>
|
||||
</data>
|
||||
<data name="NumberOfProcesses" xml:space="preserve">
|
||||
<value>_Number of processes:</value>
|
||||
</data>
|
||||
<data name="OptionCategory_About" xml:space="preserve">
|
||||
<value>About</value>
|
||||
</data>
|
||||
<data name="OptionCategory_General" xml:space="preserve">
|
||||
<value>General</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_CancelButton" xml:space="preserve">
|
||||
<value>Cancel</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>
|
||||
<data name="OptionsWindow_OkayButton" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name="OptionsWindow_Title" xml:space="preserve">
|
||||
<value>Options</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">
|
||||
<value>Show _process ID</value>
|
||||
</data>
|
||||
</root>
|
||||
14
Properties/Settings.Designer.cs
generated
14
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", "15.5.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -82,5 +82,17 @@ namespace ProcessCpuUsageStatusWindow.Properties {
|
||||
this["FirstRun"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool ShowProcessId {
|
||||
get {
|
||||
return ((bool)(this["ShowProcessId"]));
|
||||
}
|
||||
set {
|
||||
this["ShowProcessId"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
<Setting Name="FirstRun" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="ShowProcessId" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
71
UpdateCheck.cs
Normal file
71
UpdateCheck.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProcessCpuUsageStatusWindow
|
||||
{
|
||||
public static class UpdateCheck
|
||||
{
|
||||
public enum UpdateStatus
|
||||
{
|
||||
Checking,
|
||||
None,
|
||||
Downloading,
|
||||
Installing,
|
||||
Restarting
|
||||
}
|
||||
|
||||
public delegate void UpdateStatusDelegate(UpdateStatus updateStatus, string message);
|
||||
|
||||
public static Version LocalVersion => Assembly.GetEntryAssembly().GetName().Version;
|
||||
|
||||
public static async Task<bool> CheckUpdate(UpdateStatusDelegate onUpdateStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
onUpdateStatus.Invoke(UpdateStatus.Checking, Properties.Resources.CheckingForUpdate);
|
||||
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
124
WindowSource.cs
124
WindowSource.cs
@@ -1,15 +1,12 @@
|
||||
using FloatingStatusWindowLibrary;
|
||||
using Common.Wpf.Windows;
|
||||
using FloatingStatusWindowLibrary;
|
||||
using ProcessCpuUsageStatusWindow.Options;
|
||||
using ProcessCpuUsageStatusWindow.Properties;
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ProcessCpuUsageStatusWindow
|
||||
@@ -20,6 +17,8 @@ namespace ProcessCpuUsageStatusWindow
|
||||
private readonly ProcessCpuUsageWatcher _processCpuUsageWatcher;
|
||||
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
|
||||
|
||||
private CategoryWindow _optionsWindow;
|
||||
|
||||
internal WindowSource()
|
||||
{
|
||||
_floatingStatusWindow = new FloatingStatusWindow(this);
|
||||
@@ -27,48 +26,28 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
_processCpuUsageWatcher = new ProcessCpuUsageWatcher();
|
||||
|
||||
Task.Factory.StartNew(UpdateApp);
|
||||
Task.Factory.StartNew(UpdateApp).ContinueWith(task => StartUpdate(task.Result.Result));
|
||||
}
|
||||
|
||||
private async Task UpdateApp()
|
||||
private void StartUpdate(bool updateRequired)
|
||||
{
|
||||
try
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
if (updateRequired)
|
||||
return;
|
||||
|
||||
using (var updateManager = await UpdateManager.GitHubUpdateManager(App.UpdateUrl))
|
||||
{
|
||||
var updates = await updateManager.CheckForUpdate();
|
||||
Task.Factory.StartNew(() => _processCpuUsageWatcher.Initialize(Settings.Default.UpdateInterval, UpdateDisplay, _dispatcher));
|
||||
}
|
||||
|
||||
var lastVersion = updates?.ReleasesToApply?.OrderBy(releaseEntry => releaseEntry.Version).LastOrDefault();
|
||||
private async Task<bool> UpdateApp()
|
||||
{
|
||||
return await UpdateCheck.CheckUpdate(HandleUpdateStatus);
|
||||
}
|
||||
|
||||
if (lastVersion == null)
|
||||
return;
|
||||
private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message)
|
||||
{
|
||||
if (status == UpdateCheck.UpdateStatus.None)
|
||||
message = Resources.Loading;
|
||||
|
||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(Resources.Updating));
|
||||
Thread.Sleep(500);
|
||||
|
||||
Common.Settings.Extensions.BackupSettings();
|
||||
|
||||
#if !DEBUG
|
||||
await updateManager.DownloadReleases(new[] { lastVersion });
|
||||
await updateManager.ApplyReleases(updates);
|
||||
await updateManager.UpdateApp();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
UpdateManager.RestartApp();
|
||||
#endif
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Task.Factory.StartNew(() => _processCpuUsageWatcher.Initialize(Settings.Default.UpdateInterval, UpdateDisplay, _dispatcher));
|
||||
}
|
||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(message));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -81,25 +60,43 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
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 => false;
|
||||
public bool HasRefreshMenu => false;
|
||||
public bool HasAboutMenu => true;
|
||||
public bool HasSettingsMenu => true;
|
||||
public bool HasRefreshMenu => true;
|
||||
public bool HasAboutMenu => false;
|
||||
|
||||
public void ShowAbout()
|
||||
{
|
||||
var version = Assembly.GetEntryAssembly().GetName().Version.ToString();
|
||||
|
||||
MessageBox.Show(version);
|
||||
}
|
||||
|
||||
public string WindowSettings
|
||||
@@ -118,21 +115,22 @@ namespace ProcessCpuUsageStatusWindow
|
||||
{
|
||||
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 != PredefinedProcessName.Idle)).ToList();
|
||||
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);
|
||||
var sortedProcessList = validProcessList.OrderByDescending(process => process.PercentUsage).Take(Settings.Default.ProcessCount);
|
||||
|
||||
// Create a new string builder
|
||||
var stringBuilder = new StringBuilder();
|
||||
@@ -146,14 +144,30 @@ namespace ProcessCpuUsageStatusWindow
|
||||
}
|
||||
|
||||
// Loop over all processes in the sorted list
|
||||
foreach (ProcessCpuUsage processCpuUsage in sortedProcessList)
|
||||
foreach (var processCpuUsage in sortedProcessList)
|
||||
{
|
||||
// Move to the next line if it isn't the first line
|
||||
if (stringBuilder.Length != 0)
|
||||
stringBuilder.AppendLine();
|
||||
|
||||
// Format the process information into a string to display
|
||||
stringBuilder.AppendFormat(Resources.ProcessLine, processCpuUsage.ProcessName, processCpuUsage.PercentUsage);
|
||||
if (_processCpuUsageWatcher.IsV2)
|
||||
{
|
||||
// Split the process name from the process ID
|
||||
var colonPosition = processCpuUsage.ProcessName.LastIndexOf(':');
|
||||
|
||||
var processName = processCpuUsage.ProcessName.Substring(0, colonPosition);
|
||||
var processId = processCpuUsage.ProcessName.Substring(colonPosition + 1);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the footer line (if any)
|
||||
@@ -170,4 +184,4 @@ namespace ProcessCpuUsageStatusWindow
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?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" />
|
||||
|
||||
Reference in New Issue
Block a user