Exemple #1
0
 public ComputerHardware()
 {
     settings    = new OpenHardwareMonitor.PersistentSettings();
     unitManager = new OpenHardwareMonitor.GUI.UnitManager(settings);
     treeModel   = new OpenHardwareMonitor.GUI.TreeModel();
     root        = new OpenHardwareMonitor.GUI.Node(System.Environment.MachineName);
     root.Image  = OpenHardwareMonitor.Utilities.EmbeddedResources.GetImage("computer.png");
     treeModel.Nodes.Add(root);
     treeModel.ForceVisible = true;
 }
Exemple #2
0
        public LightCPUMonitorAppContext()
        {
            for (int i = 0; i < 4; i++)
            {
                NotifyIcon notifyIcon     = new NotifyIcon();
                MenuItem   configMenuItem = new MenuItem("Configuration", new EventHandler(ShowConfig));
                MenuItem   exitMenuItem   = new MenuItem("Exit", new EventHandler(Exit));
                notifyIcon.ContextMenu = new ContextMenu(new MenuItem[]
                                                         { configMenuItem, exitMenuItem });
                notifyIcon.Visible = true;
                icons.Add(notifyIcon);
            }

            this.settings = new OpenHardwareMonitor.PersistentSettings();
            this.settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));
            settings.SetValue("CPUEnabled", true);
            this.computer       = new Computer(settings);
            computer.CPUEnabled = true;
            computer.Open();
            IList <ISensor> list;

            if (!sensors.TryGetValue(computer.Hardware[0], out list))
            {
                list = new List <ISensor>();
                sensors.Add(computer.Hardware[0], list);
            }

            // insert the sensor at the right position
            foreach (var sensor in computer.Hardware[0].Sensors)
            {
                int i = 0;
                while (i < list.Count && (list[i].SensorType < sensor.SensorType ||
                                          (list[i].SensorType == sensor.SensorType &&
                                           list[i].Index < sensor.Index)))
                {
                    i++;
                }
                list.Insert(i, sensor);
            }
            g          = System.Drawing.Graphics.FromImage(bitmapText);
            g.PageUnit = GraphicsUnit.Pixel;
            UpdateSensorIndexes();
            //notifyIcon.Icon = CPUSpeed.Properties.Resources.AppIcon;

            updateTimer = new System.Threading.Timer(new TimerCallback(UpdateValue));
            updateTimer.Change(DELAY_TIME, UPDATE_TIME);
        }