Пример #1
0
 public Form1()
 {
     InitializeComponent();
     INFO             = new info();
     setinfo          = new SetINFO();
     setinfo.ShowINFO = 0;//默认简易
     setinfo.satus    = 1;
     //调用INFO线程后台刷新数据
     INFOThread = new Thread(() => INFO.Main(setinfo));
     INFOThread.Start();
 }
Пример #2
0
        public void Main(SetINFO setinfo)
        {
            Sinit();
            while (true)
            {
                Thread.Sleep(50);

                /*
                 * Console.WriteLine(setinfo.ShowINFO);
                 * Console.WriteLine(setinfo.satus);
                 * Console.WriteLine(source.num);
                 * Console.WriteLine(SysInfo);
                 */
                InfoShow(setinfo);
                if (setinfo.satus == 0)
                {
                    computer.Close();
                    break;
                }
            }
        }
Пример #3
0
        public void InfoShow(SetINFO setinfo)
        {
            updateVisitor = new UpdateVisitor();
            computer      = new Computer();
            computer.Open();
            computer.CPUEnabled = true;
            computer.GPUEnabled = true;
            computer.HDDEnabled = true;
            computer.RAMEnabled = true;
            computer.Accept(updateVisitor);
            if (setinfo.ShowINFO == 0)
            {
                string tempsstr = "";
                string cputemp  = "";
                string cpuload  = "";
                string cpuclock = "";
                if (source.CPU && cpuinfo.Load)
                {
                    cpuload += "CPU使用率 " + computer.Hardware[source.CPUindex].Sensors[cpuinfo.LoadSensorNum - 1].Value.ToString() + "%\n";
                }
                tempsstr += cpuload;
                if (source.CPU && cpuinfo.Tem)
                {
                    cputemp += "CPU_Temp:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.TemSensorNum - 1].Value.ToString() + "\n";
                }
                tempsstr += cputemp;
                if (source.CPU && cpuinfo.Clock)
                {
                    double clock = 0.0;
                    for (int i = 0; i < cpuinfo.ClockSensorNum; i++)
                    {
                        clock += (double)computer.Hardware[source.CPUindex].Sensors[cpuinfo.ClockSensorindex + i].Value;
                    }
                    clock     = clock / cpuinfo.ClockSensorNum;
                    cpuclock += "CPU" + "_Clock:" + clock.ToString() + "MHz\n";
                }
                tempsstr += cpuclock;
                SysInfo   = tempsstr;
            }
            else
            {
                string tempsstr = "";
                string cputemp  = "";
                string cpuload  = "";
                string cpuclock = "";
                if (source.CPU && cpuinfo.Load)
                {
                    for (int i = 0; i < cpuinfo.LoadSensorNum; i++)
                    {
                        if (i < cpuinfo.LoadSensorNum - 1)
                        {
                            cpuload += "CPU" + "#" + i.ToString() + "_Load:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.LoadSensorindex + i].Value.ToString() + "%\n";
                        }
                        else
                        {
                            cpuload += "CPU" + "Total" + "_Load:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.LoadSensorindex + i].Value.ToString() + "%\n";
                        }
                    }
                }
                tempsstr += cpuload;

                /*
                 * if (source.CPU && cpuinfo.Tem)
                 * {
                 *  for (int i = 0; i < cpuinfo.TemSensorNum; i++)
                 *  {
                 *      if (i < cpuinfo.TemSensorNum - 1)
                 *      {
                 *          cputemp += "CPU" + "#" + i.ToString() + "_Temp:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.TemSensorindex + i].Value.ToString() + "\n";
                 *      }
                 *      else
                 *      {
                 *          cputemp += "CPU" + "Total"+ "_Temp:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.TemSensorindex + i].Value.ToString() + "\n";
                 *      }
                 *  }
                 * }
                 * tempsstr += cputemp;
                 * if (source.CPU && cpuinfo.Clock)
                 * {
                 *  for (int i = 0; i < cpuinfo.ClockSensorNum; i++)
                 *  {
                 *      if (i < cpuinfo.ClockSensorNum - 1)
                 *      {
                 *          cpuclock += "CPU" + "#" + i.ToString() + "_Clock:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.ClockSensorindex + i].Value.ToString() + "MHz\n";
                 *      }
                 *      else
                 *      {
                 *          cpuclock += "CPU" + "Total"+ "_Clock:" + computer.Hardware[source.CPUindex].Sensors[cpuinfo.ClockSensorindex + i].Value.ToString() + "MHz\n";
                 *      }
                 *  }
                 * }
                 * tempsstr += cpuclock;*/
                SysInfo = tempsstr;
            }
        }