Example #1
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            UpdateChartRam();

            CpuUse.get_usedPercentage();

            if (CpuUse.isTemperatureRead)
            {
                CpuUse.get_temperatureFunct();
            }


            UpdateChartCpu(CpuUse.UsedPercentage, CpuUse.Temperature);
        }
Example #2
0
        public Form1()
        {
            for (int i = 0; i < ramarray.Length; i++)
            {
                ramarray[i] = 0.00F;
            }

            InitializeComponent();

            this.RamUse = new RamUsage();
            this.CpuUse = new CpuUsage();

            //Set RamoPercChart Type
            this.chartRAMPerc.ChartAreas[0].AxisY.ScaleView.Zoom(0, 100);
            this.chartRAMPerc.ChartAreas[0].AxisY.Title = "Used RAM %";
            this.chartRAMPerc.ChartAreas[0].AxisX.ScaleView.Zoom(0, 100);
            this.chartRAMPerc.ChartAreas[0].AxisX.Title             = "Time (sec)";
            this.chartRAMPerc.ChartAreas[0].BackColor               = SystemColors.Control;
            this.chartRAMPerc.Series[0].Color                       = Color.Blue;
            this.chartRAMPerc.Series[0].ChartType                   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            this.chartRAMPerc.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
            this.chartRAMPerc.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

            //Set CPUPercChart Type
            this.chartCPUPerc.ChartAreas[0].AxisY.ScaleView.Zoom(0, 100);
            this.chartCPUPerc.ChartAreas[0].AxisY.Title = "Used CPU %";
            this.chartCPUPerc.ChartAreas[0].AxisX.ScaleView.Zoom(0, 100);
            this.chartCPUPerc.ChartAreas[0].AxisX.Title             = "Time (sec)";
            this.chartCPUPerc.ChartAreas[0].BackColor               = SystemColors.Control;
            this.chartCPUPerc.Series[0].Color                       = Color.Red;
            this.chartCPUPerc.Series[0].ChartType                   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            this.chartCPUPerc.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
            this.chartCPUPerc.ChartAreas[0].AxisY.MajorGrid.Enabled = false;


            //listview setting
            this.listViewRam.View = View.Details;
            this.listViewRam.Columns.Add("Column1Name");
            this.listViewRam.Columns.Add("Column2Name");
            this.listViewRam.Columns[0].Width = 100;
            this.listViewRam.BackColor        = SystemColors.Control;
            this.listViewRam.GridLines        = true;
            this.listViewRam.HeaderStyle      = System.Windows.Forms.ColumnHeaderStyle.None;

            //Write the total RAM in MB on listview
            float totalRAM = RamUse.get_totalMB();

            this.listViewRam.Items.Add(new ListViewItem(new string[] { "Total Ram (MB): ", totalRAM.ToString("N2") + " MB" }));
            this.listViewRam.Items.Add(new ListViewItem(new string[] { "Used Ram (MB): ", "0.00 MB" }));
            this.listViewRam.Items.Add(new ListViewItem(new string[] { "Used Ram (%): ", "0.00 %" }));

            //listviewCPU setting
            this.listViewCpu.View = View.Details;
            this.listViewCpu.Columns.Add("Column1Name");
            this.listViewCpu.Columns.Add("Column2Name");
            this.listViewCpu.Columns[0].Width = 100;
            this.listViewCpu.BackColor        = SystemColors.Control;
            this.listViewCpu.GridLines        = true;
            this.listViewCpu.HeaderStyle      = System.Windows.Forms.ColumnHeaderStyle.None;

            //Write the Cpu static info
            this.listViewCpu.Items.Add(new ListViewItem(new string[] { "Physical Core: ", CpuUse.get_physicalprocessor().ToString() }));
            this.listViewCpu.Items.Add(new ListViewItem(new string[] { "Cores: ", CpuUse.get_Cores().ToString() }));
            this.listViewCpu.Items.Add(new ListViewItem(new string[] { "Logical Cores: ", CpuUse.LogicalCoresCount.ToString() }));
            this.listViewCpu.Items.Add(new ListViewItem(new string[] { "Used Cpu (%): ", "0.00 %" }));
            this.listViewCpu.Items.Add(new ListViewItem(new string[] { "Temperature (°C): ", "0" }));
        }