├── README.md ├── KAEOS ├── packages.config ├── Models │ ├── GpuAti.cs │ ├── Ram.cs │ ├── NetworkInterfaceName.cs │ ├── Cpu.cs │ ├── GpuNvidia.cs │ └── MonitoredHardware.cs ├── App.xaml.cs ├── MainWindow.xaml.cs ├── Converters │ ├── HeightConverter.cs │ ├── FloatToDoubleConverter.cs │ ├── BytesToSuffixConverter.cs │ └── BooleanToVisibilityConverter.cs ├── Utilities │ ├── WmiHelper.cs │ ├── Counters.cs │ └── Logger.cs ├── Styles │ ├── GaugeStyle.xaml │ ├── WindowStyle.xaml │ ├── TextContainerStyle.xaml │ └── ItemsContainerStyle.xaml ├── Extensions │ ├── ObservableObject.cs │ ├── RelayCommand.cs │ └── MTObservableCollection.cs ├── ViewModels │ ├── DateTimeMonitoringVm.cs │ ├── ShellVm.cs │ ├── NetworkMonitoringVm.cs │ └── HardwareMonitoringVm.cs ├── App.xaml ├── Properties │ ├── Settings.settings │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Annotations.cs ├── App.config ├── Controls │ ├── GaugeContainer.xaml.cs │ └── GaugeContainer.xaml ├── app.manifest ├── KAEOS.csproj └── MainWindow.xaml ├── KAEOS.sln.DotSettings ├── KAEOS.sln ├── .gitattributes └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # KAEOS 2 | -------------------------------------------------------------------------------- /KAEOS/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /KAEOS/Models/GpuAti.cs: -------------------------------------------------------------------------------- 1 | using KAEOS.Extensions; 2 | using OpenHardwareMonitor.Hardware; 3 | 4 | namespace KAEOS.Models 5 | { 6 | public class GpuAti : ObservableObject 7 | { 8 | public ISensor GpuAtiSensor { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /KAEOS/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace KAEOS 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /KAEOS.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /KAEOS/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using KAEOS.Properties; 3 | 4 | namespace KAEOS 5 | { 6 | /// 7 | /// Interaction logic for MainWindow.xaml 8 | /// 9 | public partial class MainWindow 10 | { 11 | public MainWindow() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | private void MainWindow_OnMouseDown(object sender, MouseButtonEventArgs e) 17 | { 18 | if (e.ChangedButton.Equals(MouseButton.Left) && !Settings.Default.LockUi) 19 | DragMove(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /KAEOS/Models/Ram.cs: -------------------------------------------------------------------------------- 1 | using KAEOS.Extensions; 2 | using OpenHardwareMonitor.Hardware; 3 | 4 | namespace KAEOS.Models 5 | { 6 | public class Ram : ObservableObject 7 | { 8 | private string _name; 9 | private float? _load; 10 | 11 | public IHardware Hardware { get; set; } 12 | 13 | public string Name 14 | { 15 | get { return _name; } 16 | set { SetField(ref _name, value); } 17 | } 18 | 19 | public float? Load 20 | { 21 | get { return _load; } 22 | set { SetField(ref _load, value); } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /KAEOS/Converters/HeightConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace KAEOS.Converters 6 | { 7 | public class HeightConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var margin = double.Parse(parameter.ToString()); 12 | var height = (double)value; 13 | 14 | return height + margin; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /KAEOS/Converters/FloatToDoubleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace KAEOS.Converters 6 | { 7 | public class FloatToDoubleConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null) return 0; 12 | 13 | double output; 14 | return double.TryParse(value.ToString(), out output) ? Math.Truncate(output) : 0; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /KAEOS/Utilities/WmiHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Management; 3 | 4 | namespace KAEOS.Utilities 5 | { 6 | public static class WmiHelper 7 | { 8 | public static string GetValueFromWmi(string scope, string queryString, string objectName) 9 | { 10 | string results = null; 11 | 12 | using (var searcher = new ManagementObjectSearcher(scope, queryString)) 13 | { 14 | foreach (var queryObj in searcher.Get().Cast()) 15 | { 16 | results = queryObj[objectName].ToString().Trim(); 17 | break; 18 | } 19 | } 20 | 21 | return results; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /KAEOS/Models/NetworkInterfaceName.cs: -------------------------------------------------------------------------------- 1 | using System.Net.NetworkInformation; 2 | using KAEOS.Extensions; 3 | 4 | namespace KAEOS.Models 5 | { 6 | public class NetworkInterfaceName : ObservableObject 7 | { 8 | private string _description; 9 | private string _internalIp; 10 | private NetworkInterface _networkInterface; 11 | 12 | public string Description 13 | { 14 | get { return _description; } 15 | set { SetField(ref _description, value); } 16 | } 17 | 18 | public string InternalIp 19 | { 20 | get { return _internalIp; } 21 | set { SetField(ref _internalIp, value); } 22 | } 23 | 24 | public NetworkInterface NetworkInterface 25 | { 26 | get { return _networkInterface; } 27 | set { SetField(ref _networkInterface, value); } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /KAEOS/Styles/GaugeStyle.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /KAEOS/Extensions/ObservableObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Runtime.CompilerServices; 4 | using KAEOS.Annotations; 5 | 6 | namespace KAEOS.Extensions 7 | { 8 | public class ObservableObject : INotifyPropertyChanged 9 | { 10 | protected bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null) 11 | { 12 | if (EqualityComparer.Default.Equals(field, value)) return false; 13 | 14 | field = value; 15 | OnPropertyChanged(propertyName); 16 | 17 | return true; 18 | } 19 | 20 | public event PropertyChangedEventHandler PropertyChanged; 21 | 22 | [NotifyPropertyChangedInvocator] 23 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 24 | { 25 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /KAEOS/Extensions/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | 4 | namespace KAEOS.Extensions 5 | { 6 | public class RelayCommand : ICommand 7 | { 8 | private readonly Action _execute; 9 | private readonly Func _canExecute; 10 | 11 | public event EventHandler CanExecuteChanged 12 | { 13 | add { CommandManager.RequerySuggested += value; } 14 | remove { CommandManager.RequerySuggested -= value; } 15 | } 16 | 17 | public RelayCommand(Action execute, Func canExecute = null) 18 | { 19 | _execute = execute; 20 | _canExecute = canExecute; 21 | } 22 | 23 | public bool CanExecute(object parameter) 24 | { 25 | return _canExecute == null || _canExecute(parameter); 26 | } 27 | 28 | public void Execute(object parameter) 29 | { 30 | _execute(parameter); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /KAEOS.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KAEOS", "KAEOS\KAEOS.csproj", "{2201BF4F-F35A-4847-A079-DCD06B2C7E39}" 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 | {2201BF4F-F35A-4847-A079-DCD06B2C7E39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2201BF4F-F35A-4847-A079-DCD06B2C7E39}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2201BF4F-F35A-4847-A079-DCD06B2C7E39}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2201BF4F-F35A-4847-A079-DCD06B2C7E39}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /KAEOS/Models/Cpu.cs: -------------------------------------------------------------------------------- 1 | using KAEOS.Extensions; 2 | using OpenHardwareMonitor.Hardware; 3 | 4 | namespace KAEOS.Models 5 | { 6 | public class Cpu : ObservableObject 7 | { 8 | private string _name; 9 | private float? _temperature; 10 | private float? _load; 11 | private float? _fanSpeed; 12 | 13 | public IHardware Hardware { get; set; } 14 | 15 | public string Name 16 | { 17 | get { return _name; } 18 | set { SetField(ref _name, value); } 19 | } 20 | 21 | public float? Temperature 22 | { 23 | get { return _temperature; } 24 | set { SetField(ref _temperature, value); } 25 | } 26 | 27 | public float? Load 28 | { 29 | get { return _load; } 30 | set { SetField(ref _load, value); } 31 | } 32 | 33 | public float? FanSpeed 34 | { 35 | get { return _fanSpeed; } 36 | set { SetField(ref _fanSpeed, value); } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /KAEOS/Models/GpuNvidia.cs: -------------------------------------------------------------------------------- 1 | using KAEOS.Extensions; 2 | using OpenHardwareMonitor.Hardware; 3 | 4 | namespace KAEOS.Models 5 | { 6 | public class GpuNvidia : ObservableObject 7 | { 8 | private string _name; 9 | private float? _temperature; 10 | private float? _load; 11 | private float? _fanSpeed; 12 | 13 | public IHardware Hardware { get; set; } 14 | 15 | public string Name 16 | { 17 | get { return _name; } 18 | set { SetField(ref _name, value); } 19 | } 20 | 21 | public float? Temperature 22 | { 23 | get { return _temperature; } 24 | set { SetField(ref _temperature, value); } 25 | } 26 | 27 | public float? Load 28 | { 29 | get { return _load; } 30 | set { SetField(ref _load, value); } 31 | } 32 | 33 | public float? FanSpeed 34 | { 35 | get { return _fanSpeed; } 36 | set { SetField(ref _fanSpeed, value); } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /KAEOS/Converters/BytesToSuffixConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace KAEOS.Converters 6 | { 7 | public class BytesToSuffixConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | double output; 12 | double.TryParse(value.ToString(), out output); 13 | 14 | return SizeSuffix(output); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | 22 | static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; 23 | 24 | static string SizeSuffix(double value) 25 | { 26 | if (value < 0) { return "-" + SizeSuffix(-value); } 27 | if (Math.Abs(value) < 0.001) { return "0 bytes"; } 28 | 29 | var mag = (int)Math.Log(value, 1024); 30 | var adjustedSize = (decimal)value / (1L << (mag * 10)); 31 | 32 | return $"{adjustedSize:n1} {SizeSuffixes[mag]}"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /KAEOS/Styles/WindowStyle.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 25 | 26 | -------------------------------------------------------------------------------- /KAEOS/Extensions/MTObservableCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Collections.Specialized; 4 | using System.Linq; 5 | using System.Windows.Threading; 6 | 7 | namespace KAEOS.Extensions 8 | { 9 | public class MtObservableCollection : ObservableCollection 10 | { 11 | public override event NotifyCollectionChangedEventHandler CollectionChanged; 12 | protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) 13 | { 14 | var eh = CollectionChanged; 15 | 16 | if (eh == null) return; 17 | 18 | var dispatcher = (from NotifyCollectionChangedEventHandler nh in eh.GetInvocationList() 19 | let dpo = nh.Target as DispatcherObject 20 | where dpo != null 21 | select dpo.Dispatcher).FirstOrDefault(); 22 | 23 | if (dispatcher != null && dispatcher.CheckAccess() == false) 24 | { 25 | dispatcher.Invoke(DispatcherPriority.DataBind, (Action)(() => OnCollectionChanged(e))); 26 | } 27 | else 28 | { 29 | foreach (var nh in eh.GetInvocationList().Cast()) 30 | nh.Invoke(this, e); 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /KAEOS/Models/MonitoredHardware.cs: -------------------------------------------------------------------------------- 1 | using KAEOS.Extensions; 2 | 3 | namespace KAEOS.Models 4 | { 5 | public class MonitoredHardware : ObservableObject 6 | { 7 | public MonitoredHardware() 8 | { 9 | GpuNvidias = new MtObservableCollection(); 10 | GpuAtis = new MtObservableCollection(); 11 | Cpus = new MtObservableCollection(); 12 | Rams = new MtObservableCollection(); 13 | } 14 | 15 | private MtObservableCollection _gpuNvidias; 16 | private MtObservableCollection _gpuAtis; 17 | private MtObservableCollection _cpus; 18 | private MtObservableCollection _rams; 19 | 20 | public MtObservableCollection GpuNvidias 21 | { 22 | get { return _gpuNvidias; } 23 | set { SetField(ref _gpuNvidias, value); } 24 | } 25 | 26 | public MtObservableCollection GpuAtis 27 | { 28 | get { return _gpuAtis; } 29 | set { SetField(ref _gpuAtis, value); } 30 | } 31 | 32 | public MtObservableCollection Cpus 33 | { 34 | get { return _cpus; } 35 | set { SetField(ref _cpus, value); } 36 | } 37 | 38 | public MtObservableCollection Rams 39 | { 40 | get { return _rams; } 41 | set { SetField(ref _rams, value); } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /KAEOS/Converters/BooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace KAEOS.Converters 7 | { 8 | /// 9 | /// Converts Boolean Values to Control.Visibility values 10 | /// 11 | public class BooleanToVisibilityConverter : IValueConverter 12 | { 13 | public bool TriggerValue { get; set; } 14 | 15 | public bool IsHidden { get; set; } 16 | 17 | private object GetVisibility(object value) 18 | { 19 | if (!(value is bool)) 20 | return DependencyProperty.UnsetValue; 21 | 22 | var objValue = (bool)value; 23 | 24 | if ((objValue && TriggerValue && IsHidden) || (!objValue && !TriggerValue && IsHidden)) 25 | { 26 | return Visibility.Hidden; 27 | } 28 | 29 | if ((objValue && TriggerValue && !IsHidden) || (!objValue && !TriggerValue && !IsHidden)) 30 | { 31 | return Visibility.Collapsed; 32 | } 33 | 34 | return Visibility.Visible; 35 | } 36 | 37 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 38 | { 39 | return GetVisibility(value); 40 | } 41 | 42 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /KAEOS/Utilities/Counters.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | 4 | namespace KAEOS.Utilities 5 | { 6 | public static class Counters 7 | { 8 | public static float? GetCpuUsageValue() 9 | { 10 | float output; 11 | 12 | using (var pc = new PerformanceCounter 13 | { 14 | CategoryName = "Processor", 15 | CounterName = "% Processor Time", 16 | InstanceName = "_Total" 17 | }) 18 | { 19 | pc.NextValue(); 20 | Thread.Sleep(1000); 21 | output = pc.NextValue(); 22 | } 23 | 24 | return output; 25 | } 26 | 27 | public static float? GetNetworkBytesSentValue(string networkInterfaceName) 28 | { 29 | float output; 30 | 31 | using (var pc = new PerformanceCounter("Network Interface", "Bytes Sent/sec", networkInterfaceName)) 32 | { 33 | pc.NextValue(); 34 | Thread.Sleep(1000); 35 | output = pc.NextValue(); 36 | } 37 | 38 | return output; 39 | } 40 | 41 | public static float? GetNetworkBytesRecievedValue(string networkInterfaceName) 42 | { 43 | float output; 44 | 45 | using (var pc = new PerformanceCounter("Network Interface", "Bytes Received/sec", networkInterfaceName)) 46 | { 47 | pc.NextValue(); 48 | Thread.Sleep(1000); 49 | output = pc.NextValue(); 50 | } 51 | 52 | return output; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /KAEOS/ViewModels/DateTimeMonitoringVm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Timers; 3 | using KAEOS.Extensions; 4 | 5 | namespace KAEOS.ViewModels 6 | { 7 | public class DateTimeMonitoringVm : ObservableObject 8 | { 9 | public DateTimeMonitoringVm() 10 | { 11 | if (CmdStartMonitoring.CanExecute(null)) 12 | CmdStartMonitoring.Execute(null); 13 | } 14 | 15 | /* 16 | * Private fields 17 | */ 18 | 19 | private RelayCommand _cmdStartMonitoring; 20 | private DateTime _currentDateTime; 21 | 22 | /* 23 | * Public fields 24 | */ 25 | 26 | public DateTime CurrentDateTime 27 | { 28 | get { return _currentDateTime; } 29 | set { SetField(ref _currentDateTime, value); } 30 | } 31 | 32 | /* 33 | * Commands 34 | */ 35 | 36 | public RelayCommand CmdStartMonitoring 37 | { 38 | get 39 | { 40 | return _cmdStartMonitoring ?? 41 | (_cmdStartMonitoring = new RelayCommand(Execute_StartMonitoring, p => true)); 42 | } 43 | } 44 | 45 | /* 46 | * Methods 47 | */ 48 | 49 | private void Execute_StartMonitoring(object obj) 50 | { 51 | var timerCurrentDateTime = new Timer { Interval = 100 }; 52 | timerCurrentDateTime.Elapsed += timerCurrentDateTime_Elapsed; 53 | timerCurrentDateTime.Start(); 54 | } 55 | 56 | private void timerCurrentDateTime_Elapsed(object sender, ElapsedEventArgs e) 57 | { 58 | CurrentDateTime = DateTime.Now; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /KAEOS/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /KAEOS/Utilities/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace KAEOS.Utilities 8 | { 9 | public static class Logger 10 | { 11 | private static readonly string LogFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Assembly.GetExecutingAssembly().GetName().Name + ".log"); 12 | 13 | public static void WriteLine(string value, bool writeToFile = false, Exception exception = null) 14 | { 15 | FileStream fileStream = null; 16 | 17 | try 18 | { 19 | fileStream = new FileStream(LogFileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); 20 | 21 | using (var streamWriter = new StreamWriter(fileStream, Encoding.UTF8)) 22 | { 23 | fileStream = null; 24 | 25 | if (exception != null) 26 | { 27 | Debug.WriteLine($"[{DateTime.Now}]: {value} [Exception:\n{exception}]"); 28 | 29 | if (writeToFile) 30 | streamWriter.WriteLine($"[{DateTime.Now}]: {value} [Exception:\n{exception}]"); 31 | } 32 | else 33 | { 34 | Debug.WriteLine($"[{DateTime.Now}]: {value}"); 35 | 36 | if (writeToFile) 37 | streamWriter.WriteLine($"[{DateTime.Now}]: {value}"); 38 | } 39 | } 40 | } 41 | catch (Exception ex) 42 | { 43 | Debug.WriteLine($"Logger error: {ex}"); 44 | } 45 | finally 46 | { 47 | fileStream?.Dispose(); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /KAEOS/ViewModels/ShellVm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Windows; 5 | using KAEOS.Extensions; 6 | using KAEOS.Utilities; 7 | 8 | namespace KAEOS.ViewModels 9 | { 10 | public class ShellVm : ObservableObject 11 | { 12 | public ShellVm() 13 | { 14 | var osVersion = WmiHelper.GetValueFromWmi("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem", "Caption"); 15 | var osArchitecture = WmiHelper.GetValueFromWmi("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem", "OSArchitecture"); 16 | var osBuildNumber = WmiHelper.GetValueFromWmi("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem", "BuildNumber"); 17 | 18 | var ohmVersionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "OpenHardwareMonitorLib.dll")); 19 | 20 | Logger.WriteLine($"OS: {osVersion}, build: {osBuildNumber} ({osArchitecture})", true); 21 | Logger.WriteLine($"OpenHardwareMonitorLib.dll file version: {ohmVersionInfo.FileVersion}, product version: {ohmVersionInfo.ProductVersion}", true); 22 | } 23 | 24 | /* 25 | * Private fields 26 | */ 27 | 28 | private RelayCommand _cmdCloseApplication; 29 | 30 | /* 31 | * Public fields 32 | */ 33 | 34 | 35 | 36 | /* 37 | * Commands 38 | */ 39 | 40 | public RelayCommand CmdCloseApplication 41 | { 42 | get 43 | { 44 | return _cmdCloseApplication ?? 45 | (_cmdCloseApplication = new RelayCommand(Execute_CloseApplication, p => true)); 46 | } 47 | } 48 | 49 | /* 50 | * Methods 51 | */ 52 | 53 | private static void Execute_CloseApplication(object obj) 54 | { 55 | Properties.Settings.Default.Save(); 56 | 57 | Application.Current.Shutdown(0); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /KAEOS/Styles/TextContainerStyle.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 10 | 11 | 17 | 18 | 25 | 26 | 33 | 34 | 40 | 41 | -------------------------------------------------------------------------------- /KAEOS/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | True 10 | 11 | 12 | True 13 | 14 | 15 | True 16 | 17 | 18 | True 19 | 20 | 21 | True 22 | 23 | 24 | True 25 | 26 | 27 | True 28 | 29 | 30 | True 31 | 32 | 33 | True 34 | 35 | 36 | True 37 | 38 | 39 | False 40 | 41 | 42 | 0 43 | 44 | 45 | 0 46 | 47 | 48 | -------------------------------------------------------------------------------- /KAEOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("KAEOS")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("KAEOS")] 15 | [assembly: AssemblyCopyright("Copyright © 2016")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /KAEOS/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | True 15 | 16 | 17 | True 18 | 19 | 20 | True 21 | 22 | 23 | True 24 | 25 | 26 | True 27 | 28 | 29 | True 30 | 31 | 32 | True 33 | 34 | 35 | True 36 | 37 | 38 | True 39 | 40 | 41 | True 42 | 43 | 44 | True 45 | 46 | 47 | False 48 | 49 | 50 | 0 51 | 52 | 53 | 0 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /KAEOS/Controls/GaugeContainer.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace KAEOS.Controls 5 | { 6 | /// 7 | /// Interaction logic for GaugeContainer.xaml 8 | /// 9 | public partial class GaugeContainer 10 | { 11 | public GaugeContainer() 12 | { 13 | InitializeComponent(); 14 | 15 | PercentageFormatter = x => Math.Truncate(x) + "%"; 16 | TemperatureFormatter = x => Math.Truncate(x) + "°C"; 17 | RpmFormatter = x => Math.Truncate(x) + "RPM"; 18 | } 19 | 20 | public string HardwareName 21 | { 22 | get { return (string)GetValue(HardwareNameProperty); } 23 | set { SetValue(HardwareNameProperty, value); } 24 | } 25 | 26 | public float? Load 27 | { 28 | get { return (float?)GetValue(LoadProperty); } 29 | set { SetValue(LoadProperty, value); } 30 | } 31 | 32 | public float? Temperature 33 | { 34 | get { return (float?)GetValue(TemperatureProperty); } 35 | set { SetValue(TemperatureProperty, value); } 36 | } 37 | 38 | public float? FanSpeed 39 | { 40 | get { return (float?)GetValue(FanSpeedProperty); } 41 | set { SetValue(FanSpeedProperty, value); } 42 | } 43 | 44 | public bool FanSpeedVisibility 45 | { 46 | get { return (bool)GetValue(FanSpeedVisibilityProperty); } 47 | set { SetValue(FanSpeedVisibilityProperty, value); } 48 | } 49 | 50 | public Func PercentageFormatter { get; set; } 51 | 52 | public Func TemperatureFormatter { get; set; } 53 | 54 | public Func RpmFormatter { get; set; } 55 | 56 | public static readonly DependencyProperty HardwareNameProperty = DependencyProperty.Register("HardwareName", typeof(string), typeof(GaugeContainer), new PropertyMetadata(default(string))); 57 | 58 | public static readonly DependencyProperty LoadProperty = DependencyProperty.Register("Load", typeof(float?), typeof(GaugeContainer), new PropertyMetadata(default(float?))); 59 | 60 | public static readonly DependencyProperty TemperatureProperty = DependencyProperty.Register("Temperature", typeof(float?), typeof(GaugeContainer), new PropertyMetadata(default(float?))); 61 | 62 | public static readonly DependencyProperty FanSpeedProperty = DependencyProperty.Register("FanSpeed", typeof(float?), typeof(GaugeContainer), new PropertyMetadata(default(float?))); 63 | 64 | public static readonly DependencyProperty FanSpeedVisibilityProperty = DependencyProperty.Register("FanSpeedVisibility", typeof(bool), typeof(GaugeContainer), new PropertyMetadata(default(bool))); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /KAEOS/Controls/GaugeContainer.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /KAEOS/Properties/Resources.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 KAEOS.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KAEOS.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /KAEOS/Styles/ItemsContainerStyle.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 32 | 33 | 54 | 55 | -------------------------------------------------------------------------------- /KAEOS/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 59 | 60 | 61 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /.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 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 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 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /KAEOS/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 | -------------------------------------------------------------------------------- /KAEOS/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 KAEOS.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.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 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 29 | public bool ShowCpu { 30 | get { 31 | return ((bool)(this["ShowCpu"])); 32 | } 33 | set { 34 | this["ShowCpu"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 41 | public bool ShowGpu { 42 | get { 43 | return ((bool)(this["ShowGpu"])); 44 | } 45 | set { 46 | this["ShowGpu"] = value; 47 | } 48 | } 49 | 50 | [global::System.Configuration.UserScopedSettingAttribute()] 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 52 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 53 | public bool ShowRam { 54 | get { 55 | return ((bool)(this["ShowRam"])); 56 | } 57 | set { 58 | this["ShowRam"] = value; 59 | } 60 | } 61 | 62 | [global::System.Configuration.UserScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 65 | public bool ShowTime { 66 | get { 67 | return ((bool)(this["ShowTime"])); 68 | } 69 | set { 70 | this["ShowTime"] = value; 71 | } 72 | } 73 | 74 | [global::System.Configuration.UserScopedSettingAttribute()] 75 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 76 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 77 | public bool ShowDate { 78 | get { 79 | return ((bool)(this["ShowDate"])); 80 | } 81 | set { 82 | this["ShowDate"] = value; 83 | } 84 | } 85 | 86 | [global::System.Configuration.UserScopedSettingAttribute()] 87 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 88 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 89 | public bool ShowDownload { 90 | get { 91 | return ((bool)(this["ShowDownload"])); 92 | } 93 | set { 94 | this["ShowDownload"] = value; 95 | } 96 | } 97 | 98 | [global::System.Configuration.UserScopedSettingAttribute()] 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 100 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 101 | public bool ShowUpload { 102 | get { 103 | return ((bool)(this["ShowUpload"])); 104 | } 105 | set { 106 | this["ShowUpload"] = value; 107 | } 108 | } 109 | 110 | [global::System.Configuration.UserScopedSettingAttribute()] 111 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 112 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 113 | public bool ShowExtIp { 114 | get { 115 | return ((bool)(this["ShowExtIp"])); 116 | } 117 | set { 118 | this["ShowExtIp"] = value; 119 | } 120 | } 121 | 122 | [global::System.Configuration.UserScopedSettingAttribute()] 123 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 124 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 125 | public bool ShowIntIp { 126 | get { 127 | return ((bool)(this["ShowIntIp"])); 128 | } 129 | set { 130 | this["ShowIntIp"] = value; 131 | } 132 | } 133 | 134 | [global::System.Configuration.UserScopedSettingAttribute()] 135 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 136 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 137 | public bool ShowCpuFan { 138 | get { 139 | return ((bool)(this["ShowCpuFan"])); 140 | } 141 | set { 142 | this["ShowCpuFan"] = value; 143 | } 144 | } 145 | 146 | [global::System.Configuration.UserScopedSettingAttribute()] 147 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 148 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 149 | public bool ShowGpuFan { 150 | get { 151 | return ((bool)(this["ShowGpuFan"])); 152 | } 153 | set { 154 | this["ShowGpuFan"] = value; 155 | } 156 | } 157 | 158 | [global::System.Configuration.UserScopedSettingAttribute()] 159 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 160 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 161 | public bool LockUi { 162 | get { 163 | return ((bool)(this["LockUi"])); 164 | } 165 | set { 166 | this["LockUi"] = value; 167 | } 168 | } 169 | 170 | [global::System.Configuration.UserScopedSettingAttribute()] 171 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 172 | [global::System.Configuration.DefaultSettingValueAttribute("0")] 173 | public double UiPosLeft { 174 | get { 175 | return ((double)(this["UiPosLeft"])); 176 | } 177 | set { 178 | this["UiPosLeft"] = value; 179 | } 180 | } 181 | 182 | [global::System.Configuration.UserScopedSettingAttribute()] 183 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 184 | [global::System.Configuration.DefaultSettingValueAttribute("0")] 185 | public double UiPosTop { 186 | get { 187 | return ((double)(this["UiPosTop"])); 188 | } 189 | set { 190 | this["UiPosTop"] = value; 191 | } 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /KAEOS/ViewModels/NetworkMonitoringVm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.NetworkInformation; 5 | using System.Net.Sockets; 6 | using System.Timers; 7 | using KAEOS.Extensions; 8 | using KAEOS.Models; 9 | using KAEOS.Properties; 10 | using KAEOS.Utilities; 11 | 12 | namespace KAEOS.ViewModels 13 | { 14 | public class NetworkMonitoringVm : ObservableObject 15 | { 16 | public NetworkMonitoringVm() 17 | { 18 | NetworkChange.NetworkAddressChanged += NetworkAddressChangedCallback; 19 | 20 | NetworkInterfaceNames = new MtObservableCollection(); 21 | CurrentNetworkInterfaceName = new NetworkInterfaceName(); 22 | 23 | if (CmdSetNetworkInterfaceName.CanExecute(null)) 24 | CmdSetNetworkInterfaceName.Execute(null); 25 | 26 | if (CmdStartMonitoring.CanExecute(null)) 27 | CmdStartMonitoring.Execute(null); 28 | } 29 | 30 | private void NetworkAddressChangedCallback(object sender, EventArgs e) 31 | { 32 | if (NetworkInterfaceNames.Count > 0) 33 | { 34 | foreach (var networkInterfaceName in NetworkInterfaceNames.Where(networkInterfaceName => networkInterfaceName.Description.Equals(CurrentNetworkInterfaceName.Description))) 35 | { 36 | var dnsHostEntry = Dns.GetHostEntry(Dns.GetHostName()); 37 | networkInterfaceName.InternalIp = 38 | dnsHostEntry.AddressList.First(x => x.AddressFamily.Equals(AddressFamily.InterNetwork)).ToString(); 39 | } 40 | } 41 | } 42 | 43 | /* 44 | * Private fields 45 | */ 46 | 47 | private NetworkInterfaceName _currentNetworkInterfaceName; 48 | private MtObservableCollection _networkInterfaceNames; 49 | private float? _networkBytesSent; 50 | private float? _networkBytesRecieved; 51 | private Timer _timer; 52 | private RelayCommand _cmdSetNetworkInterfaceName; 53 | private RelayCommand _cmdStartMonitoring; 54 | 55 | /* 56 | * Public fields 57 | */ 58 | 59 | public NetworkInterfaceName CurrentNetworkInterfaceName 60 | { 61 | get { return _currentNetworkInterfaceName; } 62 | set { SetField(ref _currentNetworkInterfaceName, value); } 63 | } 64 | 65 | public MtObservableCollection NetworkInterfaceNames 66 | { 67 | get { return _networkInterfaceNames; } 68 | set { SetField(ref _networkInterfaceNames, value); } 69 | } 70 | 71 | public float? NetworkBytesSent 72 | { 73 | get { return _networkBytesSent; } 74 | set { SetField(ref _networkBytesSent, value); } 75 | } 76 | 77 | public float? NetworkBytesRecieved 78 | { 79 | get { return _networkBytesRecieved; } 80 | set { SetField(ref _networkBytesRecieved, value); } 81 | } 82 | 83 | /* 84 | * Commands 85 | */ 86 | 87 | public RelayCommand CmdSetNetworkInterfaceName 88 | { 89 | get 90 | { 91 | return _cmdSetNetworkInterfaceName ?? 92 | (_cmdSetNetworkInterfaceName = new RelayCommand(Execute_SetNetworkInterfaceName, p => true)); 93 | } 94 | } 95 | 96 | public RelayCommand CmdStartMonitoring 97 | { 98 | get 99 | { 100 | return _cmdStartMonitoring ?? 101 | (_cmdStartMonitoring = new RelayCommand(Execute_StartMonitoring, p => true)); 102 | } 103 | } 104 | 105 | /* 106 | * Methods 107 | */ 108 | 109 | private void Execute_SetNetworkInterfaceName(object obj) 110 | { 111 | // Get all network interfaces and filter out unwanted 112 | var networkInterfaces = 113 | NetworkInterface.GetAllNetworkInterfaces(). 114 | Where( 115 | x => 116 | x.OperationalStatus == OperationalStatus.Up && 117 | x.NetworkInterfaceType != NetworkInterfaceType.Loopback && 118 | x.NetworkInterfaceType != NetworkInterfaceType.Tunnel); 119 | 120 | // Loop the results 121 | foreach (var networkInterface in networkInterfaces) 122 | { 123 | var nic = networkInterface.Description; 124 | 125 | // PerformanceCounter class uses different characters than the GetAllNetworkInterfaces class, so replace them 126 | nic = nic.Replace("\\", "_"); 127 | nic = nic.Replace("/", "_"); 128 | nic = nic.Replace("(", "["); 129 | nic = nic.Replace(")", "]"); 130 | nic = nic.Replace("#", "_"); 131 | 132 | // Add it to the collection 133 | NetworkInterfaceNames.Add(new NetworkInterfaceName 134 | { 135 | Description = nic, 136 | NetworkInterface = networkInterface 137 | }); 138 | 139 | Logger.WriteLine($"Added network interface: '{nic}', of type: '{networkInterface.NetworkInterfaceType}', id: '{networkInterface.Id}'", true); 140 | 141 | if (NetworkInterfaceNames.Count > 0) 142 | { 143 | foreach (var networkInterfaceName in NetworkInterfaceNames.Where(networkInterfaceName => networkInterfaceName.Description.Equals(CurrentNetworkInterfaceName.Description))) 144 | { 145 | var dnsHostEntry = Dns.GetHostEntry(Dns.GetHostName()); 146 | networkInterfaceName.InternalIp = 147 | dnsHostEntry.AddressList.First(x => x.AddressFamily.Equals(AddressFamily.InterNetwork)).ToString(); 148 | } 149 | } 150 | } 151 | 152 | // Set the first nic as current adapter, if any 153 | if (NetworkInterfaceNames.Count > 0) 154 | { 155 | CurrentNetworkInterfaceName.Description = NetworkInterfaceNames.First().Description; 156 | 157 | Logger.WriteLine($"Current network interface set to: '{CurrentNetworkInterfaceName.Description}'", true); 158 | } 159 | } 160 | 161 | private void Execute_StartMonitoring(object obj) 162 | { 163 | NetworkBytesSent = Settings.Default.ShowUpload 164 | ? Counters.GetNetworkBytesSentValue(CurrentNetworkInterfaceName.Description) 165 | : 0; 166 | 167 | NetworkBytesRecieved = Settings.Default.ShowDownload 168 | ? Counters.GetNetworkBytesRecievedValue(CurrentNetworkInterfaceName.Description) 169 | : 0; 170 | 171 | // Create polling timer 172 | CreatePollingTimer(); 173 | } 174 | 175 | private void CreatePollingTimer() 176 | { 177 | _timer = new Timer(1000); 178 | _timer.Elapsed += TimerOnElapsed; 179 | _timer.Start(); 180 | 181 | Logger.WriteLine($"Created polling timer instance with interval: '{_timer.Interval}' in NetworkMonitoringVm", true); 182 | } 183 | 184 | private void TimerOnElapsed(object sender, ElapsedEventArgs e) 185 | { 186 | NetworkBytesSent = Settings.Default.ShowUpload 187 | ? Counters.GetNetworkBytesSentValue(CurrentNetworkInterfaceName.Description) 188 | : 0; 189 | 190 | NetworkBytesRecieved = Settings.Default.ShowDownload 191 | ? Counters.GetNetworkBytesRecievedValue(CurrentNetworkInterfaceName.Description) 192 | : 0; 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /KAEOS/KAEOS.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2201BF4F-F35A-4847-A079-DCD06B2C7E39} 8 | WinExe 9 | Properties 10 | KAEOS 11 | KAEOS 12 | v4.5.2 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | publish\ 18 | true 19 | Disk 20 | false 21 | Foreground 22 | 7 23 | Days 24 | false 25 | false 26 | true 27 | 0 28 | 1.0.0.%2a 29 | false 30 | false 31 | true 32 | 33 | 34 | AnyCPU 35 | true 36 | full 37 | false 38 | bin\Debug\ 39 | DEBUG;TRACE 40 | prompt 41 | 4 42 | 43 | 44 | AnyCPU 45 | pdbonly 46 | true 47 | bin\Release\ 48 | TRACE 49 | prompt 50 | 4 51 | 52 | 53 | 54 | app.manifest 55 | 56 | 57 | 58 | ..\packages\LiveCharts.0.7.11\lib\portable-net40+sl5+win8+wp8+wpa81\LiveCharts.dll 59 | True 60 | 61 | 62 | ..\packages\LiveCharts.Wpf.0.7.11\lib\net452\LiveCharts.Wpf.dll 63 | True 64 | 65 | 66 | False 67 | D:\Google Drive\HRTZ\.NET Libraries\OpenHardwareMonitorLib.dll 68 | True 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 4.0 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | MSBuild:Compile 89 | Designer 90 | 91 | 92 | GaugeContainer.xaml 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Designer 114 | MSBuild:Compile 115 | 116 | 117 | MSBuild:Compile 118 | Designer 119 | 120 | 121 | App.xaml 122 | Code 123 | 124 | 125 | 126 | 127 | MainWindow.xaml 128 | Code 129 | 130 | 131 | Designer 132 | MSBuild:Compile 133 | 134 | 135 | Designer 136 | MSBuild:Compile 137 | 138 | 139 | Designer 140 | MSBuild:Compile 141 | 142 | 143 | Designer 144 | MSBuild:Compile 145 | 146 | 147 | 148 | 149 | 150 | Code 151 | 152 | 153 | True 154 | True 155 | Resources.resx 156 | 157 | 158 | True 159 | Settings.settings 160 | True 161 | 162 | 163 | ResXFileCodeGenerator 164 | Resources.Designer.cs 165 | 166 | 167 | 168 | 169 | SettingsSingleFileGenerator 170 | Settings.Designer.cs 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | False 183 | Microsoft .NET Framework 4.5.2 %28x86 and x64%29 184 | true 185 | 186 | 187 | False 188 | .NET Framework 3.5 SP1 189 | false 190 | 191 | 192 | 193 | 200 | -------------------------------------------------------------------------------- /KAEOS/ViewModels/HardwareMonitoringVm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Timers; 4 | using KAEOS.Extensions; 5 | using KAEOS.Models; 6 | using KAEOS.Properties; 7 | using KAEOS.Utilities; 8 | using OpenHardwareMonitor.Hardware; 9 | 10 | namespace KAEOS.ViewModels 11 | { 12 | public class HardwareMonitoringVm : ObservableObject 13 | { 14 | public HardwareMonitoringVm() 15 | { 16 | MonitoredHardware = new MonitoredHardware(); 17 | 18 | if (CmdStartMonitoring.CanExecute(null)) 19 | CmdStartMonitoring.Execute(null); 20 | } 21 | 22 | /* 23 | * Private fields 24 | */ 25 | 26 | private MonitoredHardware _monitoredHardware; 27 | private Computer _computer; 28 | private Timer _timer; 29 | private RelayCommand _cmdStartMonitoring; 30 | private RelayCommand _cmdRestartMonitoring; 31 | private RelayCommand _cmdPrintReport; 32 | 33 | /* 34 | * Public fields 35 | */ 36 | 37 | public MonitoredHardware MonitoredHardware 38 | { 39 | get { return _monitoredHardware; } 40 | set { SetField(ref _monitoredHardware, value); } 41 | } 42 | 43 | /* 44 | * Commands 45 | */ 46 | 47 | public RelayCommand CmdStartMonitoring 48 | { 49 | get 50 | { 51 | return _cmdStartMonitoring ?? 52 | (_cmdStartMonitoring = new RelayCommand(Execute_StartMonitoring, p => true)); 53 | } 54 | } 55 | 56 | public RelayCommand CmdRestartMonitoring 57 | { 58 | get 59 | { 60 | return _cmdRestartMonitoring ?? 61 | (_cmdRestartMonitoring = new RelayCommand(Execute_ReStartMonitoring, p => true)); 62 | } 63 | } 64 | 65 | public RelayCommand CmdPrintReport 66 | { 67 | get 68 | { 69 | return _cmdPrintReport ?? 70 | (_cmdPrintReport = new RelayCommand(Execute_PrintReport, p => true)); 71 | } 72 | } 73 | 74 | /* 75 | * Methods 76 | */ 77 | 78 | private void Execute_StartMonitoring(object obj) 79 | { 80 | // Create computer instance 81 | _computer = new Computer 82 | { 83 | GPUEnabled = Settings.Default.ShowGpu, 84 | CPUEnabled = Settings.Default.ShowCpu, 85 | RAMEnabled = Settings.Default.ShowRam 86 | }; 87 | 88 | Logger.WriteLine($"Created computer instance with parameters; GPU Enabled: '{_computer.GPUEnabled}', CPU Enabled: '{_computer.CPUEnabled}', RAM Enabled: '{_computer.RAMEnabled}'", true); 89 | 90 | // Start computer instance 91 | _computer.Open(); 92 | 93 | // Iterate all hardware 94 | foreach (var hardware in _computer.Hardware.Where(hardware => hardware != null)) 95 | { 96 | // Get hardware values 97 | hardware.Update(); 98 | 99 | // Get GPU 100 | if (hardware.HardwareType.Equals(HardwareType.GpuNvidia) && Settings.Default.ShowGpu) 101 | { 102 | var name = hardware.Name; 103 | var load = GetSensorValue(hardware, SensorType.Load, "GPU Core"); 104 | var temperature = GetSensorValue(hardware, SensorType.Temperature, "GPU Core"); 105 | var fanSpeed = GetSensorValue(hardware, SensorType.Fan); 106 | 107 | MonitoredHardware.GpuNvidias.Add(new GpuNvidia 108 | { 109 | Name = name, 110 | Temperature = temperature, 111 | Load = load, 112 | FanSpeed = fanSpeed, 113 | Hardware = hardware 114 | }); 115 | 116 | Logger.WriteLine($"Added hardware: '{hardware.Name}', of type: '{hardware.HardwareType}', id: '{hardware.Identifier}'", true); 117 | } 118 | 119 | // Get CPU 120 | if (hardware.HardwareType.Equals(HardwareType.CPU) && Settings.Default.ShowCpu) 121 | { 122 | var name = hardware.Name; 123 | var load = GetSensorValue(hardware, SensorType.Load, "CPU Total"); 124 | var temperature = GetSensorValue(hardware, SensorType.Temperature, "CPU Package"); 125 | var fanSpeed = GetSensorValue(hardware, SensorType.Fan); 126 | 127 | // Add to collection 128 | MonitoredHardware.Cpus.Add(new Cpu 129 | { 130 | Name = name, 131 | Temperature = temperature, 132 | Load = load, 133 | FanSpeed = fanSpeed, 134 | Hardware = hardware 135 | }); 136 | 137 | Logger.WriteLine($"Added hardware: '{hardware.Name}', of type: '{hardware.HardwareType}', id: '{hardware.Identifier}'", true); 138 | } 139 | 140 | // Get RAM 141 | if (hardware.HardwareType.Equals(HardwareType.RAM) && Settings.Default.ShowRam) 142 | { 143 | var name = hardware.Name; 144 | var load = GetSensorValue(hardware, SensorType.Load, "Memory"); 145 | 146 | // If vendor name could not be resolved, try to get from wmi 147 | if (name.Equals("Generic Memory")) 148 | { 149 | var partNumber = WmiHelper.GetValueFromWmi("root\\CIMV2", "SELECT * FROM Win32_PhysicalMemory", "PartNumber"); 150 | if (partNumber != null) 151 | { 152 | name = GetMemoryModelNameFromPartNumber(partNumber); 153 | 154 | Logger.WriteLine($"Resolved memory ({hardware.Name}) part number from WMI: '{partNumber}', model name: '{name}'", true); 155 | } 156 | } 157 | 158 | // Add to collection 159 | MonitoredHardware.Rams.Add(new Ram 160 | { 161 | Name = name, 162 | Load = load, 163 | Hardware = hardware 164 | }); 165 | 166 | Logger.WriteLine($"Added hardware: '{name}', of type: '{hardware.HardwareType}', id: '{hardware.Identifier}'", true); 167 | } 168 | } 169 | 170 | // Create polling timer 171 | CreatePollingTimer(); 172 | } 173 | 174 | private void Execute_ReStartMonitoring(object obj) 175 | { 176 | _computer?.Close(); 177 | Logger.WriteLine("Closed running computer instance in HardwareMonitoringVm", true); 178 | 179 | _timer?.Dispose(); 180 | Logger.WriteLine("Disposed running polling timer instance in HardwareMonitoringVm", true); 181 | 182 | if (MonitoredHardware != null) 183 | { 184 | MonitoredHardware = new MonitoredHardware(); 185 | Logger.WriteLine("Reset monitored hardware class in HardwareMonitoringVm", true); 186 | } 187 | 188 | if (CmdStartMonitoring.CanExecute(null)) 189 | CmdStartMonitoring.Execute(null); 190 | } 191 | 192 | private void CreatePollingTimer() 193 | { 194 | _timer = new Timer(1000); 195 | _timer.Elapsed += TimerOnElapsed; 196 | _timer.Start(); 197 | 198 | Logger.WriteLine($"Created polling timer instance with interval: '{_timer.Interval}' in HardwareMonitoringVm", true); 199 | } 200 | 201 | private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) 202 | { 203 | // Update values -- Gpu Nvidia 204 | if (MonitoredHardware.GpuNvidias != null) 205 | foreach (var gpu in MonitoredHardware.GpuNvidias.Where(gpu => gpu.Hardware != null)) 206 | { 207 | gpu.Hardware.Update(); 208 | 209 | var load = GetSensorValue(gpu.Hardware, SensorType.Load, "GPU Core"); 210 | var temperature = GetSensorValue(gpu.Hardware, SensorType.Temperature, "GPU Core"); 211 | var fanSpeed = Settings.Default.ShowGpuFan ? GetSensorValue(gpu.Hardware, SensorType.Fan) : 0; 212 | 213 | gpu.Load = load; 214 | gpu.Temperature = temperature; 215 | gpu.FanSpeed = fanSpeed; 216 | } 217 | 218 | // Update values -- Cpu 219 | if (MonitoredHardware.Cpus != null) 220 | foreach (var cpu in MonitoredHardware.Cpus.Where(cpu => cpu.Hardware != null)) 221 | { 222 | cpu.Hardware.Update(); 223 | 224 | var load = GetSensorValue(cpu.Hardware, SensorType.Load, "CPU Total"); 225 | var temperature = GetSensorValue(cpu.Hardware, SensorType.Temperature, "CPU Package"); 226 | var fanSpeed = Settings.Default.ShowCpuFan ? GetSensorValue(cpu.Hardware, SensorType.Fan) : 0; 227 | 228 | cpu.Load = load; 229 | cpu.Temperature = temperature; 230 | cpu.FanSpeed = fanSpeed; 231 | } 232 | 233 | // Update values -- Ram 234 | if (MonitoredHardware.Rams != null) 235 | foreach (var ram in MonitoredHardware.Rams.Where(ram => ram.Hardware != null)) 236 | { 237 | ram.Hardware.Update(); 238 | 239 | var load = GetSensorValue(ram.Hardware, SensorType.Load, "Memory"); 240 | 241 | ram.Load = load; 242 | } 243 | } 244 | 245 | private void Execute_PrintReport(object obj) 246 | { 247 | var report = _computer?.GetReport(); 248 | 249 | Logger.WriteLine(report, true); 250 | } 251 | 252 | private static float? GetSensorValue(IHardware hardware, SensorType sensorType, string sensorName = null) 253 | { 254 | float? results = null; 255 | 256 | // Check if sensor exists 257 | var hasValue = sensorName == null 258 | ? hardware.Sensors?.Any(x => x.SensorType.Equals(sensorType)) 259 | : hardware.Sensors?.Any(x => x.SensorType.Equals(sensorType) && x.Name.Equals(sensorName)); 260 | var b = !hasValue; 261 | if (b != null && (bool) b) 262 | return 0; 263 | 264 | try 265 | { 266 | results = sensorName == null 267 | ? hardware.Sensors?.First(x => x.SensorType.Equals(sensorType)).Value 268 | : hardware.Sensors?.First(x => x.SensorType.Equals(sensorType) && x.Name.Equals(sensorName)).Value; 269 | } 270 | catch (Exception ex) 271 | { 272 | Logger.WriteLine($"Unable to get sensor value from hardware name: '{hardware.Name}', of type: '{sensorType}', sensor name: '{sensorName}' -- Exception: {ex.Message}", true); 273 | } 274 | 275 | return results ?? 0; 276 | } 277 | 278 | private static string GetMemoryModelNameFromPartNumber(string partNumber) 279 | { 280 | var results = "Generic Memory"; 281 | 282 | switch (partNumber) 283 | { 284 | case "CMK16GX4M4A2800C16": 285 | results = "Corsair Vengeance LPX"; 286 | break; 287 | } 288 | 289 | return results; 290 | } 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /KAEOS/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 65 | 66 | 67 | 68 | 69 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /KAEOS/Properties/Annotations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #pragma warning disable 1591 4 | // ReSharper disable UnusedMember.Global 5 | // ReSharper disable MemberCanBePrivate.Global 6 | // ReSharper disable UnusedAutoPropertyAccessor.Global 7 | // ReSharper disable IntroduceOptionalParameters.Global 8 | // ReSharper disable MemberCanBeProtected.Global 9 | // ReSharper disable InconsistentNaming 10 | // ReSharper disable CheckNamespace 11 | 12 | namespace KAEOS.Annotations 13 | { 14 | /// 15 | /// Indicates that the value of the marked element could be null sometimes, 16 | /// so the check for null is necessary before its usage. 17 | /// 18 | /// 19 | /// [CanBeNull] public object Test() { return null; } 20 | /// public void UseTest() { 21 | /// var p = Test(); 22 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' 23 | /// } 24 | /// 25 | [AttributeUsage( 26 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 27 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] 28 | public sealed class CanBeNullAttribute : Attribute { } 29 | 30 | /// 31 | /// Indicates that the value of the marked element could never be null. 32 | /// 33 | /// 34 | /// [NotNull] public object Foo() { 35 | /// return null; // Warning: Possible 'null' assignment 36 | /// } 37 | /// 38 | [AttributeUsage( 39 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 40 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)] 41 | public sealed class NotNullAttribute : Attribute { } 42 | 43 | /// 44 | /// Indicates that collection or enumerable value does not contain null elements. 45 | /// 46 | [AttributeUsage( 47 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 48 | AttributeTargets.Delegate | AttributeTargets.Field)] 49 | public sealed class ItemNotNullAttribute : Attribute { } 50 | 51 | /// 52 | /// Indicates that collection or enumerable value can contain null elements. 53 | /// 54 | [AttributeUsage( 55 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 56 | AttributeTargets.Delegate | AttributeTargets.Field)] 57 | public sealed class ItemCanBeNullAttribute : Attribute { } 58 | 59 | /// 60 | /// Indicates that the marked method builds string by format pattern and (optional) arguments. 61 | /// Parameter, which contains format string, should be given in constructor. The format string 62 | /// should be in -like form. 63 | /// 64 | /// 65 | /// [StringFormatMethod("message")] 66 | /// public void ShowError(string message, params object[] args) { /* do something */ } 67 | /// public void Foo() { 68 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string 69 | /// } 70 | /// 71 | [AttributeUsage( 72 | AttributeTargets.Constructor | AttributeTargets.Method | 73 | AttributeTargets.Property | AttributeTargets.Delegate)] 74 | public sealed class StringFormatMethodAttribute : Attribute 75 | { 76 | /// 77 | /// Specifies which parameter of an annotated method should be treated as format-string 78 | /// 79 | public StringFormatMethodAttribute(string formatParameterName) 80 | { 81 | FormatParameterName = formatParameterName; 82 | } 83 | 84 | public string FormatParameterName { get; private set; } 85 | } 86 | 87 | /// 88 | /// For a parameter that is expected to be one of the limited set of values. 89 | /// Specify fields of which type should be used as values for this parameter. 90 | /// 91 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] 92 | public sealed class ValueProviderAttribute : Attribute 93 | { 94 | public ValueProviderAttribute(string name) 95 | { 96 | Name = name; 97 | } 98 | 99 | [NotNull] public string Name { get; private set; } 100 | } 101 | 102 | /// 103 | /// Indicates that the function argument should be string literal and match one 104 | /// of the parameters of the caller function. For example, ReSharper annotates 105 | /// the parameter of . 106 | /// 107 | /// 108 | /// public void Foo(string param) { 109 | /// if (param == null) 110 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol 111 | /// } 112 | /// 113 | [AttributeUsage(AttributeTargets.Parameter)] 114 | public sealed class InvokerParameterNameAttribute : Attribute { } 115 | 116 | /// 117 | /// Indicates that the method is contained in a type that implements 118 | /// System.ComponentModel.INotifyPropertyChanged interface and this method 119 | /// is used to notify that some property value changed. 120 | /// 121 | /// 122 | /// The method should be non-static and conform to one of the supported signatures: 123 | /// 124 | /// NotifyChanged(string) 125 | /// NotifyChanged(params string[]) 126 | /// NotifyChanged{T}(Expression{Func{T}}) 127 | /// NotifyChanged{T,U}(Expression{Func{T,U}}) 128 | /// SetProperty{T}(ref T, T, string) 129 | /// 130 | /// 131 | /// 132 | /// public class Foo : INotifyPropertyChanged { 133 | /// public event PropertyChangedEventHandler PropertyChanged; 134 | /// [NotifyPropertyChangedInvocator] 135 | /// protected virtual void NotifyChanged(string propertyName) { ... } 136 | /// 137 | /// private string _name; 138 | /// public string Name { 139 | /// get { return _name; } 140 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } 141 | /// } 142 | /// } 143 | /// 144 | /// Examples of generated notifications: 145 | /// 146 | /// NotifyChanged("Property") 147 | /// NotifyChanged(() => Property) 148 | /// NotifyChanged((VM x) => x.Property) 149 | /// SetProperty(ref myField, value, "Property") 150 | /// 151 | /// 152 | [AttributeUsage(AttributeTargets.Method)] 153 | public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute 154 | { 155 | public NotifyPropertyChangedInvocatorAttribute() { } 156 | public NotifyPropertyChangedInvocatorAttribute(string parameterName) 157 | { 158 | ParameterName = parameterName; 159 | } 160 | 161 | public string ParameterName { get; private set; } 162 | } 163 | 164 | /// 165 | /// Describes dependency between method input and output. 166 | /// 167 | /// 168 | ///

