RAM & CPU Monitor:
RAM and CPU Monitor is a small meter which is resides on Our desktop and Provides Useful Information About Our computer's processor and memory Usage. In this tutorial, we will create our Own CPU & RAM Monitor with real time charts using Metro Framework. Follow the Given Steps to Make this Application:
Download Metro Framework:
Metro Framework is an Open Source DLL. we can give High Level Windows Application design by Using Metro Framework. To download Metro frame work, follow the given steps:
After Installation, Rebuild the Project (To Rebuild the Project, Open Solution Explorer, right click on the Project, and click on Rebuild. After that, Go to Your Project Form, Double Click on it, and Now you need to change a single line from the code. Our Class Used to Inherit the Properties and Methods from base class Form, But in this example, we will Inherit the properties from Base Class MetroFramework.Forms.MetroForm. We will create form-class like this:
public partial class Form1 : MetroFramework.Forms.MetroForm
{
public Form1()
{
InitializeComponent();
}
}
After Changing this code, go back to your form, and you'll feel something different. Now drag and Drop controls on form Using tool box as shown in the picture.
If You Didn't found Metro Framework Toolkit in your Toolbox, Follow these steps to Get the Toolkit in your Toolbox.
Now Go to your code page, and write Given code for method Timer_Tick, that we Open Using Timer Properties.
private void timer_Tick(object sender, EventArgs e)
{
float fcpu = perfCounterCPU.NextValue();
float fram = perfCounterRAM.NextValue();
//set value to cpu and ram.
metroProgressBarCPU.Value = (int)fcpu;
metroProgressBarRAM.Value = (int)fram;
//Update Value to CPU and RAM Label.
metroLabelCPU.Text = string.Format("{0:0.00}%", fcpu);
metroLabelRAM.Text = string.Format("{0:0.00}%", fram);
//Draw cpu and RAM Chart.
chart1.Series["CPU"].Points.AddY(fcpu);
chart1.Series["RAM"].Points.AddY(fram);
}
Now double click on anywhere in the form and write the give code to start the timer.
//start the Timer:
private void Form1_Load(object sender, EventArgs e)
{
timer.Start();
}