# HG changeset patch # User moel.mich # Date 1342028130 0 # Node ID c1a4377c11d1e84b29620ac2ad5fecc057552b48 # Parent 30bb76a1da249d373d32a2f220f4d8d830d747c5 Added the option to enable/disable all hardware groups. diff -r 30bb76a1da24 -r c1a4377c11d1 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Sun Jul 08 19:26:00 2012 +0000 +++ b/GUI/MainForm.Designer.cs Wed Jul 11 17:35:30 2012 +0000 @@ -51,6 +51,12 @@ this.sumbitReportMenuItem = new System.Windows.Forms.MenuItem(); this.MenuItem2 = new System.Windows.Forms.MenuItem(); this.resetMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.mainboardMenuItem = new System.Windows.Forms.MenuItem(); + this.cpuMenuItem = new System.Windows.Forms.MenuItem(); + this.gpuMenuItem = new System.Windows.Forms.MenuItem(); + this.fanControllerMenuItem = new System.Windows.Forms.MenuItem(); + this.hddMenuItem = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.exitMenuItem = new System.Windows.Forms.MenuItem(); this.viewMenuItem = new System.Windows.Forms.MenuItem(); @@ -73,9 +79,12 @@ this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem(); this.celsiusMenuItem = new System.Windows.Forms.MenuItem(); this.fahrenheitMenuItem = new System.Windows.Forms.MenuItem(); + this.plotLocationMenuItem = new System.Windows.Forms.MenuItem(); + this.plotWindowMenuItem = new System.Windows.Forms.MenuItem(); + this.plotBottomMenuItem = new System.Windows.Forms.MenuItem(); + this.plotRightMenuItem = new System.Windows.Forms.MenuItem(); this.MenuItem4 = new System.Windows.Forms.MenuItem(); - this.hddMenuItem = new System.Windows.Forms.MenuItem(); - this.webMenuItem = new System.Windows.Forms.MenuItem(); + this.webMenuItem = new System.Windows.Forms.MenuItem(); this.runWebServerMenuItem = new System.Windows.Forms.MenuItem(); this.serverPortMenuItem = new System.Windows.Forms.MenuItem(); this.helpMenuItem = new System.Windows.Forms.MenuItem(); @@ -84,13 +93,8 @@ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.timer = new System.Windows.Forms.Timer(this.components); this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv(); - this.treeView = new Aga.Controls.Tree.TreeViewAdv(); - this.plotLocationMenuItem = new System.Windows.Forms.MenuItem(); - this.plotWindowMenuItem = new System.Windows.Forms.MenuItem(); - this.plotBottomMenuItem = new System.Windows.Forms.MenuItem(); - this.plotRightMenuItem = new System.Windows.Forms.MenuItem(); + this.treeView = new Aga.Controls.Tree.TreeViewAdv(); this.splitContainer.Panel1.SuspendLayout(); - this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.SuspendLayout(); this.SuspendLayout(); // @@ -189,6 +193,7 @@ this.sumbitReportMenuItem, this.MenuItem2, this.resetMenuItem, + this.menuItem5, this.menuItem6, this.exitMenuItem}); this.fileMenuItem.Text = "File"; @@ -216,14 +221,50 @@ this.resetMenuItem.Text = "Reset"; this.resetMenuItem.Click += new System.EventHandler(this.resetClick); // + // menuItem5 + // + this.menuItem5.Index = 4; + this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.mainboardMenuItem, + this.cpuMenuItem, + this.gpuMenuItem, + this.fanControllerMenuItem, + this.hddMenuItem}); + this.menuItem5.Text = "Hardware"; + // + // mainboardMenuItem + // + this.mainboardMenuItem.Index = 0; + this.mainboardMenuItem.Text = "Mainboard"; + // + // cpuMenuItem + // + this.cpuMenuItem.Index = 1; + this.cpuMenuItem.Text = "CPU"; + // + // gpuMenuItem + // + this.gpuMenuItem.Index = 2; + this.gpuMenuItem.Text = "GPU"; + // + // fanControllerMenuItem + // + this.fanControllerMenuItem.Index = 3; + this.fanControllerMenuItem.Text = "Fan Controllers"; + // + // hddMenuItem + // + this.hddMenuItem.Index = 4; + this.hddMenuItem.Text = "Hard Disk Drives"; + // // menuItem6 // - this.menuItem6.Index = 4; + this.menuItem6.Index = 5; this.menuItem6.Text = "-"; // // exitMenuItem // - this.exitMenuItem.Index = 5; + this.exitMenuItem.Index = 6; this.exitMenuItem.Text = "Exit"; this.exitMenuItem.Click += new System.EventHandler(this.exitClick); // @@ -307,8 +348,7 @@ this.temperatureUnitsMenuItem, this.plotLocationMenuItem, this.MenuItem4, - this.hddMenuItem, - this.webMenuItem}); + this.webMenuItem}); this.optionsMenuItem.Text = "Options"; // // startMinMenuItem @@ -356,34 +396,53 @@ this.fahrenheitMenuItem.Text = "Fahrenheit"; this.fahrenheitMenuItem.Click += new System.EventHandler(this.fahrenheitMenuItem_Click); // + // plotLocationMenuItem + // + this.plotLocationMenuItem.Index = 6; + this.plotLocationMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.plotWindowMenuItem, + this.plotBottomMenuItem, + this.plotRightMenuItem}); + this.plotLocationMenuItem.Text = "Plot Location"; + // + // plotWindowMenuItem + // + this.plotWindowMenuItem.Index = 0; + this.plotWindowMenuItem.Text = "Window"; + // + // plotBottomMenuItem + // + this.plotBottomMenuItem.Index = 1; + this.plotBottomMenuItem.Text = "Bottom"; + // + // plotRightMenuItem + // + this.plotRightMenuItem.Index = 2; + this.plotRightMenuItem.Text = "Right"; + // // MenuItem4 // this.MenuItem4.Index = 7; this.MenuItem4.Text = "-"; // - // hddMenuItem + // webMenuItem // - this.hddMenuItem.Index = 8; - this.hddMenuItem.Text = "Read HDD sensors"; - // - // webMenuItem - // - this.webMenuItem.Index = 9; - this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.runWebServerMenuItem, - this.serverPortMenuItem}); - this.webMenuItem.Text = "Remote Web Server"; + this.webMenuItem.Index = 8; + this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.runWebServerMenuItem, + this.serverPortMenuItem}); + this.webMenuItem.Text = "Remote Web Server"; // // runWebServerMenuItem // this.runWebServerMenuItem.Index = 0; this.runWebServerMenuItem.Text = "Run"; - // - // serverPortMenuItem - // - this.serverPortMenuItem.Index = 1; - this.serverPortMenuItem.Text = "Port"; - this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click); + // + // serverPortMenuItem + // + this.serverPortMenuItem.Index = 1; + this.serverPortMenuItem.Text = "Port"; + this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click); // // helpMenuItem // @@ -466,30 +525,6 @@ this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove); this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp); // - // plotLocationMenuItem - // - this.plotLocationMenuItem.Index = 6; - this.plotLocationMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.plotWindowMenuItem, - this.plotBottomMenuItem, - this.plotRightMenuItem}); - this.plotLocationMenuItem.Text = "Plot Location"; - // - // plotWindowMenuItem - // - this.plotWindowMenuItem.Index = 0; - this.plotWindowMenuItem.Text = "Window"; - // - // plotBottomMenuItem - // - this.plotBottomMenuItem.Index = 1; - this.plotBottomMenuItem.Text = "Bottom"; - // - // plotRightMenuItem - // - this.plotRightMenuItem.Index = 2; - this.plotRightMenuItem.Text = "Right"; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -506,7 +541,6 @@ this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize); this.Move += new System.EventHandler(this.MainForm_MoveOrResize); this.splitContainer.Panel1.ResumeLayout(false); - this.splitContainer.Panel2.ResumeLayout(false); this.splitContainer.ResumeLayout(false); this.ResumeLayout(false); @@ -568,6 +602,11 @@ private System.Windows.Forms.MenuItem webMenuItem; private System.Windows.Forms.MenuItem runWebServerMenuItem; private System.Windows.Forms.MenuItem serverPortMenuItem; + private System.Windows.Forms.MenuItem menuItem5; + private System.Windows.Forms.MenuItem mainboardMenuItem; + private System.Windows.Forms.MenuItem cpuMenuItem; + private System.Windows.Forms.MenuItem gpuMenuItem; + private System.Windows.Forms.MenuItem fanControllerMenuItem; } } diff -r 30bb76a1da24 -r c1a4377c11d1 GUI/MainForm.cs --- a/GUI/MainForm.cs Sun Jul 08 19:26:00 2012 +0000 +++ b/GUI/MainForm.cs Wed Jul 11 17:35:30 2012 +0000 @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.IO; @@ -50,7 +51,13 @@ private UserOption minimizeToTray; private UserOption minimizeOnClose; private UserOption autoStart; + + private UserOption readMainboardSensors; + private UserOption readCpuSensors; + private UserOption readGpuSensors; + private UserOption readFanControllersSensors; private UserOption readHddSensors; + private UserOption showGadget; private UserRadioGroup plotLocation; private WmiProvider wmiProvider; @@ -207,6 +214,30 @@ } }; + readMainboardSensors = new UserOption("mainboardMenuItem", true, + mainboardMenuItem, settings); + readMainboardSensors.Changed += delegate(object sender, EventArgs e) { + computer.MainboardEnabled = readMainboardSensors.Value; + }; + + readCpuSensors = new UserOption("cpuMenuItem", true, + cpuMenuItem, settings); + readCpuSensors.Changed += delegate(object sender, EventArgs e) { + computer.CPUEnabled = readCpuSensors.Value; + }; + + readGpuSensors = new UserOption("gpuMenuItem", true, + gpuMenuItem, settings); + readGpuSensors.Changed += delegate(object sender, EventArgs e) { + computer.GPUEnabled = readGpuSensors.Value; + }; + + readFanControllersSensors = new UserOption("fanControllerMenuItem", true, + fanControllerMenuItem, settings); + readFanControllersSensors.Changed += delegate(object sender, EventArgs e) { + computer.FanControllerEnabled = readFanControllersSensors.Value; + }; + readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, settings); readHddSensors.Changed += delegate(object sender, EventArgs e) { @@ -227,15 +258,13 @@ server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085)); runWebServer = new UserOption("runWebServerMenuItem", false, runWebServerMenuItem, settings); - runWebServer.Changed += delegate(object sender, EventArgs e) - { - if (runWebServer.Value) - runWebServer.Value = server.startHTTPListener(); - else - server.stopHTTPListener(); + runWebServer.Changed += delegate(object sender, EventArgs e) { + if (runWebServer.Value) + runWebServer.Value = server.startHTTPListener(); + else + server.stopHTTPListener(); }; - InitializePlotForm(); startupMenuItem.Visible = startupManager.IsAvailable; @@ -357,13 +386,23 @@ plotForm.Hide(); }; } + + private void InsertSorted(Collection nodes, HardwareNode node) { + int i = 0; + while (i < nodes.Count && nodes[i] is HardwareNode && + ((HardwareNode)nodes[i]).Hardware.HardwareType < + node.Hardware.HardwareType) + i++; + nodes.Insert(i, node); + } private void SubHardwareAdded(IHardware hardware, Node node) { HardwareNode hardwareNode = new HardwareNode(hardware, settings, unitManager); hardwareNode.PlotSelectionChanged += PlotSelectionChanged; - node.Nodes.Add(hardwareNode); + InsertSorted(node.Nodes, hardwareNode); + foreach (IHardware subHardware in hardware.SubHardware) SubHardwareAdded(subHardware, hardwareNode); } diff -r 30bb76a1da24 -r c1a4377c11d1 Hardware/Computer.cs --- a/Hardware/Computer.cs Sun Jul 08 19:26:00 2012 +0000 +++ b/Hardware/Computer.cs Wed Jul 11 17:35:30 2012 +0000 @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2011 Michael Möller + Copyright (C) 2009-2012 Michael Möller */ @@ -23,7 +23,12 @@ private readonly ISettings settings; private bool open; - private bool hddEnabled; + + private bool mainboardEnabled; + private bool cpuEnabled; + private bool gpuEnabled; + private bool fanControllerEnabled; + private bool hddEnabled; public Computer() { this.settings = new Settings(); @@ -53,6 +58,17 @@ if (HardwareRemoved != null) foreach (IHardware hardware in group.Hardware) HardwareRemoved(hardware); + + group.Close(); + } + + private void RemoveType() where T : IGroup { + List list = new List(); + foreach (IGroup group in groups) + if (group is T) + list.Add(group); + foreach (IGroup group in list) + Remove(group); } [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] @@ -63,33 +79,104 @@ Ring0.Open(); Opcode.Open(); - Add(new Mainboard.MainboardGroup(settings)); - Add(new CPU.CPUGroup(settings)); - Add(new ATI.ATIGroup(settings)); - Add(new Nvidia.NvidiaGroup(settings)); - Add(new TBalancer.TBalancerGroup(settings)); - Add(new Heatmaster.HeatmasterGroup(settings)); + if (mainboardEnabled) + Add(new Mainboard.MainboardGroup(settings)); + + if (cpuEnabled) + Add(new CPU.CPUGroup(settings)); + + if (gpuEnabled) { + Add(new ATI.ATIGroup(settings)); + Add(new Nvidia.NvidiaGroup(settings)); + } + + if (fanControllerEnabled) { + Add(new TBalancer.TBalancerGroup(settings)); + Add(new Heatmaster.HeatmasterGroup(settings)); + } if (hddEnabled) Add(new HDD.HarddriveGroup(settings)); open = true; } - + + public bool MainboardEnabled { + get { return mainboardEnabled; } + + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] + set { + if (open && value != mainboardEnabled) { + if (value) + Add(new Mainboard.MainboardGroup(settings)); + else + RemoveType(); + } + mainboardEnabled = value; + } + } + + public bool CPUEnabled { + get { return cpuEnabled; } + + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] + set { + if (open && value != cpuEnabled) { + if (value) + Add(new CPU.CPUGroup(settings)); + else + RemoveType(); + } + cpuEnabled = value; + } + } + + public bool GPUEnabled { + get { return gpuEnabled; } + + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] + set { + if (open && value != gpuEnabled) { + if (value) { + Add(new ATI.ATIGroup(settings)); + Add(new Nvidia.NvidiaGroup(settings)); + } else { + RemoveType(); + RemoveType(); + } + } + gpuEnabled = value; + } + } + + public bool FanControllerEnabled { + get { return fanControllerEnabled; } + + [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] + set { + if (open && value != fanControllerEnabled) { + if (value) { + Add(new TBalancer.TBalancerGroup(settings)); + Add(new Heatmaster.HeatmasterGroup(settings)); + } else { + RemoveType(); + RemoveType(); + } + } + fanControllerEnabled = value; + } + } + public bool HDDEnabled { get { return hddEnabled; } [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] set { - if (open && value && !hddEnabled) { - Add(new HDD.HarddriveGroup(settings)); - } else if (open && !value && hddEnabled) { - List list = new List(); - foreach (IGroup group in groups) - if (group is HDD.HarddriveGroup) - list.Add(group); - foreach (IGroup group in list) - Remove(group); + if (open && value != hddEnabled) { + if (value) + Add(new HDD.HarddriveGroup(settings)); + else + RemoveType(); } hddEnabled = value; } @@ -243,8 +330,7 @@ while (groups.Count > 0) { IGroup group = groups[groups.Count - 1]; - Remove(group); - group.Close(); + Remove(group); } Opcode.Close(); diff -r 30bb76a1da24 -r c1a4377c11d1 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sun Jul 08 19:26:00 2012 +0000 +++ b/Properties/AssemblyVersion.cs Wed Jul 11 17:35:30 2012 +0000 @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.4.0.14")] -[assembly: AssemblyInformationalVersion("0.4.0.14 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.4.0.16")] +[assembly: AssemblyInformationalVersion("0.4.0.16 Alpha")] \ No newline at end of file