├── PerfMonX ├── Icons │ ├── add.ico │ ├── app.ico │ ├── run.ico │ ├── close.ico │ ├── config.ico │ ├── delete.ico │ ├── field.ico │ ├── graph.ico │ ├── object.ico │ ├── pause.ico │ ├── reset.ico │ ├── computer.ico │ ├── execute.ico │ ├── favorite.ico │ ├── pin_red.ico │ ├── resources.ico │ ├── select_all.ico │ ├── select_none.ico │ ├── multiinstance.ico │ ├── select_invert.ico │ └── singleinstance.ico ├── ViewModels │ ├── LineThickness.cs │ ├── PerformanceCounterTabViewModel.cs │ ├── PerformanceCounterViewModel.cs │ ├── PerformanceCounterCategoryViewModel.cs │ ├── AccentViewModel.cs │ ├── PlotViewModel.cs │ ├── RunningCounterViewModel.cs │ ├── MainViewModel.cs │ ├── ConfigureTabViewModel.cs │ └── GraphicTabViewModel.cs ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Constants.cs ├── Models │ ├── UpdateInterval.cs │ ├── Settings.cs │ └── MonitoredCounter.cs ├── Interfaces │ ├── ITabViewModel.cs │ └── IMainViewModel.cs ├── App.config ├── packages.config ├── MainWindow.xaml.cs ├── Views │ ├── ConfigureTabView.xaml.cs │ ├── GraphicTabView.xaml.cs │ ├── MainView.xaml.cs │ ├── MainView.xaml │ ├── GraphicTabView.xaml │ └── ConfigureTabView.xaml ├── Resources │ └── Templates.xaml ├── App.xaml.cs ├── Behaviors │ └── ListBoxBehavior.cs ├── App.xaml ├── MainWindow.xaml └── PerfMonX.csproj ├── README.md ├── PerfMonX.sln ├── .gitattributes └── .gitignore /PerfMonX/Icons/add.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/add.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/app.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/run.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/run.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/close.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/close.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/config.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/config.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/delete.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/delete.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/field.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/field.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/graph.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/graph.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/object.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/object.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/pause.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/pause.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/reset.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/reset.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/computer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/computer.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/execute.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/execute.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/favorite.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/favorite.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/pin_red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/pin_red.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/resources.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/resources.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/select_all.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/select_all.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/select_none.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/select_none.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/multiinstance.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/multiinstance.ico -------------------------------------------------------------------------------- /PerfMonX/Icons/select_invert.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/select_invert.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PerfMonX 2 | PerfMonX is an an attempt to improve on the Performance Monitor built-in tool in Windows. 3 | -------------------------------------------------------------------------------- /PerfMonX/Icons/singleinstance.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/PerfMonX/HEAD/PerfMonX/Icons/singleinstance.ico -------------------------------------------------------------------------------- /PerfMonX/ViewModels/LineThickness.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | 3 | namespace PerfMonX.ViewModels { 4 | class LineThickness { 5 | public double Thickness { get; set; } 6 | public Brush Brush { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /PerfMonX/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /PerfMonX/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerfMonX { 8 | static class Constants { 9 | public const string Title = "Performance Monitor X"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /PerfMonX/Models/UpdateInterval.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerfMonX.Models { 8 | class UpdateInterval { 9 | public int Interval { get; set; } 10 | public string Text { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PerfMonX/Interfaces/ITabViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerfMonX.Interfaces { 8 | interface ITabViewModel { 9 | string Header { get; } 10 | string Icon { get; } 11 | bool CanClose { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PerfMonX/Models/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerfMonX.Models { 8 | public class Settings { 9 | public bool AlwaysOnTop { get; set; } 10 | public string AccentColor { get; set; } 11 | public string Theme { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PerfMonX/Models/MonitoredCounter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PerfMonX.Models { 8 | class MonitoredCounter { 9 | public string Category { get; set; } 10 | public string Counter { get; set; } 11 | public string Instance { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/PerformanceCounterTabViewModel.cs: -------------------------------------------------------------------------------- 1 | using PerfMonX.Interfaces; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PerfMonX.ViewModels { 10 | sealed class PerformanceCounterTabViewModel : BindableBase, ITabViewModel { 11 | public string Header => "Counters"; 12 | public string Icon => "/icons/counters.ico"; 13 | public bool CanClose => true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PerfMonX/Interfaces/IMainViewModel.cs: -------------------------------------------------------------------------------- 1 | using PerfMonX.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Zodiacon.WPF; 8 | 9 | namespace PerfMonX.Interfaces { 10 | interface IMainViewModel { 11 | void SetStatusText(string text); 12 | IUIServices UI { get; } 13 | IList RunningCounters { get; } 14 | IList Tabs { get; } 15 | ITabViewModel SelectedTab { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PerfMonX/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/PerformanceCounterViewModel.cs: -------------------------------------------------------------------------------- 1 | using OxyPlot; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace PerfMonX.ViewModels { 11 | public sealed class PerformanceCounterViewModel : BindableBase { 12 | public PerformanceCounter Counter { get; } 13 | 14 | public PerformanceCounterViewModel(PerformanceCounter counter) { 15 | Counter = counter; 16 | } 17 | 18 | public string InstanceName { get; set; } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PerfMonX/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PerfMonX/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace PerfMonX { 17 | /// 18 | /// Interaction logic for MainWindow.xaml 19 | /// 20 | public partial class MainWindow { 21 | public MainWindow() { 22 | InitializeComponent(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PerfMonX/Views/ConfigureTabView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace PerfMonX.Views { 17 | /// 18 | /// Interaction logic for CountersTabView.xaml 19 | /// 20 | public partial class ConfigureTabView { 21 | public ConfigureTabView() { 22 | InitializeComponent(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PerfMonX/Views/GraphicTabView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace PerfMonX.Views { 17 | /// 18 | /// Interaction logic for GraphicView.xaml 19 | /// 20 | public partial class GraphicTabView : UserControl { 21 | public GraphicTabView() { 22 | InitializeComponent(); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PerfMonX/Views/MainView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace PerfMonX.Views { 17 | /// 18 | /// Interaction logic for MainView.xaml 19 | /// 20 | public partial class MainView : UserControl { 21 | public MainView() { 22 | InitializeComponent(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/PerformanceCounterCategoryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PerfMonX.ViewModels { 10 | public sealed class PerformanceCounterCategoryViewModel { 11 | public PerformanceCounterCategory Category { get; } 12 | public IList Counters { get; } = new ObservableCollection(); 13 | public IList Instances { get; } = new ObservableCollection(); 14 | 15 | public PerformanceCounterCategoryViewModel(PerformanceCounterCategory category) { 16 | Category = category; 17 | } 18 | 19 | public bool IsMultiInstance => Category.CategoryType == PerformanceCounterCategoryType.MultiInstance; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/AccentViewModel.cs: -------------------------------------------------------------------------------- 1 | using MahApps.Metro; 2 | using Prism.Mvvm; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Media; 10 | 11 | namespace PerfMonX.ViewModels { 12 | sealed class AccentViewModel : BindableBase { 13 | public Accent Accent { get; } 14 | public AccentViewModel(Accent accent) { 15 | Accent = accent; 16 | } 17 | 18 | public Brush Brush => Accent.Resources["AccentColorBrush"] as Brush; 19 | public string Name => Accent.Name; 20 | 21 | bool _isCurrent; 22 | public bool IsCurrent { 23 | get => _isCurrent; 24 | set { 25 | if (SetProperty(ref _isCurrent, value) && value) { 26 | ChangeAccentColor(); 27 | } 28 | } 29 | } 30 | 31 | public void ChangeAccentColor() { 32 | ThemeManager.ChangeAppStyle(Application.Current, Accent, ThemeManager.DetectAppStyle().Item1); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PerfMonX/Resources/Templates.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /PerfMonX/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using PerfMonX.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Configuration; 5 | using System.Data; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using Zodiacon.WPF; 11 | 12 | namespace PerfMonX { 13 | /// 14 | /// Interaction logic for App.xaml 15 | /// 16 | public partial class App : Application { 17 | MainViewModel _mainViewModel; 18 | 19 | protected override void OnStartup(StartupEventArgs e) { 20 | Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; 21 | 22 | var ui = new UIServicesDefaults(); 23 | var vm = new MainViewModel(ui); 24 | var win = new MainWindow { DataContext = vm }; 25 | ui.MessageBoxService.SetOwner(win); 26 | vm.LoadSettings(win); 27 | _mainViewModel = vm; 28 | 29 | win.Show(); 30 | } 31 | 32 | protected override void OnExit(ExitEventArgs e) { 33 | _mainViewModel.SaveSettings(); 34 | 35 | base.OnExit(e); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PerfMonX/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PerfMonX.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /PerfMonX.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2042 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerfMonX", "PerfMonX\PerfMonX.csproj", "{6315E498-FC46-4F5C-8E99-474909C0496D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6315E498-FC46-4F5C-8E99-474909C0496D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6315E498-FC46-4F5C-8E99-474909C0496D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6315E498-FC46-4F5C-8E99-474909C0496D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6315E498-FC46-4F5C-8E99-474909C0496D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4DF95BDF-5CE2-4A64-8725-0FDF471C03A5} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /PerfMonX/Behaviors/ListBoxBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Interactivity; 10 | 11 | namespace PerfMonX.Behaviors { 12 | sealed class ListBoxBehavior : Behavior { 13 | protected override void OnAttached() { 14 | AssociatedObject.SelectionChanged += AssociatedObject_SelectionChanged; 15 | } 16 | 17 | protected override void OnDetaching() { 18 | AssociatedObject.SelectionChanged -= AssociatedObject_SelectionChanged; 19 | } 20 | 21 | private void AssociatedObject_SelectionChanged(object sender, SelectionChangedEventArgs e) { 22 | SelectedItems = AssociatedObject.SelectedItems; 23 | } 24 | 25 | 26 | public IList SelectedItems { 27 | get { return (IList)GetValue(SelectedItemsProperty); } 28 | set { SetValue(SelectedItemsProperty, value); } 29 | } 30 | 31 | public static readonly DependencyProperty SelectedItemsProperty = 32 | DependencyProperty.Register(nameof(SelectedItems), typeof(IList), 33 | typeof(ListBoxBehavior), new PropertyMetadata(null)); 34 | 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PerfMonX/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /PerfMonX/Views/MainView.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/RunningCounterViewModel.cs: -------------------------------------------------------------------------------- 1 | using OxyPlot; 2 | using OxyPlot.Series; 3 | using Prism.Commands; 4 | using Prism.Mvvm; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Linq; 9 | using System.Windows.Media; 10 | 11 | namespace PerfMonX.ViewModels { 12 | sealed class RunningCounterViewModel : BindableBase, IDisposable { 13 | public PerformanceCounter Counter { get; } 14 | public List Points { get; } = new List(120); 15 | 16 | LineThickness[] _strokeThicknessValues; 17 | public LineThickness[] StrokeThicknessValues => _strokeThicknessValues; 18 | 19 | LineThickness _strokeThickness; 20 | public LineThickness StrokeThickness { 21 | get => _strokeThickness ?? (_strokeThickness = _strokeThicknessValues[0]); 22 | set { 23 | if (SetProperty(ref _strokeThickness, value)) { 24 | Series.StrokeThickness = value.Thickness; 25 | } 26 | } 27 | } 28 | 29 | float _scale = 1; 30 | public float Scale { 31 | get => _scale; 32 | set { 33 | if (SetProperty(ref _scale, value)) { 34 | for (int i = 0; i < Points.Count; i++) 35 | Points[i] = new DataPoint(Points[i].X, Points[i].Y / value); 36 | } 37 | } 38 | } 39 | 40 | public RunningCounterViewModel(PerformanceCounter pc) { 41 | Counter = pc; 42 | } 43 | 44 | bool _minValueChanged, _maxValueChanged; 45 | 46 | public float NextValue { 47 | get { 48 | try { 49 | var value = Counter.NextValue(); 50 | LastValue = value; 51 | if (value < MinValue) { 52 | MinValue = value; 53 | _minValueChanged = true; 54 | } 55 | else if (value > MaxValue) { 56 | MaxValue = value; 57 | _maxValueChanged = true; 58 | } 59 | return value; 60 | } 61 | catch (Exception) { 62 | // counter went away 63 | IsEnabled = false; 64 | return 0; 65 | } 66 | } 67 | } 68 | 69 | public bool IsEnabled { get; private set; } = true; 70 | 71 | public float LastValue { get; private set; } 72 | public float MinValue { get; private set; } = float.MaxValue; 73 | public float MaxValue { get; private set; } = float.MinValue; 74 | 75 | OxyColor _lineColor; 76 | Brush _brush; 77 | 78 | public OxyColor LineColor { 79 | get => _lineColor; 80 | set { 81 | if (SetProperty(ref _lineColor, value)) { 82 | _brush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(_lineColor.R, _lineColor.G, _lineColor.B)); 83 | _brush.Freeze(); 84 | 85 | RaisePropertyChanged(nameof(ColorAsBrush)); 86 | 87 | _strokeThicknessValues = Enumerable.Range(1, 5).Select(i => new LineThickness { Thickness = i, Brush = _brush }).ToArray(); 88 | RaisePropertyChanged(nameof(StrokeThicknessValues)); 89 | } 90 | } 91 | } 92 | 93 | public Brush ColorAsBrush => _brush; 94 | 95 | bool _isVisible = true; 96 | public bool IsVisible { 97 | get => _isVisible; 98 | set { 99 | if (SetProperty(ref _isVisible, value)) { 100 | Series.IsVisible = value; 101 | } 102 | } 103 | } 104 | 105 | public LineSeries Series { get; set; } 106 | 107 | public string CategoryName => Counter.CategoryName; 108 | public string CounterName => Counter.CounterName; 109 | public string InstanceName => Counter.InstanceName ?? "-"; 110 | 111 | public void Refresh() { 112 | RaisePropertyChanged(nameof(LastValue)); 113 | if (_minValueChanged) { 114 | RaisePropertyChanged(nameof(MinValue)); 115 | _minValueChanged = false; 116 | } 117 | if (_maxValueChanged) { 118 | RaisePropertyChanged(nameof(MaxValue)); 119 | _maxValueChanged = false; 120 | } 121 | } 122 | 123 | public void Dispose() { 124 | Counter.Dispose(); 125 | } 126 | 127 | public DelegateCommandBase ToggleCheckCommand => new DelegateCommand(() => IsVisible = !IsVisible); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using MahApps.Metro; 2 | using PerfMonX.Interfaces; 3 | using PerfMonX.Models; 4 | using Prism.Commands; 5 | using Prism.Mvvm; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Collections.ObjectModel; 9 | using System.Diagnostics; 10 | using System.IO; 11 | using System.Linq; 12 | using System.Runtime.Serialization; 13 | using System.Windows; 14 | using System.Windows.Input; 15 | using Zodiacon.WPF; 16 | 17 | namespace PerfMonX.ViewModels { 18 | sealed class MainViewModel : BindableBase, IMainViewModel { 19 | readonly ObservableCollection _tabs = new ObservableCollection(); 20 | readonly ObservableCollection _runningCounters = new ObservableCollection(); 21 | 22 | public IList RunningCounters => _runningCounters; 23 | public AccentViewModel[] Accents => ThemeManager.Accents.Select(a => new AccentViewModel(a)).ToArray(); 24 | public AppTheme[] Themes => ThemeManager.AppThemes.ToArray(); 25 | 26 | AccentViewModel _currentAccent; 27 | 28 | public AccentViewModel CurrentAccent => _currentAccent; 29 | 30 | public ICommand ChangeAccentCommand => new DelegateCommand(accent => { 31 | if (_currentAccent != null) 32 | _currentAccent.IsCurrent = false; 33 | _currentAccent = accent; 34 | accent.IsCurrent = true; 35 | RaisePropertyChanged(nameof(CurrentAccent)); 36 | }, accent => accent != _currentAccent).ObservesProperty(() => CurrentAccent); 37 | 38 | public ICommand ChangeThemeCommand => new DelegateCommand(theme => { 39 | var style = ThemeManager.DetectAppStyle(); 40 | if (theme != style.Item1) { 41 | ThemeManager.ChangeAppStyle(Application.Current, style.Item2, theme); 42 | } 43 | }); 44 | 45 | public IList Tabs => _tabs; 46 | public IUIServices UI { get; } 47 | 48 | public MainViewModel(IUIServices ui) { 49 | UI = ui; 50 | } 51 | 52 | public ICommand LoadedCommand => new DelegateCommand(async () => { 53 | var configTab = new ConfigureTabViewModel(this); 54 | Tabs.Add(configTab); 55 | var graph = new GraphicTabViewModel(this, new List { 56 | new RunningCounterViewModel(new PerformanceCounter("Processor", "% Processor Time", "_Total", true)) 57 | }); 58 | Tabs.Add(graph); 59 | SelectedTab = graph; 60 | await configTab.InitAsync(); 61 | }); 62 | 63 | ITabViewModel _selectedTab; 64 | public ITabViewModel SelectedTab { 65 | get => _selectedTab; 66 | set => SetProperty(ref _selectedTab, value); 67 | } 68 | 69 | string _statusText; 70 | public string StatusText { 71 | get => _statusText; 72 | set => SetProperty(ref _statusText, value); 73 | } 74 | 75 | public void SetStatusText(string text) { 76 | StatusText = text; 77 | } 78 | 79 | bool _alwaysOnTop; 80 | public DelegateCommandBase AlwaysOnTopCommand => new DelegateCommand(win => win.Topmost = _alwaysOnTop = !win.Topmost); 81 | public DelegateCommandBase CloseTabCommand => new DelegateCommand(tab => { 82 | if (tab is IDisposable disposable) 83 | disposable.Dispose(); 84 | Tabs.Remove(tab); 85 | }); 86 | 87 | public void SaveSettings() { 88 | var style = ThemeManager.DetectAppStyle(); 89 | var settings = new Settings { 90 | AlwaysOnTop = _alwaysOnTop, 91 | AccentColor = style.Item2.Name, 92 | Theme = style.Item1.Name 93 | }; 94 | try { 95 | using (var fs = new FileStream(GetSettingsPath(), FileMode.Create)) { 96 | var serializer = new DataContractSerializer(typeof(Settings)); 97 | serializer.WriteObject(fs, settings); 98 | } 99 | } 100 | catch { 101 | } 102 | } 103 | 104 | private string GetSettingsPath() { 105 | var directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\PerfMonX"; 106 | if (!Directory.Exists(directory)) 107 | Directory.CreateDirectory(directory); 108 | return directory + @"\PerfMonX.Settings.Xml"; 109 | } 110 | 111 | public void LoadSettings(Window window) { 112 | try { 113 | using (var fs = File.OpenRead(GetSettingsPath())) { 114 | var serializer = new DataContractSerializer(typeof(Settings)); 115 | var settings = serializer.ReadObject(fs) as Settings; 116 | if (settings != null) { 117 | if (settings.AlwaysOnTop) 118 | window.Topmost = true; 119 | var accent = Accents.FirstOrDefault(acc => acc.Name == settings.AccentColor); 120 | if(accent != null) 121 | ChangeAccentCommand.Execute(accent); 122 | var theme = Themes.FirstOrDefault(t => t.Name == settings.Theme); 123 | if (theme != null) 124 | ChangeThemeCommand.Execute(theme); 125 | } 126 | } 127 | } 128 | catch { 129 | } 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /PerfMonX/Views/GraphicTabView.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 28 | 29 | 30 | 31 | 32 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /PerfMonX/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/ConfigureTabViewModel.cs: -------------------------------------------------------------------------------- 1 | using PerfMonX.Interfaces; 2 | using Prism.Commands; 3 | using Prism.Mvvm; 4 | using System; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.Collections.ObjectModel; 8 | using System.Diagnostics; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading; 12 | using System.Threading.Tasks; 13 | using System.Windows.Data; 14 | using System.Windows.Media; 15 | 16 | namespace PerfMonX.ViewModels { 17 | sealed class ConfigureTabViewModel : BindableBase, ITabViewModel { 18 | public string Header => "Configuration"; 19 | public string Icon => "/icons/config.ico"; 20 | public bool CanClose => false; 21 | 22 | private string _machineName = "."; 23 | 24 | public string MachineName { 25 | get => _machineName; 26 | set => SetProperty(ref _machineName, value); 27 | } 28 | 29 | public PerformanceCounterCategoryViewModel[] Categories { get; private set; } 30 | public PerformanceCounterViewModel[] Counters { get; private set; } 31 | public string[] Instances { get; private set; } 32 | public ObservableCollection ActualCounters { get; } = new ObservableCollection(); 33 | 34 | public DelegateCommandBase AddCountersCommand { get; } 35 | public DelegateCommandBase RunCountersCommand { get; } 36 | 37 | private PerformanceCounterCategoryViewModel _selectedCategory; 38 | 39 | public PerformanceCounterCategoryViewModel SelectedCategory { 40 | get => _selectedCategory; 41 | set { 42 | if (SetProperty(ref _selectedCategory, value)) { 43 | UpdateCounters(); 44 | RaisePropertyChanged(nameof(Counters)); 45 | RaisePropertyChanged(nameof(Instances)); 46 | } 47 | } 48 | } 49 | 50 | private IList _selectedCounters, _selectedInstances; 51 | 52 | public IList SelectedCounters { 53 | get => _selectedCounters; 54 | set { 55 | _selectedCounters = value; 56 | RaisePropertyChanged(nameof(SelectedCounters)); 57 | } 58 | } 59 | 60 | public IList SelectedInstances { 61 | get => _selectedInstances; 62 | set { 63 | _selectedInstances = value; 64 | RaisePropertyChanged(nameof(SelectedInstances)); 65 | } 66 | } 67 | 68 | public IList GetSelectedCounters() { 69 | return SelectedCounters.Cast().ToList(); 70 | } 71 | 72 | public IList GetSelectedInstances() { 73 | return SelectedInstances.Cast().ToList(); 74 | } 75 | 76 | private void UpdateCounters() { 77 | Counters = null; 78 | Instances = null; 79 | SelectedCounters = null; 80 | SelectedInstances = null; 81 | if (SelectedCategory == null) 82 | return; 83 | 84 | if (SelectedCategory.IsMultiInstance) { 85 | var names = SelectedCategory.Category.GetInstanceNames(); 86 | if (names.Length > 0) { 87 | try { 88 | Counters = SelectedCategory.Category.GetCounters(names[0]).OrderBy(c => c.CounterName).Select(c => new PerformanceCounterViewModel(c)).ToArray(); 89 | Instances = names.OrderBy(name => name).ToArray(); 90 | } 91 | catch { 92 | } 93 | } 94 | } 95 | else { 96 | Counters = SelectedCategory.Category.GetCounters().Select(c => new PerformanceCounterViewModel(c)).ToArray(); 97 | } 98 | } 99 | 100 | readonly IMainViewModel MainViewModel; 101 | public ConfigureTabViewModel(IMainViewModel mainView) { 102 | MainViewModel = mainView; 103 | 104 | AddCountersCommand = new DelegateCommand(() => { 105 | if (SelectedCategory.IsMultiInstance) { 106 | foreach (var counter in GetSelectedCounters()) { 107 | foreach (var instance in GetSelectedInstances()) { 108 | var pc = new PerformanceCounter(SelectedCategory.Category.CategoryName, counter.Counter.CounterName, instance, true); 109 | ActualCounters.Add(new RunningCounterViewModel(pc)); 110 | } 111 | } 112 | } 113 | else { 114 | foreach (var counter in GetSelectedCounters()) { 115 | var pc = new PerformanceCounter(SelectedCategory.Category.CategoryName, counter.Counter.CounterName, true); 116 | ActualCounters.Add(new RunningCounterViewModel(pc)); 117 | } 118 | } 119 | }, () => SelectedCategory != null && SelectedCounters?.Count > 0 && (SelectedInstances?.Count > 0 && SelectedCategory.IsMultiInstance || !SelectedCategory.IsMultiInstance)) 120 | .ObservesProperty(() => SelectedCategory).ObservesProperty(() => SelectedInstances).ObservesProperty(() => SelectedCounters); 121 | 122 | RunCountersCommand = new DelegateCommand(() => { 123 | if (ActualCounters.Count == 0) { 124 | MainViewModel.UI.MessageBoxService.ShowMessage("Please select at least one counter", Constants.Title); 125 | return; 126 | } 127 | 128 | var tab = new GraphicTabViewModel(MainViewModel, ActualCounters.ToList()); 129 | MainViewModel.Tabs.Add(tab); 130 | MainViewModel.SelectedTab = tab; 131 | ActualCounters.Clear(); 132 | }); 133 | } 134 | 135 | public async Task InitAsync() { 136 | await InitCategoriesAsync(); 137 | } 138 | 139 | async Task InitCategoriesAsync() { 140 | MainViewModel.SetStatusText("Loading peformance counter categories..."); 141 | Categories = await Task.Run(() => { 142 | Thread.CurrentThread.Priority = ThreadPriority.Lowest; 143 | return PerformanceCounterCategory.GetCategories(MachineName).OrderBy(c => c.CategoryName).Select(c => new PerformanceCounterCategoryViewModel(c)).ToArray(); 144 | }); 145 | RaisePropertyChanged(nameof(Categories)); 146 | MainViewModel.SetStatusText(string.Empty); 147 | } 148 | 149 | private string _searchCategoryText; 150 | 151 | public string SearchCategoryText { 152 | get => _searchCategoryText; 153 | set { 154 | if (SetProperty(ref _searchCategoryText, value)) { 155 | if (Categories == null) 156 | return; 157 | var view = CollectionViewSource.GetDefaultView(Categories); 158 | if (value == null) 159 | view.Filter = null; 160 | else { 161 | var text = value.ToLower(); 162 | view.Filter = obj => { 163 | var cat = (PerformanceCounterCategoryViewModel)obj; 164 | return cat.Category.CategoryName.ToLower().Contains(text); 165 | }; 166 | } 167 | } 168 | } 169 | } 170 | 171 | string _searchCounterText; 172 | public string SearchCounterText { 173 | get => _searchCounterText; 174 | set { 175 | if (SetProperty(ref _searchCounterText, value)) { 176 | var view = CollectionViewSource.GetDefaultView(Counters); 177 | if (value == null) 178 | view.Filter = null; 179 | else { 180 | var text = value.ToLower(); 181 | view.Filter = obj => { 182 | var cat = (PerformanceCounterViewModel)obj; 183 | return cat.Counter.CounterName.ToLower().Contains(text); 184 | }; 185 | } 186 | } 187 | } 188 | } 189 | 190 | string _searchInstanceText; 191 | public string SearchInstanceText { 192 | get => _searchInstanceText; 193 | set { 194 | if (SetProperty(ref _searchInstanceText, value)) { 195 | var view = CollectionViewSource.GetDefaultView(Instances); 196 | if (value == null) 197 | view.Filter = null; 198 | else { 199 | var text = value.ToLower(); 200 | view.Filter = obj => { 201 | var instance = (string)obj; 202 | return instance.ToLower().Contains(text); 203 | }; 204 | } 205 | } 206 | } 207 | } 208 | 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /PerfMonX/ViewModels/GraphicTabViewModel.cs: -------------------------------------------------------------------------------- 1 | using MahApps.Metro; 2 | using OxyPlot; 3 | using OxyPlot.Axes; 4 | using OxyPlot.Series; 5 | using PerfMonX.Interfaces; 6 | using PerfMonX.Models; 7 | using Prism.Commands; 8 | using Prism.Mvvm; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Diagnostics; 12 | using System.Linq; 13 | using System.Threading; 14 | using System.Windows; 15 | using System.Windows.Media; 16 | using System.Windows.Threading; 17 | 18 | namespace PerfMonX.ViewModels { 19 | sealed class GraphicTabViewModel : BindableBase, ITabViewModel, IDisposable { 20 | public string Header => "Graph"; 21 | public string Icon => "/icons/graph.ico"; 22 | public bool CanClose => true; 23 | 24 | Timer _timer; 25 | DispatcherTimer _refreshTimer; 26 | Dispatcher _dispatcher; 27 | DateTimeAxis _timeAxis; 28 | LinearAxis _valueAxis; 29 | 30 | IMainViewModel _mainViewModel; 31 | static UpdateInterval[] _updateIntervals = new[] { 32 | new UpdateInterval { Interval = 100, Text = "100 msec" }, 33 | new UpdateInterval { Interval = 200, Text = "200 msec" }, 34 | new UpdateInterval { Interval = 500, Text = "500 msec" }, 35 | new UpdateInterval { Interval = 1000, Text = "1 sec" }, 36 | new UpdateInterval { Interval = 2000, Text = "2 sec" }, 37 | new UpdateInterval { Interval = 5000, Text = "5 sec" }, 38 | new UpdateInterval { Interval = 10000, Text = "10 sec" }, 39 | }; 40 | 41 | public IList RunningCounters { get; } 42 | 43 | public PlotModel PlotModel { get; } 44 | 45 | public GraphicTabViewModel(IMainViewModel mainViewModel, IList counters) { 46 | _mainViewModel = mainViewModel; 47 | _dispatcher = Dispatcher.CurrentDispatcher; 48 | 49 | PlotModel = new PlotModel(); 50 | RunningCounters = counters; 51 | ThemeManager.IsThemeChanged += ThemeManager_IsThemeChanged; 52 | var now = DateTimeAxis.ToDouble(DateTime.UtcNow); 53 | 54 | _timeAxis = new DateTimeAxis { 55 | Position = AxisPosition.Bottom, 56 | Minimum = now, 57 | AbsoluteMinimum = now, 58 | //Maximum = DateTimeAxis.ToDouble(DateTime.UtcNow.AddMinutes(1)), 59 | Title = "Time", 60 | TimeZone = TimeZoneInfo.Local, 61 | MaximumRange = DateTimeAxis.ToDouble(DateTime.UtcNow.AddMinutes(5)) - now, 62 | MinimumRange = DateTimeAxis.ToDouble(DateTime.UtcNow.AddSeconds(60)) - now, 63 | }; 64 | //_timeAxis.AxisChanged += OnTimeAxisChanged; 65 | 66 | PlotModel.Axes.Add(_timeAxis); 67 | PlotModel.Axes.Add(_valueAxis = new LinearAxis { 68 | Position = AxisPosition.Left, 69 | //Minimum = 0, 70 | //Maximum = 100, 71 | IsPanEnabled = false, 72 | IsZoomEnabled = false, 73 | Title = "Value", 74 | }); 75 | 76 | var style = ThemeManager.DetectAppStyle(); 77 | var color = (Color)style.Item1.Resources["BlackColor"]; 78 | var defaultColor = OxyColor.FromRgb(color.R, color.G, color.B); 79 | color = (Color)style.Item1.Resources["WhiteColor"]; 80 | var inverseColor = OxyColor.FromRgb(color.R, color.G, color.B); 81 | UpdateColors(defaultColor, inverseColor); 82 | 83 | var colors = new OxyColor[] { 84 | OxyColors.Red, OxyColors.Blue, OxyColors.Green, OxyColors.Orange, OxyColors.Brown, OxyColors.Cyan, OxyColors.Purple, 85 | OxyColors.Gray, OxyColors.GreenYellow, OxyColors.Indigo, OxyColors.DarkBlue, OxyColors.Pink, OxyColors.Plum, 86 | OxyColors.SeaGreen, OxyColors.Fuchsia 87 | }; 88 | 89 | int index = 0; 90 | foreach (var counter in counters) { 91 | var series = new LineSeries { 92 | StrokeThickness = 1, 93 | //MarkerStroke = OxyColors.Blue, 94 | Color = colors[index % colors.Length], 95 | ItemsSource = counter.Points, 96 | }; 97 | index++; 98 | counter.LineColor = series.Color; 99 | counter.Series = series; 100 | PlotModel.Series.Add(series); 101 | } 102 | 103 | _refreshTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; 104 | _refreshTimer.Tick += OnRefresh; 105 | _refreshTimer.Start(); 106 | 107 | var dispatcher = Dispatcher.CurrentDispatcher; 108 | _timer = new Timer(_ => Update(), null, 0, UpdateInterval.Interval); 109 | 110 | } 111 | 112 | private void ThemeManager_IsThemeChanged(object sender, OnThemeChangedEventArgs e) { 113 | var color = (Color)e.AppTheme.Resources["BlackColor"]; 114 | var defaultColor = OxyColor.FromRgb(color.R, color.G, color.B); 115 | color = (Color)e.AppTheme.Resources["WhiteColor"]; 116 | var inverseColor = OxyColor.FromRgb(color.R, color.G, color.B); 117 | UpdateColors(defaultColor, inverseColor); 118 | } 119 | 120 | void UpdateColors(OxyColor color, OxyColor inverseColor) { 121 | PlotModel.PlotAreaBorderColor = color; 122 | PlotModel.TextColor = color; 123 | _timeAxis.TicklineColor = color; 124 | _timeAxis.AxislineColor = color; 125 | _valueAxis.AxislineColor = color; 126 | _valueAxis.TicklineColor = color; 127 | PlotModel.PlotAreaBackground = inverseColor; 128 | PlotModel.InvalidatePlot(false); 129 | } 130 | 131 | private void OnTimeAxisChanged(object sender, AxisChangedEventArgs e) { 132 | 133 | } 134 | 135 | public UpdateInterval[] UpdateIntervals => _updateIntervals; 136 | 137 | UpdateInterval _updateInterval = _updateIntervals.First(i => i.Interval == 1000); 138 | public UpdateInterval UpdateInterval { 139 | get => _updateInterval; 140 | set { 141 | if (SetProperty(ref _updateInterval, value)) { 142 | _timer?.Change(value.Interval, value.Interval); 143 | } 144 | } 145 | } 146 | private void Update() { 147 | foreach (var counter in RunningCounters) { 148 | if (counter.IsEnabled) 149 | counter.Points.Add(DateTimeAxis.CreateDataPoint(DateTime.UtcNow, counter.NextValue)); 150 | } 151 | _dispatcher.InvokeAsync(() => { 152 | var now = DateTimeAxis.ToDouble(DateTime.UtcNow); 153 | var window = DateTimeAxis.ToDouble(DateTime.UtcNow.AddMinutes(1)) - now; 154 | _timeAxis.Minimum = now - window * .95; 155 | _timeAxis.Maximum = now + window * .05; 156 | PlotModel.InvalidatePlot(true); 157 | }); 158 | } 159 | 160 | private void OnRefresh(object sender, EventArgs e) { 161 | foreach (var counter in RunningCounters) 162 | counter.Refresh(); 163 | } 164 | 165 | bool _isPaused; 166 | public bool IsPaused { 167 | get => _isPaused; 168 | set { 169 | if (SetProperty(ref _isPaused, value)) { 170 | if (value) { 171 | _timer.Dispose(); 172 | _timer = null; 173 | } 174 | else { 175 | Debug.Assert(_timer == null); 176 | _timer = new Timer(_ => Update(), null, 0, UpdateInterval.Interval); 177 | } 178 | } 179 | } 180 | } 181 | 182 | public DelegateCommandBase ExportCommand => new DelegateCommand(() => { 183 | var isPaused = IsPaused; 184 | try { 185 | IsPaused = true; 186 | var path = _mainViewModel.UI.FileDialogService.GetFileForSave("CSV Files|*.csv", "Export Data"); 187 | if (path == null) 188 | return; 189 | ExportToFile(path); 190 | } 191 | finally { 192 | IsPaused = isPaused; 193 | } 194 | }); 195 | 196 | public DelegateCommandBase ClearAllCommand => new DelegateCommand(() => { 197 | if (RunningCounters.Any() && RunningCounters[0].Points.Count > 0) { 198 | if (_mainViewModel.UI.MessageBoxService.ShowMessage("Clear all data?", Constants.Title, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) 199 | return; 200 | } 201 | ClearAll(); 202 | }); 203 | 204 | private void ClearAll() { 205 | foreach (var counter in RunningCounters) { 206 | counter.Points.Clear(); 207 | } 208 | _timeAxis.Minimum = _timeAxis.AbsoluteMinimum = DateTimeAxis.ToDouble(DateTime.UtcNow); 209 | _timeAxis.Reset(); 210 | } 211 | 212 | void ExportToFile(string filename) { 213 | 214 | } 215 | 216 | public void Dispose() { 217 | _timer?.Dispose(); 218 | foreach (var counter in RunningCounters) 219 | counter.Dispose(); 220 | } 221 | 222 | public DelegateCommandBase ResetCommand => new DelegateCommand(() => _timeAxis.Reset()); 223 | 224 | //Color _backgroundColor; 225 | //public Color BackgroundColor { 226 | // get => _backgroundColor; 227 | // set { 228 | // if (SetProperty(ref _backgroundColor, value)) { 229 | // PlotModel.PlotAreaBackground = OxyColor.FromRgb(value.R, value.G, value.B); 230 | // } 231 | // } 232 | //} 233 | 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /PerfMonX/Views/ConfigureTabView.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 95 | 99 | 100 | 106 | 107 | 113 | 114 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /PerfMonX/PerfMonX.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {6315E498-FC46-4F5C-8E99-474909C0496D} 8 | WinExe 9 | PerfMonX 10 | PerfMonX 11 | v4.7.2 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | false 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | Icons\app.ico 39 | 40 | 41 | 42 | ..\packages\ControlzEx.3.0.2.4\lib\net462\ControlzEx.dll 43 | 44 | 45 | ..\packages\MahApps.Metro.1.6.5\lib\net47\MahApps.Metro.dll 46 | 47 | 48 | ..\packages\OxyPlot.Core.1.0.0\lib\net45\OxyPlot.dll 49 | 50 | 51 | ..\packages\OxyPlot.Wpf.1.0.0\lib\net45\OxyPlot.Wpf.dll 52 | 53 | 54 | ..\packages\Prism.Core.7.0.0.396\lib\net45\Prism.dll 55 | 56 | 57 | 58 | 59 | 60 | 61 | ..\packages\ControlzEx.3.0.2.4\lib\net462\System.Windows.Interactivity.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 4.0 71 | 72 | 73 | 74 | 75 | 76 | ..\packages\WriteableBitmapEx.1.5.1.0\lib\net40\WriteableBitmapEx.Wpf.dll 77 | 78 | 79 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.dll 80 | 81 | 82 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll 83 | 84 | 85 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll 86 | 87 | 88 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll 89 | 90 | 91 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.DataGrid.dll 92 | 93 | 94 | ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.Toolkit.dll 95 | 96 | 97 | ..\packages\Zodiacon.WPF.1.2.17\lib\net45\Zodiacon.WPF.dll 98 | 99 | 100 | 101 | 102 | MSBuild:Compile 103 | Designer 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | ConfigureTabView.xaml 124 | 125 | 126 | GraphicTabView.xaml 127 | 128 | 129 | MainView.xaml 130 | 131 | 132 | MSBuild:Compile 133 | Designer 134 | 135 | 136 | App.xaml 137 | Code 138 | 139 | 140 | MainWindow.xaml 141 | Code 142 | 143 | 144 | Designer 145 | MSBuild:Compile 146 | 147 | 148 | Designer 149 | MSBuild:Compile 150 | 151 | 152 | Designer 153 | MSBuild:Compile 154 | 155 | 156 | Designer 157 | MSBuild:Compile 158 | 159 | 160 | 161 | 162 | Code 163 | 164 | 165 | True 166 | True 167 | Resources.resx 168 | 169 | 170 | True 171 | Settings.settings 172 | True 173 | 174 | 175 | ResXFileCodeGenerator 176 | Resources.Designer.cs 177 | 178 | 179 | 180 | SettingsSingleFileGenerator 181 | Settings.Designer.cs 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | --------------------------------------------------------------------------------