예제 #1
0
        private void SetHardwareUsage(Computer comp)
        {
            if (this.lblCPUUsage.InvokeRequired)
            {
                SetHardwareUsageCallback d = new SetHardwareUsageCallback(SetHardwareUsage);
                this.Invoke(d, new object[] { comp });
            }
            else
            {
                if (comp.HostName == "")
                {
                }
                else
                {
                    //Set CPU Usage Labels
                    //0 = Uptime: 1 = Utilisation: 2 = Threads: 3 = Processes
                    this.lblUptimeAns.Text    = comp.SystemUpTime.TotalHours.ToString() + ":" + comp.SystemUpTime.TotalMinutes.ToString() + ":" + comp.SystemUpTime.TotalSeconds.ToString();
                    this.lblCPUUsageAns.Text  = comp.SystemProcessor.cpuUsage;
                    this.lblThreadsAns.Text   = comp.SystemProcessor.threads.ToString();
                    this.lblProcessesAns.Text = comp.RunningProcesses.GetProcesses().Count().ToString();

                    //Set RAM Usage Labels

                    this.lblTotalRAMAns.Text = comp.SystemRAM.totalRAM.ToString() + "MB";
                    this.lblFreeRAMAns.Text  = comp.SystemRAM.freeRAM.ToString() + "MB";
                    this.lblInUseRAMAns.Text = (comp.SystemRAM.totalRAM - comp.SystemRAM.freeRAM).ToString() + "MB";

                    //Set Network Usage


                    this.txtBoxNetworkUsage.Text = "";
                    this.txtBoxNetworkUsage.Text = "Total In: " + comp.SystemNIC.KBytesIn.ToString() + Environment.NewLine + "Total Out: " + comp.SystemNIC.KBytesOut.ToString() + Environment.NewLine + comp.SystemNIC.KBytesTotal.ToString();

                    //Set Volume Usage

                    this.txtBoxVolUsage.Text = "";
                    foreach (Volumes vol in comp.SystemVolumes.drives)
                    {
                        this.txtBoxVolUsage.Text += "Manufacturer:" + vol.Manufacturer + Environment.NewLine;
                        this.txtBoxVolUsage.Text += "Drive Letter:" + vol.driveLetter + Environment.NewLine;
                        this.txtBoxVolUsage.Text += "Drive Capacity:" + vol.driveCap + "GB" + Environment.NewLine;
                        this.txtBoxVolUsage.Text += "Free Space:" + vol.freeSpace + "GB" + Environment.NewLine;
                        this.txtBoxVolUsage.Text += "Usage:" + vol.volUsage + Environment.NewLine;
                    }
                }
            }
        }
예제 #2
0
        private void SetHardwareUsage(string[] usage)
        {
            if (this.lblCPUUsage.InvokeRequired)
            {
                SetHardwareUsageCallback d = new SetHardwareUsageCallback(SetHardwareUsage);
                this.Invoke(d, new object[] { usage });
            }
            else
            {
                if (usage[0] == "")
                {
                }
                else
                {
                    //Set CPU Usage Labels
                    string[] cpudetails = usage[0].Split('$'); //0 = Uptime: 1 = Utilisation: 2 = Threads: 3 = Processes
                    this.lblUptimeAns.Text = cpudetails[0];
                    this.lblCPUUsageAns.Text = cpudetails[1];
                    this.lblThreadsAns.Text = cpudetails[2];
                    this.lblProcessesAns.Text = cpudetails[3];

                    //Set RAM Usage Labels
                    string[] ramdetails = usage[1].Split('$');
                    this.lblTotalRAMAns.Text = ramdetails[0];
                    this.lblFreeRAMAns.Text = ramdetails[1];
                    this.lblInUseRAMAns.Text = ramdetails[2];

                    //Set Network Usage
                    string[] nicdetails = usage[3].Split('$');
                    this.txtBoxNetworkUsage.Text = "";
                    foreach (string nic in nicdetails)
                    {
                        this.txtBoxNetworkUsage.Text += nic + Environment.NewLine;
                    }

                    //Set Volume Usage

                    this.txtBoxVolUsage.Text = "";
                    string[] diskperf = usage[2].Split('$');
                    foreach (string disk in diskperf)
                    {
                        this.txtBoxVolUsage.Text += disk + Environment.NewLine;
                    }
                }
            }
            //this.lblCPUUsage.Text = usage[0];
        }