Added the option to enable/disable all hardware groups.

This commit is contained in:
Michael Möller
2012-07-11 17:35:30 +00:00
parent 04be3e3943
commit 028248273b
4 changed files with 248 additions and 84 deletions

119
GUI/MainForm.Designer.cs generated
View File

@@ -51,6 +51,12 @@ namespace OpenHardwareMonitor.GUI {
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,8 +79,11 @@ namespace OpenHardwareMonitor.GUI {
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.runWebServerMenuItem = new System.Windows.Forms.MenuItem();
this.serverPortMenuItem = new System.Windows.Forms.MenuItem();
@@ -85,12 +94,7 @@ namespace OpenHardwareMonitor.GUI {
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.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
@@ -189,6 +193,7 @@ namespace OpenHardwareMonitor.GUI {
this.sumbitReportMenuItem,
this.MenuItem2,
this.resetMenuItem,
this.menuItem5,
this.menuItem6,
this.exitMenuItem});
this.fileMenuItem.Text = "File";
@@ -216,14 +221,50 @@ namespace OpenHardwareMonitor.GUI {
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,7 +348,6 @@ namespace OpenHardwareMonitor.GUI {
this.temperatureUnitsMenuItem,
this.plotLocationMenuItem,
this.MenuItem4,
this.hddMenuItem,
this.webMenuItem});
this.optionsMenuItem.Text = "Options";
//
@@ -356,19 +396,38 @@ namespace OpenHardwareMonitor.GUI {
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
//
this.hddMenuItem.Index = 8;
this.hddMenuItem.Text = "Read HDD sensors";
//
// webMenuItem
//
this.webMenuItem.Index = 9;
this.webMenuItem.Index = 8;
this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.runWebServerMenuItem,
this.serverPortMenuItem});
@@ -466,30 +525,6 @@ namespace OpenHardwareMonitor.GUI {
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 @@ namespace OpenHardwareMonitor.GUI {
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 @@ namespace OpenHardwareMonitor.GUI {
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;
}
}

View File

@@ -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 @@ namespace OpenHardwareMonitor.GUI {
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 @@ namespace OpenHardwareMonitor.GUI {
}
};
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 @@ namespace OpenHardwareMonitor.GUI {
server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085));
runWebServer = new UserOption("runWebServerMenuItem", false,
runWebServerMenuItem, settings);
runWebServer.Changed += delegate(object sender, EventArgs e)
{
runWebServer.Changed += delegate(object sender, EventArgs e) {
if (runWebServer.Value)
runWebServer.Value = server.startHTTPListener();
else
server.stopHTTPListener();
};
InitializePlotForm();
startupMenuItem.Visible = startupManager.IsAvailable;
@@ -358,12 +387,22 @@ namespace OpenHardwareMonitor.GUI {
};
}
private void InsertSorted(Collection<Node> 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);
}

View File

@@ -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 <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
*/
@@ -23,6 +23,11 @@ namespace OpenHardwareMonitor.Hardware {
private readonly ISettings settings;
private bool open;
private bool mainboardEnabled;
private bool cpuEnabled;
private bool gpuEnabled;
private bool fanControllerEnabled;
private bool hddEnabled;
public Computer() {
@@ -53,6 +58,17 @@ namespace OpenHardwareMonitor.Hardware {
if (HardwareRemoved != null)
foreach (IHardware hardware in group.Hardware)
HardwareRemoved(hardware);
group.Close();
}
private void RemoveType<T>() where T : IGroup {
List<IGroup> list = new List<IGroup>();
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,12 +79,21 @@ namespace OpenHardwareMonitor.Hardware {
Ring0.Open();
Opcode.Open();
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));
@@ -76,20 +101,82 @@ namespace OpenHardwareMonitor.Hardware {
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<Mainboard.MainboardGroup>();
}
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<CPU.CPUGroup>();
}
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<ATI.ATIGroup>();
RemoveType<Nvidia.NvidiaGroup>();
}
}
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<TBalancer.TBalancerGroup>();
RemoveType<Heatmaster.HeatmasterGroup>();
}
}
fanControllerEnabled = value;
}
}
public bool HDDEnabled {
get { return hddEnabled; }
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
set {
if (open && value && !hddEnabled) {
if (open && value != hddEnabled) {
if (value)
Add(new HDD.HarddriveGroup(settings));
} else if (open && !value && hddEnabled) {
List<IGroup> list = new List<IGroup>();
foreach (IGroup group in groups)
if (group is HDD.HarddriveGroup)
list.Add(group);
foreach (IGroup group in list)
Remove(group);
else
RemoveType<HDD.HarddriveGroup>();
}
hddEnabled = value;
}
@@ -244,7 +331,6 @@ namespace OpenHardwareMonitor.Hardware {
while (groups.Count > 0) {
IGroup group = groups[groups.Count - 1];
Remove(group);
group.Close();
}
Opcode.Close();

View File

@@ -10,5 +10,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.4.0.14")]
[assembly: AssemblyInformationalVersion("0.4.0.14 Alpha")]
[assembly: AssemblyVersion("0.4.0.16")]
[assembly: AssemblyInformationalVersion("0.4.0.16 Alpha")]