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

147
GUI/MainForm.Designer.cs generated
View File

@@ -51,6 +51,12 @@ namespace OpenHardwareMonitor.GUI {
this.sumbitReportMenuItem = new System.Windows.Forms.MenuItem(); this.sumbitReportMenuItem = new System.Windows.Forms.MenuItem();
this.MenuItem2 = new System.Windows.Forms.MenuItem(); this.MenuItem2 = new System.Windows.Forms.MenuItem();
this.resetMenuItem = 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.menuItem6 = new System.Windows.Forms.MenuItem();
this.exitMenuItem = new System.Windows.Forms.MenuItem(); this.exitMenuItem = new System.Windows.Forms.MenuItem();
this.viewMenuItem = new System.Windows.Forms.MenuItem(); this.viewMenuItem = new System.Windows.Forms.MenuItem();
@@ -73,9 +79,12 @@ namespace OpenHardwareMonitor.GUI {
this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem(); this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem();
this.celsiusMenuItem = new System.Windows.Forms.MenuItem(); this.celsiusMenuItem = new System.Windows.Forms.MenuItem();
this.fahrenheitMenuItem = 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.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.runWebServerMenuItem = new System.Windows.Forms.MenuItem();
this.serverPortMenuItem = new System.Windows.Forms.MenuItem(); this.serverPortMenuItem = new System.Windows.Forms.MenuItem();
this.helpMenuItem = new System.Windows.Forms.MenuItem(); this.helpMenuItem = new System.Windows.Forms.MenuItem();
@@ -84,13 +93,8 @@ namespace OpenHardwareMonitor.GUI {
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.timer = new System.Windows.Forms.Timer(this.components); this.timer = new System.Windows.Forms.Timer(this.components);
this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv(); this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
this.treeView = new Aga.Controls.Tree.TreeViewAdv(); 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.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout(); this.splitContainer.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -189,6 +193,7 @@ namespace OpenHardwareMonitor.GUI {
this.sumbitReportMenuItem, this.sumbitReportMenuItem,
this.MenuItem2, this.MenuItem2,
this.resetMenuItem, this.resetMenuItem,
this.menuItem5,
this.menuItem6, this.menuItem6,
this.exitMenuItem}); this.exitMenuItem});
this.fileMenuItem.Text = "File"; this.fileMenuItem.Text = "File";
@@ -216,14 +221,50 @@ namespace OpenHardwareMonitor.GUI {
this.resetMenuItem.Text = "Reset"; this.resetMenuItem.Text = "Reset";
this.resetMenuItem.Click += new System.EventHandler(this.resetClick); 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 // menuItem6
// //
this.menuItem6.Index = 4; this.menuItem6.Index = 5;
this.menuItem6.Text = "-"; this.menuItem6.Text = "-";
// //
// exitMenuItem // exitMenuItem
// //
this.exitMenuItem.Index = 5; this.exitMenuItem.Index = 6;
this.exitMenuItem.Text = "Exit"; this.exitMenuItem.Text = "Exit";
this.exitMenuItem.Click += new System.EventHandler(this.exitClick); this.exitMenuItem.Click += new System.EventHandler(this.exitClick);
// //
@@ -307,8 +348,7 @@ namespace OpenHardwareMonitor.GUI {
this.temperatureUnitsMenuItem, this.temperatureUnitsMenuItem,
this.plotLocationMenuItem, this.plotLocationMenuItem,
this.MenuItem4, this.MenuItem4,
this.hddMenuItem, this.webMenuItem});
this.webMenuItem});
this.optionsMenuItem.Text = "Options"; this.optionsMenuItem.Text = "Options";
// //
// startMinMenuItem // startMinMenuItem
@@ -356,34 +396,53 @@ namespace OpenHardwareMonitor.GUI {
this.fahrenheitMenuItem.Text = "Fahrenheit"; this.fahrenheitMenuItem.Text = "Fahrenheit";
this.fahrenheitMenuItem.Click += new System.EventHandler(this.fahrenheitMenuItem_Click); 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 // MenuItem4
// //
this.MenuItem4.Index = 7; this.MenuItem4.Index = 7;
this.MenuItem4.Text = "-"; this.MenuItem4.Text = "-";
// //
// hddMenuItem // webMenuItem
// //
this.hddMenuItem.Index = 8; this.webMenuItem.Index = 8;
this.hddMenuItem.Text = "Read HDD sensors"; this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
// this.runWebServerMenuItem,
// webMenuItem this.serverPortMenuItem});
// this.webMenuItem.Text = "Remote Web Server";
this.webMenuItem.Index = 9;
this.webMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.runWebServerMenuItem,
this.serverPortMenuItem});
this.webMenuItem.Text = "Remote Web Server";
// //
// runWebServerMenuItem // runWebServerMenuItem
// //
this.runWebServerMenuItem.Index = 0; this.runWebServerMenuItem.Index = 0;
this.runWebServerMenuItem.Text = "Run"; this.runWebServerMenuItem.Text = "Run";
// //
// serverPortMenuItem // serverPortMenuItem
// //
this.serverPortMenuItem.Index = 1; this.serverPortMenuItem.Index = 1;
this.serverPortMenuItem.Text = "Port"; this.serverPortMenuItem.Text = "Port";
this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click); this.serverPortMenuItem.Click += new System.EventHandler(this.serverPortMenuItem_Click);
// //
// helpMenuItem // helpMenuItem
// //
@@ -466,30 +525,6 @@ namespace OpenHardwareMonitor.GUI {
this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove); this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove);
this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp); 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 // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -506,7 +541,6 @@ namespace OpenHardwareMonitor.GUI {
this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize); this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize);
this.Move += new System.EventHandler(this.MainForm_MoveOrResize); this.Move += new System.EventHandler(this.MainForm_MoveOrResize);
this.splitContainer.Panel1.ResumeLayout(false); this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false); this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@@ -568,6 +602,11 @@ namespace OpenHardwareMonitor.GUI {
private System.Windows.Forms.MenuItem webMenuItem; private System.Windows.Forms.MenuItem webMenuItem;
private System.Windows.Forms.MenuItem runWebServerMenuItem; private System.Windows.Forms.MenuItem runWebServerMenuItem;
private System.Windows.Forms.MenuItem serverPortMenuItem; 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
@@ -50,7 +51,13 @@ namespace OpenHardwareMonitor.GUI {
private UserOption minimizeToTray; private UserOption minimizeToTray;
private UserOption minimizeOnClose; private UserOption minimizeOnClose;
private UserOption autoStart; private UserOption autoStart;
private UserOption readMainboardSensors;
private UserOption readCpuSensors;
private UserOption readGpuSensors;
private UserOption readFanControllersSensors;
private UserOption readHddSensors; private UserOption readHddSensors;
private UserOption showGadget; private UserOption showGadget;
private UserRadioGroup plotLocation; private UserRadioGroup plotLocation;
private WmiProvider wmiProvider; 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, readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem,
settings); settings);
readHddSensors.Changed += delegate(object sender, EventArgs e) { readHddSensors.Changed += delegate(object sender, EventArgs e) {
@@ -227,15 +258,13 @@ namespace OpenHardwareMonitor.GUI {
server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085)); server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085));
runWebServer = new UserOption("runWebServerMenuItem", false, runWebServer = new UserOption("runWebServerMenuItem", false,
runWebServerMenuItem, settings); runWebServerMenuItem, settings);
runWebServer.Changed += delegate(object sender, EventArgs e) runWebServer.Changed += delegate(object sender, EventArgs e) {
{ if (runWebServer.Value)
if (runWebServer.Value) runWebServer.Value = server.startHTTPListener();
runWebServer.Value = server.startHTTPListener(); else
else server.stopHTTPListener();
server.stopHTTPListener();
}; };
InitializePlotForm(); InitializePlotForm();
startupMenuItem.Visible = startupManager.IsAvailable; startupMenuItem.Visible = startupManager.IsAvailable;
@@ -357,13 +386,23 @@ namespace OpenHardwareMonitor.GUI {
plotForm.Hide(); plotForm.Hide();
}; };
} }
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) { private void SubHardwareAdded(IHardware hardware, Node node) {
HardwareNode hardwareNode = HardwareNode hardwareNode =
new HardwareNode(hardware, settings, unitManager); new HardwareNode(hardware, settings, unitManager);
hardwareNode.PlotSelectionChanged += PlotSelectionChanged; hardwareNode.PlotSelectionChanged += PlotSelectionChanged;
node.Nodes.Add(hardwareNode); InsertSorted(node.Nodes, hardwareNode);
foreach (IHardware subHardware in hardware.SubHardware) foreach (IHardware subHardware in hardware.SubHardware)
SubHardwareAdded(subHardware, hardwareNode); SubHardwareAdded(subHardware, hardwareNode);
} }

