-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRamPerformance.cs
31 lines (26 loc) · 1.03 KB
/
RamPerformance.cs
1
2
3
4
5
6
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
using Microsoft.VisualBasic.Devices;
using Microsoft.WindowsAPICodePack.Taskbar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TaskbarPerformance
{
public class RamPerformance : AbstractPerformanceWindow
{
private const float GB = 0x3FFFFFFF + 1;
private readonly ComputerInfo computerInfo = new();
public RamPerformance(Timer timer) : base(timer) {}
public override string FormatText(float value) => $"RAM: {value / GB:0.00} GB";
public override TaskbarProgressBarState MapState(float value) => value switch
{
100 => TaskbarProgressBarState.Error,
> 75 => TaskbarProgressBarState.Paused,
_ => TaskbarProgressBarState.Normal,
};
public override float ProvideMaxValue() => computerInfo.TotalPhysicalMemory;
public override float ProvideValue() => computerInfo.TotalPhysicalMemory - computerInfo.AvailablePhysicalMemory;
}
}