Function Definition Table syntax:

169 | /// 170 | /// FDT ::= FDTRow [;FDTRow]* 171 | /// FDTRow ::= Input => Output | Output <= Input 172 | /// Input ::= ParameterName: Value [, Input]* 173 | /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} 174 | /// Value ::= true | false | null | notnull | canbenull 175 | /// 176 | /// If method has single input parameter, it's name could be omitted.
177 | /// Using halt (or void/nothing, which is the same) 178 | /// for method output means that the methos doesn't return normally.
179 | /// canbenull annotation is only applicable for output parameters.
180 | /// You can use multiple [ContractAnnotation] for each FDT row, 181 | /// or use single attribute with rows separated by semicolon.
182 | ///
183 | /// 184 | /// 185 | /// [ContractAnnotation("=> halt")] 186 | /// public void TerminationMethod() 187 | /// 188 | /// 189 | /// [ContractAnnotation("halt <= condition: false")] 190 | /// public void Assert(bool condition, string text) // regular assertion method 191 | /// 192 | /// 193 | /// [ContractAnnotation("s:null => true")] 194 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() 195 | /// 196 | /// 197 | /// // A method that returns null if the parameter is null, 198 | /// // and not null if the parameter is not null 199 | /// [ContractAnnotation("null => null; notnull => notnull")] 200 | /// public object Transform(object data) 201 | /// 202 | /// 203 | /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] 204 | /// public bool TryParse(string s, out Person result) 205 | /// 206 | /// 207 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 208 | public sealed class ContractAnnotationAttribute : Attribute 209 | { 210 | public ContractAnnotationAttribute([NotNull] string contract) 211 | : this(contract, false) { } 212 | 213 | public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) 214 | { 215 | Contract = contract; 216 | ForceFullStates = forceFullStates; 217 | } 218 | 219 | public string Contract { get; private set; } 220 | public bool ForceFullStates { get; private set; } 221 | } 222 | 223 | /// 224 | /// Indicates that marked element should be localized or not. 225 | /// 226 | /// 227 | /// [LocalizationRequiredAttribute(true)] 228 | /// public class Foo { 229 | /// private string str = "my string"; // Warning: Localizable string 230 | /// } 231 | /// 232 | [AttributeUsage(AttributeTargets.All)] 233 | public sealed class LocalizationRequiredAttribute : Attribute 234 | { 235 | public LocalizationRequiredAttribute() : this(true) { } 236 | public LocalizationRequiredAttribute(bool required) 237 | { 238 | Required = required; 239 | } 240 | 241 | public bool Required { get; private set; } 242 | } 243 | 244 | /// 245 | /// Indicates that the value of the marked type (or its derivatives) 246 | /// cannot be compared using '==' or '!=' operators and Equals() 247 | /// should be used instead. However, using '==' or '!=' for comparison 248 | /// with null is always permitted. 249 | /// 250 | /// 251 | /// [CannotApplyEqualityOperator] 252 | /// class NoEquality { } 253 | /// class UsesNoEquality { 254 | /// public void Test() { 255 | /// var ca1 = new NoEquality(); 256 | /// var ca2 = new NoEquality(); 257 | /// if (ca1 != null) { // OK 258 | /// bool condition = ca1 == ca2; // Warning 259 | /// } 260 | /// } 261 | /// } 262 | /// 263 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] 264 | public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } 265 | 266 | /// 267 | /// When applied to a target attribute, specifies a requirement for any type marked 268 | /// with the target attribute to implement or inherit specific type or types. 269 | /// 270 | /// 271 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement 272 | /// public class ComponentAttribute : Attribute { } 273 | /// [Component] // ComponentAttribute requires implementing IComponent interface 274 | /// public class MyComponent : IComponent { } 275 | /// 276 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 277 | [BaseTypeRequired(typeof(Attribute))] 278 | public sealed class BaseTypeRequiredAttribute : Attribute 279 | { 280 | public BaseTypeRequiredAttribute([NotNull] Type baseType) 281 | { 282 | BaseType = baseType; 283 | } 284 | 285 | [NotNull] public Type BaseType { get; private set; } 286 | } 287 | 288 | /// 289 | /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), 290 | /// so this symbol will not be marked as unused (as well as by other usage inspections). 291 | /// 292 | [AttributeUsage(AttributeTargets.All)] 293 | public sealed class UsedImplicitlyAttribute : Attribute 294 | { 295 | public UsedImplicitlyAttribute() 296 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 297 | 298 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) 299 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 300 | 301 | public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) 302 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 303 | 304 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 305 | { 306 | UseKindFlags = useKindFlags; 307 | TargetFlags = targetFlags; 308 | } 309 | 310 | public ImplicitUseKindFlags UseKindFlags { get; private set; } 311 | public ImplicitUseTargetFlags TargetFlags { get; private set; } 312 | } 313 | 314 | /// 315 | /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes 316 | /// as unused (as well as by other usage inspections) 317 | /// 318 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] 319 | public sealed class MeansImplicitUseAttribute : Attribute 320 | { 321 | public MeansImplicitUseAttribute() 322 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 323 | 324 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) 325 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 326 | 327 | public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) 328 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 329 | 330 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 331 | { 332 | UseKindFlags = useKindFlags; 333 | TargetFlags = targetFlags; 334 | } 335 | 336 | [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } 337 | [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } 338 | } 339 | 340 | [Flags] 341 | public enum ImplicitUseKindFlags 342 | { 343 | Default = Access | Assign | InstantiatedWithFixedConstructorSignature, 344 | /// Only entity marked with attribute considered used. 345 | Access = 1, 346 | /// Indicates implicit assignment to a member. 347 | Assign = 2, 348 | /// 349 | /// Indicates implicit instantiation of a type with fixed constructor signature. 350 | /// That means any unused constructor parameters won't be reported as such. 351 | /// 352 | InstantiatedWithFixedConstructorSignature = 4, 353 | /// Indicates implicit instantiation of a type. 354 | InstantiatedNoFixedConstructorSignature = 8, 355 | } 356 | 357 | /// 358 | /// Specify what is considered used implicitly when marked 359 | /// with or . 360 | /// 361 | [Flags] 362 | public enum ImplicitUseTargetFlags 363 | { 364 | Default = Itself, 365 | Itself = 1, 366 | /// Members of entity marked with attribute are considered used. 367 | Members = 2, 368 | /// Entity marked with attribute and all its members considered used. 369 | WithMembers = Itself | Members 370 | } 371 | 372 | /// 373 | /// This attribute is intended to mark publicly available API 374 | /// which should not be removed and so is treated as used. 375 | /// 376 | [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] 377 | public sealed class PublicAPIAttribute : Attribute 378 | { 379 | public PublicAPIAttribute() { } 380 | public PublicAPIAttribute([NotNull] string comment) 381 | { 382 | Comment = comment; 383 | } 384 | 385 | public string Comment { get; private set; } 386 | } 387 | 388 | /// 389 | /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. 390 | /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. 391 | /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. 392 | /// 393 | [AttributeUsage(AttributeTargets.Parameter)] 394 | public sealed class InstantHandleAttribute : Attribute { } 395 | 396 | /// 397 | /// Indicates that a method does not make any observable state changes. 398 | /// The same as System.Diagnostics.Contracts.PureAttribute. 399 | /// 400 | /// 401 | /// [Pure] private int Multiply(int x, int y) { return x * y; } 402 | /// public void Foo() { 403 | /// const int a = 2, b = 2; 404 | /// Multiply(a, b); // Waring: Return value of pure method is not used 405 | /// } 406 | /// 407 | [AttributeUsage(AttributeTargets.Method)] 408 | public sealed class PureAttribute : Attribute { } 409 | 410 | /// 411 | /// Indicates that a parameter is a path to a file or a folder within a web project. 412 | /// Path can be relative or absolute, starting from web root (~). 413 | /// 414 | [AttributeUsage(AttributeTargets.Parameter)] 415 | public sealed class PathReferenceAttribute : Attribute 416 | { 417 | public PathReferenceAttribute() { } 418 | public PathReferenceAttribute([PathReference] string basePath) 419 | { 420 | BasePath = basePath; 421 | } 422 | 423 | public string BasePath { get; private set; } 424 | } 425 | 426 | /// 427 | /// An extension method marked with this attribute is processed by ReSharper code completion 428 | /// as a 'Source Template'. When extension method is completed over some expression, it's source code 429 | /// is automatically expanded like a template at call site. 430 | /// 431 | /// 432 | /// Template method body can contain valid source code and/or special comments starting with '$'. 433 | /// Text inside these comments is added as source code when the template is applied. Template parameters 434 | /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. 435 | /// Use the attribute to specify macros for parameters. 436 | /// 437 | /// 438 | /// In this example, the 'forEach' method is a source template available over all values 439 | /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: 440 | /// 441 | /// [SourceTemplate] 442 | /// public static void forEach<T>(this IEnumerable<T> xs) { 443 | /// foreach (var x in xs) { 444 | /// //$ $END$ 445 | /// } 446 | /// } 447 | /// 448 | /// 449 | [AttributeUsage(AttributeTargets.Method)] 450 | public sealed class SourceTemplateAttribute : Attribute { } 451 | 452 | /// 453 | /// Allows specifying a macro for a parameter of a source template. 454 | /// 455 | /// 456 | /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression 457 | /// is defined in the property. When applied on a method, the target 458 | /// template parameter is defined in the property. To apply the macro silently 459 | /// for the parameter, set the property value = -1. 460 | /// 461 | /// 462 | /// Applying the attribute on a source template method: 463 | /// 464 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] 465 | /// public static void forEach<T>(this IEnumerable<T> collection) { 466 | /// foreach (var item in collection) { 467 | /// //$ $END$ 468 | /// } 469 | /// } 470 | /// 471 | /// Applying the attribute on a template method parameter: 472 | /// 473 | /// [SourceTemplate] 474 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { 475 | /// /*$ var $x$Id = "$newguid$" + x.ToString(); 476 | /// x.DoSomething($x$Id); */ 477 | /// } 478 | /// 479 | /// 480 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] 481 | public sealed class MacroAttribute : Attribute 482 | { 483 | /// 484 | /// Allows specifying a macro that will be executed for a source template 485 | /// parameter when the template is expanded. 486 | /// 487 | public string Expression { get; set; } 488 | 489 | /// 490 | /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. 491 | /// 492 | /// 493 | /// If the target parameter is used several times in the template, only one occurrence becomes editable; 494 | /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, 495 | /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. 496 | /// > 497 | public int Editable { get; set; } 498 | 499 | /// 500 | /// Identifies the target parameter of a source template if the 501 | /// is applied on a template method. 502 | /// 503 | public string Target { get; set; } 504 | } 505 | 506 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 507 | public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute 508 | { 509 | public AspMvcAreaMasterLocationFormatAttribute(string format) 510 | { 511 | Format = format; 512 | } 513 | 514 | public string Format { get; private set; } 515 | } 516 | 517 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 518 | public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute 519 | { 520 | public AspMvcAreaPartialViewLocationFormatAttribute(string format) 521 | { 522 | Format = format; 523 | } 524 | 525 | public string Format { get; private set; } 526 | } 527 | 528 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 529 | public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute 530 | { 531 | public AspMvcAreaViewLocationFormatAttribute(string format) 532 | { 533 | Format = format; 534 | } 535 | 536 | public string Format { get; private set; } 537 | } 538 | 539 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 540 | public sealed class AspMvcMasterLocationFormatAttribute : Attribute 541 | { 542 | public AspMvcMasterLocationFormatAttribute(string format) 543 | { 544 | Format = format; 545 | } 546 | 547 | public string Format { get; private set; } 548 | } 549 | 550 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 551 | public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute 552 | { 553 | public AspMvcPartialViewLocationFormatAttribute(string format) 554 | { 555 | Format = format; 556 | } 557 | 558 | public string Format { get; private set; } 559 | } 560 | 561 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 562 | public sealed class AspMvcViewLocationFormatAttribute : Attribute 563 | { 564 | public AspMvcViewLocationFormatAttribute(string format) 565 | { 566 | Format = format; 567 | } 568 | 569 | public string Format { get; private set; } 570 | } 571 | 572 | /// 573 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 574 | /// is an MVC action. If applied to a method, the MVC action name is calculated 575 | /// implicitly from the context. Use this attribute for custom wrappers similar to 576 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 577 | /// 578 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 579 | public sealed class AspMvcActionAttribute : Attribute 580 | { 581 | public AspMvcActionAttribute() { } 582 | public AspMvcActionAttribute(string anonymousProperty) 583 | { 584 | AnonymousProperty = anonymousProperty; 585 | } 586 | 587 | public string AnonymousProperty { get; private set; } 588 | } 589 | 590 | /// 591 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. 592 | /// Use this attribute for custom wrappers similar to 593 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 594 | /// 595 | [AttributeUsage(AttributeTargets.Parameter)] 596 | public sealed class AspMvcAreaAttribute : Attribute 597 | { 598 | public AspMvcAreaAttribute() { } 599 | public AspMvcAreaAttribute(string anonymousProperty) 600 | { 601 | AnonymousProperty = anonymousProperty; 602 | } 603 | 604 | public string AnonymousProperty { get; private set; } 605 | } 606 | 607 | /// 608 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is 609 | /// an MVC controller. If applied to a method, the MVC controller name is calculated 610 | /// implicitly from the context. Use this attribute for custom wrappers similar to 611 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). 612 | /// 613 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 614 | public sealed class AspMvcControllerAttribute : Attribute 615 | { 616 | public AspMvcControllerAttribute() { } 617 | public AspMvcControllerAttribute(string anonymousProperty) 618 | { 619 | AnonymousProperty = anonymousProperty; 620 | } 621 | 622 | public string AnonymousProperty { get; private set; } 623 | } 624 | 625 | /// 626 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute 627 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). 628 | /// 629 | [AttributeUsage(AttributeTargets.Parameter)] 630 | public sealed class AspMvcMasterAttribute : Attribute { } 631 | 632 | /// 633 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute 634 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). 635 | /// 636 | [AttributeUsage(AttributeTargets.Parameter)] 637 | public sealed class AspMvcModelTypeAttribute : Attribute { } 638 | 639 | /// 640 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC 641 | /// partial view. If applied to a method, the MVC partial view name is calculated implicitly 642 | /// from the context. Use this attribute for custom wrappers similar to 643 | /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). 644 | /// 645 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 646 | public sealed class AspMvcPartialViewAttribute : Attribute { } 647 | 648 | /// 649 | /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. 650 | /// 651 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 652 | public sealed class AspMvcSupressViewErrorAttribute : Attribute { } 653 | 654 | /// 655 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. 656 | /// Use this attribute for custom wrappers similar to 657 | /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). 658 | /// 659 | [AttributeUsage(AttributeTargets.Parameter)] 660 | public sealed class AspMvcDisplayTemplateAttribute : Attribute { } 661 | 662 | /// 663 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. 664 | /// Use this attribute for custom wrappers similar to 665 | /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). 666 | /// 667 | [AttributeUsage(AttributeTargets.Parameter)] 668 | public sealed class AspMvcEditorTemplateAttribute : Attribute { } 669 | 670 | /// 671 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. 672 | /// Use this attribute for custom wrappers similar to 673 | /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). 674 | /// 675 | [AttributeUsage(AttributeTargets.Parameter)] 676 | public sealed class AspMvcTemplateAttribute : Attribute { } 677 | 678 | /// 679 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 680 | /// is an MVC view. If applied to a method, the MVC view name is calculated implicitly 681 | /// from the context. Use this attribute for custom wrappers similar to 682 | /// System.Web.Mvc.Controller.View(Object). 683 | /// 684 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 685 | public sealed class AspMvcViewAttribute : Attribute { } 686 | 687 | /// 688 | /// ASP.NET MVC attribute. When applied to a parameter of an attribute, 689 | /// indicates that this parameter is an MVC action name. 690 | /// 691 | /// 692 | /// [ActionName("Foo")] 693 | /// public ActionResult Login(string returnUrl) { 694 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK 695 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action 696 | /// } 697 | /// 698 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] 699 | public sealed class AspMvcActionSelectorAttribute : Attribute { } 700 | 701 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] 702 | public sealed class HtmlElementAttributesAttribute : Attribute 703 | { 704 | public HtmlElementAttributesAttribute() { } 705 | public HtmlElementAttributesAttribute(string name) 706 | { 707 | Name = name; 708 | } 709 | 710 | public string Name { get; private set; } 711 | } 712 | 713 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] 714 | public sealed class HtmlAttributeValueAttribute : Attribute 715 | { 716 | public HtmlAttributeValueAttribute([NotNull] string name) 717 | { 718 | Name = name; 719 | } 720 | 721 | [NotNull] public string Name { get; private set; } 722 | } 723 | 724 | /// 725 | /// Razor attribute. Indicates that a parameter or a method is a Razor section. 726 | /// Use this attribute for custom wrappers similar to 727 | /// System.Web.WebPages.WebPageBase.RenderSection(String). 728 | /// 729 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 730 | public sealed class RazorSectionAttribute : Attribute { } 731 | 732 | /// 733 | /// Indicates how method invocation affects content of the collection. 734 | /// 735 | [AttributeUsage(AttributeTargets.Method)] 736 | public sealed class CollectionAccessAttribute : Attribute 737 | { 738 | public CollectionAccessAttribute(CollectionAccessType collectionAccessType) 739 | { 740 | CollectionAccessType = collectionAccessType; 741 | } 742 | 743 | public CollectionAccessType CollectionAccessType { get; private set; } 744 | } 745 | 746 | [Flags] 747 | public enum CollectionAccessType 748 | { 749 | /// Method does not use or modify content of the collection. 750 | None = 0, 751 | /// Method only reads content of the collection but does not modify it. 752 | Read = 1, 753 | /// Method can change content of the collection but does not add new elements. 754 | ModifyExistingContent = 2, 755 | /// Method can add new elements to the collection. 756 | UpdatedContent = ModifyExistingContent | 4 757 | } 758 | 759 | /// 760 | /// Indicates that the marked method is assertion method, i.e. it halts control flow if 761 | /// one of the conditions is satisfied. To set the condition, mark one of the parameters with 762 | /// attribute. 763 | /// 764 | [AttributeUsage(AttributeTargets.Method)] 765 | public sealed class AssertionMethodAttribute : Attribute { } 766 | 767 | /// 768 | /// Indicates the condition parameter of the assertion method. The method itself should be 769 | /// marked by attribute. The mandatory argument of 770 | /// the attribute is the assertion type. 771 | /// 772 | [AttributeUsage(AttributeTargets.Parameter)] 773 | public sealed class AssertionConditionAttribute : Attribute 774 | { 775 | public AssertionConditionAttribute(AssertionConditionType conditionType) 776 | { 777 | ConditionType = conditionType; 778 | } 779 | 780 | public AssertionConditionType ConditionType { get; private set; } 781 | } 782 | 783 | /// 784 | /// Specifies assertion type. If the assertion method argument satisfies the condition, 785 | /// then the execution continues. Otherwise, execution is assumed to be halted. 786 | /// 787 | public enum AssertionConditionType 788 | { 789 | /// Marked parameter should be evaluated to true. 790 | IS_TRUE = 0, 791 | /// Marked parameter should be evaluated to false. 792 | IS_FALSE = 1, 793 | /// Marked parameter should be evaluated to null value. 794 | IS_NULL = 2, 795 | /// Marked parameter should be evaluated to not null value. 796 | IS_NOT_NULL = 3, 797 | } 798 | 799 | /// 800 | /// Indicates that the marked method unconditionally terminates control flow execution. 801 | /// For example, it could unconditionally throw exception. 802 | /// 803 | [Obsolete("Use [ContractAnnotation('=> halt')] instead")] 804 | [AttributeUsage(AttributeTargets.Method)] 805 | public sealed class TerminatesProgramAttribute : Attribute { } 806 | 807 | /// 808 | /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, 809 | /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters 810 | /// of delegate type by analyzing LINQ method chains. 811 | /// 812 | [AttributeUsage(AttributeTargets.Method)] 813 | public sealed class LinqTunnelAttribute : Attribute { } 814 | 815 | /// 816 | /// Indicates that IEnumerable, passed as parameter, is not enumerated. 817 | /// 818 | [AttributeUsage(AttributeTargets.Parameter)] 819 | public sealed class NoEnumerationAttribute : Attribute { } 820 | 821 | /// 822 | /// Indicates that parameter is regular expression pattern. 823 | /// 824 | [AttributeUsage(AttributeTargets.Parameter)] 825 | public sealed class RegexPatternAttribute : Attribute { } 826 | 827 | /// 828 | /// XAML attribute. Indicates the type that has ItemsSource property and should be treated 829 | /// as ItemsControl-derived type, to enable inner items DataContext type resolve. 830 | /// 831 | [AttributeUsage(AttributeTargets.Class)] 832 | public sealed class XamlItemsControlAttribute : Attribute { } 833 | 834 | /// 835 | /// XAML attibute. Indicates the property of some BindingBase-derived type, that 836 | /// is used to bind some item of ItemsControl-derived type. This annotation will 837 | /// enable the DataContext type resolve for XAML bindings for such properties. 838 | /// 839 | /// 840 | /// Property should have the tree ancestor of the ItemsControl type or 841 | /// marked with the attribute. 842 | /// 843 | [AttributeUsage(AttributeTargets.Property)] 844 | public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } 845 | 846 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 847 | public sealed class AspChildControlTypeAttribute : Attribute 848 | { 849 | public AspChildControlTypeAttribute(string tagName, Type controlType) 850 | { 851 | TagName = tagName; 852 | ControlType = controlType; 853 | } 854 | 855 | public string TagName { get; private set; } 856 | public Type ControlType { get; private set; } 857 | } 858 | 859 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 860 | public sealed class AspDataFieldAttribute : Attribute { } 861 | 862 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 863 | public sealed class AspDataFieldsAttribute : Attribute { } 864 | 865 | [AttributeUsage(AttributeTargets.Property)] 866 | public sealed class AspMethodPropertyAttribute : Attribute { } 867 | 868 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 869 | public sealed class AspRequiredAttributeAttribute : Attribute 870 | { 871 | public AspRequiredAttributeAttribute([NotNull] string attribute) 872 | { 873 | Attribute = attribute; 874 | } 875 | 876 | public string Attribute { get; private set; } 877 | } 878 | 879 | [AttributeUsage(AttributeTargets.Property)] 880 | public sealed class AspTypePropertyAttribute : Attribute 881 | { 882 | public bool CreateConstructorReferences { get; private set; } 883 | 884 | public AspTypePropertyAttribute(bool createConstructorReferences) 885 | { 886 | CreateConstructorReferences = createConstructorReferences; 887 | } 888 | } 889 | 890 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 891 | public sealed class RazorImportNamespaceAttribute : Attribute 892 | { 893 | public RazorImportNamespaceAttribute(string name) 894 | { 895 | Name = name; 896 | } 897 | 898 | public string Name { get; private set; } 899 | } 900 | 901 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 902 | public sealed class RazorInjectionAttribute : Attribute 903 | { 904 | public RazorInjectionAttribute(string type, string fieldName) 905 | { 906 | Type = type; 907 | FieldName = fieldName; 908 | } 909 | 910 | public string Type { get; private set; } 911 | public string FieldName { get; private set; } 912 | } 913 | 914 | [AttributeUsage(AttributeTargets.Method)] 915 | public sealed class RazorHelperCommonAttribute : Attribute { } 916 | 917 | [AttributeUsage(AttributeTargets.Property)] 918 | public sealed class RazorLayoutAttribute : Attribute { } 919 | 920 | [AttributeUsage(AttributeTargets.Method)] 921 | public sealed class RazorWriteLiteralMethodAttribute : Attribute { } 922 | 923 | [AttributeUsage(AttributeTargets.Method)] 924 | public sealed class RazorWriteMethodAttribute : Attribute { } 925 | 926 | [AttributeUsage(AttributeTargets.Parameter)] 927 | public sealed class RazorWriteMethodParameterAttribute : Attribute { } 928 | 929 | /// 930 | /// Prevents the Member Reordering feature from tossing members of the marked class. 931 | /// 932 | /// 933 | /// The attribute must be mentioned in your member reordering patterns 934 | /// 935 | [AttributeUsage(AttributeTargets.All)] 936 | public sealed class NoReorder : Attribute { } 937 | } --------------------------------------------------------------------------------