View File

@@ -4,7 +4,7 @@
License, v. 2.0. If a copy of the MPL was not distributed with this 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/. 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,7 +23,12 @@ namespace OpenHardwareMonitor.Hardware {
private readonly ISettings settings; private readonly ISettings settings;
private bool open; private bool open;
private bool hddEnabled;
private bool mainboardEnabled;
private bool cpuEnabled;
private bool gpuEnabled;
private bool fanControllerEnabled;
private bool hddEnabled;
public Computer() { public Computer() {
this.settings = new Settings(); this.settings = new Settings();
@@ -53,6 +58,17 @@ namespace OpenHardwareMonitor.Hardware {
if (HardwareRemoved != null) if (HardwareRemoved != null)
foreach (IHardware hardware in group.Hardware) foreach (IHardware hardware in group.Hardware)
HardwareRemoved(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)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
@@ -63,33 +79,104 @@ namespace OpenHardwareMonitor.Hardware {
Ring0.Open(); Ring0.Open();
Opcode.Open(); Opcode.Open();
Add(new Mainboard.MainboardGroup(settings)); if (mainboardEnabled)
Add(new CPU.CPUGroup(settings)); Add(new Mainboard.MainboardGroup(settings));
Add(new ATI.ATIGroup(settings));
Add(new Nvidia.NvidiaGroup(settings)); if (cpuEnabled)
Add(new TBalancer.TBalancerGroup(settings)); Add(new CPU.CPUGroup(settings));
Add(new Heatmaster.HeatmasterGroup(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) if (hddEnabled)
Add(new HDD.HarddriveGroup(settings)); Add(new HDD.HarddriveGroup(settings));
open = true; 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 { public bool HDDEnabled {
get { return hddEnabled; } get { return hddEnabled; }
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
set { set {
if (open && value && !hddEnabled) { if (open && value != hddEnabled) {
Add(new HDD.HarddriveGroup(settings)); if (value)
} else if (open && !value && hddEnabled) { Add(new HDD.HarddriveGroup(settings));
List<IGroup> list = new List<IGroup>(); else
foreach (IGroup group in groups) RemoveType<HDD.HarddriveGroup>();
if (group is HDD.HarddriveGroup)
list.Add(group);
foreach (IGroup group in list)
Remove(group);
} }
hddEnabled = value; hddEnabled = value;
} }
@@ -243,8 +330,7 @@ namespace OpenHardwareMonitor.Hardware {
while (groups.Count > 0) { while (groups.Count > 0) {
IGroup group = groups[groups.Count - 1]; IGroup group = groups[groups.Count - 1];
Remove(group); Remove(group);
group.Close();
} }
Opcode.Close(); Opcode.Close();

View File

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