Added a user interface to configure certain sensors as hidden. This fixed Issue 53.
This commit is contained in:
+19
-21
@@ -38,7 +38,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Aga.Controls.Tree;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
@@ -71,16 +70,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
get { return hardware; }
|
||||
}
|
||||
|
||||
public void SetVisible(SensorType sensorType, bool visible) {
|
||||
foreach (TypeNode node in typeNodes)
|
||||
if (node.SensorType == sensorType) {
|
||||
node.IsVisible = visible;
|
||||
UpdateNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNode(TypeNode node) {
|
||||
if (node.IsVisible && node.Nodes.Count > 0) {
|
||||
private void UpdateNode(TypeNode node) {
|
||||
if (node.Nodes.Count > 0) {
|
||||
if (!Nodes.Contains(node)) {
|
||||
int i = 0;
|
||||
while (i < Nodes.Count &&
|
||||
@@ -95,10 +86,16 @@ namespace OpenHardwareMonitor.GUI {
|
||||
}
|
||||
|
||||
private void SensorRemoved(ISensor sensor) {
|
||||
foreach (TypeNode node in typeNodes)
|
||||
if (node.SensorType == sensor.SensorType) {
|
||||
node.Nodes.Remove(new SensorNode(sensor));
|
||||
UpdateNode(node);
|
||||
foreach (TypeNode typeNode in typeNodes)
|
||||
if (typeNode.SensorType == sensor.SensorType) {
|
||||
SensorNode sensorNode = null;
|
||||
foreach (Node node in typeNode.Nodes) {
|
||||
SensorNode n = node as SensorNode;
|
||||
if (n != null && n.Sensor == sensor)
|
||||
sensorNode = n;
|
||||
}
|
||||
typeNode.Nodes.Remove(sensorNode);
|
||||
UpdateNode(typeNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,15 +104,16 @@ namespace OpenHardwareMonitor.GUI {
|
||||
while (i < node.Nodes.Count &&
|
||||
((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
|
||||
i++;
|
||||
node.Nodes.Insert(i, new SensorNode(sensor));
|
||||
SensorNode sensorNode = new SensorNode(sensor);
|
||||
node.Nodes.Insert(i, sensorNode);
|
||||
}
|
||||
|
||||
private void SensorAdded(ISensor sensor) {
|
||||
foreach (TypeNode node in typeNodes)
|
||||
if (node.SensorType == sensor.SensorType) {
|
||||
InsertSorted(node, sensor);
|
||||
UpdateNode(node);
|
||||
foreach (TypeNode typeNode in typeNodes)
|
||||
if (typeNode.SensorType == sensor.SensorType) {
|
||||
InsertSorted(typeNode, sensor);
|
||||
UpdateNode(typeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+81
-158
@@ -75,25 +75,19 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.nodeTextBoxMin = new Aga.Controls.Tree.NodeControls.NodeTextBox();
|
||||
this.nodeTextBoxMax = new Aga.Controls.Tree.NodeControls.NodeTextBox();
|
||||
this.nodeTextBoxLimit = new Aga.Controls.Tree.NodeControls.NodeTextBox();
|
||||
this.columnsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.valueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.minMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.maxMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.limitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sensorsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.voltMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clocksMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tempMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fansMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.flowsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.hiddenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.columnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.valueMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.minMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.maxMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.limitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.startMinMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -111,7 +105,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.timer = new System.Windows.Forms.Timer(this.components);
|
||||
this.columnsContextMenuStrip.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
@@ -239,56 +232,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.nodeTextBoxLimit.LeftMargin = 3;
|
||||
this.nodeTextBoxLimit.ParentColumn = this.limit;
|
||||
//
|
||||
// columnsContextMenuStrip
|
||||
//
|
||||
this.columnsContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.valueToolStripMenuItem,
|
||||
this.minMenuItem,
|
||||
this.maxMenuItem,
|
||||
this.limitMenuItem});
|
||||
this.columnsContextMenuStrip.Name = "columnsContextMenuStrip";
|
||||
this.columnsContextMenuStrip.Size = new System.Drawing.Size(104, 92);
|
||||
//
|
||||
// valueToolStripMenuItem
|
||||
//
|
||||
this.valueToolStripMenuItem.Checked = true;
|
||||
this.valueToolStripMenuItem.CheckOnClick = true;
|
||||
this.valueToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.valueToolStripMenuItem.Name = "valueToolStripMenuItem";
|
||||
this.valueToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.valueToolStripMenuItem.Text = "Value";
|
||||
this.valueToolStripMenuItem.CheckedChanged += new System.EventHandler(this.valueToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// minMenuItem
|
||||
//
|
||||
this.minMenuItem.Checked = true;
|
||||
this.minMenuItem.CheckOnClick = true;
|
||||
this.minMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.minMenuItem.Name = "minMenuItem";
|
||||
this.minMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.minMenuItem.Text = "Min";
|
||||
this.minMenuItem.CheckedChanged += new System.EventHandler(this.minToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// maxMenuItem
|
||||
//
|
||||
this.maxMenuItem.Checked = true;
|
||||
this.maxMenuItem.CheckOnClick = true;
|
||||
this.maxMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.maxMenuItem.Name = "maxMenuItem";
|
||||
this.maxMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.maxMenuItem.Text = "Max";
|
||||
this.maxMenuItem.CheckedChanged += new System.EventHandler(this.maxToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// limitMenuItem
|
||||
//
|
||||
this.limitMenuItem.Checked = true;
|
||||
this.limitMenuItem.CheckOnClick = true;
|
||||
this.limitMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.limitMenuItem.Name = "limitMenuItem";
|
||||
this.limitMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.limitMenuItem.Text = "Limit";
|
||||
this.limitMenuItem.CheckedChanged += new System.EventHandler(this.limitToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -329,90 +272,21 @@ namespace OpenHardwareMonitor.GUI {
|
||||
// viewToolStripMenuItem
|
||||
//
|
||||
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.sensorsToolStripMenuItem,
|
||||
this.hiddenMenuItem,
|
||||
this.plotMenuItem,
|
||||
this.toolStripMenuItem1,
|
||||
this.plotMenuItem});
|
||||
this.columnsToolStripMenuItem});
|
||||
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
|
||||
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.viewToolStripMenuItem.Text = "View";
|
||||
//
|
||||
// sensorsToolStripMenuItem
|
||||
// hiddenMenuItem
|
||||
//
|
||||
this.sensorsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.voltMenuItem,
|
||||
this.clocksMenuItem,
|
||||
this.tempMenuItem,
|
||||
this.loadMenuItem,
|
||||
this.fansMenuItem,
|
||||
this.flowsMenuItem});
|
||||
this.sensorsToolStripMenuItem.Name = "sensorsToolStripMenuItem";
|
||||
this.sensorsToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
|
||||
this.sensorsToolStripMenuItem.Text = "Sensors";
|
||||
//
|
||||
// voltMenuItem
|
||||
//
|
||||
this.voltMenuItem.Checked = true;
|
||||
this.voltMenuItem.CheckOnClick = true;
|
||||
this.voltMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.voltMenuItem.Name = "voltMenuItem";
|
||||
this.voltMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.voltMenuItem.Text = "Voltages";
|
||||
this.voltMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// clocksMenuItem
|
||||
//
|
||||
this.clocksMenuItem.Checked = true;
|
||||
this.clocksMenuItem.CheckOnClick = true;
|
||||
this.clocksMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.clocksMenuItem.Name = "clocksMenuItem";
|
||||
this.clocksMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.clocksMenuItem.Text = "Clocks";
|
||||
this.clocksMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// tempMenuItem
|
||||
//
|
||||
this.tempMenuItem.Checked = true;
|
||||
this.tempMenuItem.CheckOnClick = true;
|
||||
this.tempMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.tempMenuItem.Name = "tempMenuItem";
|
||||
this.tempMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.tempMenuItem.Text = "Temperatures";
|
||||
this.tempMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// loadMenuItem
|
||||
//
|
||||
this.loadMenuItem.Checked = true;
|
||||
this.loadMenuItem.CheckOnClick = true;
|
||||
this.loadMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.loadMenuItem.Name = "loadMenuItem";
|
||||
this.loadMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.loadMenuItem.Text = "Load";
|
||||
this.loadMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// fansMenuItem
|
||||
//
|
||||
this.fansMenuItem.Checked = true;
|
||||
this.fansMenuItem.CheckOnClick = true;
|
||||
this.fansMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.fansMenuItem.Name = "fansMenuItem";
|
||||
this.fansMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.fansMenuItem.Text = "Fans";
|
||||
this.fansMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// flowsMenuItem
|
||||
//
|
||||
this.flowsMenuItem.Checked = true;
|
||||
this.flowsMenuItem.CheckOnClick = true;
|
||||
this.flowsMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.flowsMenuItem.Name = "flowsMenuItem";
|
||||
this.flowsMenuItem.Size = new System.Drawing.Size(147, 22);
|
||||
this.flowsMenuItem.Text = "Flows";
|
||||
this.flowsMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(111, 6);
|
||||
this.hiddenMenuItem.CheckOnClick = true;
|
||||
this.hiddenMenuItem.Name = "hiddenMenuItem";
|
||||
this.hiddenMenuItem.Size = new System.Drawing.Size(188, 22);
|
||||
this.hiddenMenuItem.Text = "Show Hidden Sensors";
|
||||
this.hiddenMenuItem.CheckedChanged += new System.EventHandler(this.hiddenSensorsMenuItem_CheckedChanged);
|
||||
//
|
||||
// plotMenuItem
|
||||
//
|
||||
@@ -420,10 +294,66 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.plotMenuItem.CheckOnClick = true;
|
||||
this.plotMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.plotMenuItem.Name = "plotMenuItem";
|
||||
this.plotMenuItem.Size = new System.Drawing.Size(114, 22);
|
||||
this.plotMenuItem.Text = "Plot";
|
||||
this.plotMenuItem.Size = new System.Drawing.Size(188, 22);
|
||||
this.plotMenuItem.Text = "Show Plot";
|
||||
this.plotMenuItem.CheckedChanged += new System.EventHandler(this.plotToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(185, 6);
|
||||
//
|
||||
// columnsToolStripMenuItem
|
||||
//
|
||||
this.columnsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.valueMenuItem,
|
||||
this.minMenuItem,
|
||||
this.maxMenuItem,
|
||||
this.limitMenuItem});
|
||||
this.columnsToolStripMenuItem.Name = "columnsToolStripMenuItem";
|
||||
this.columnsToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
|
||||
this.columnsToolStripMenuItem.Text = "Columns";
|
||||
//
|
||||
// valueMenuItem
|
||||
//
|
||||
this.valueMenuItem.Checked = true;
|
||||
this.valueMenuItem.CheckOnClick = true;
|
||||
this.valueMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.valueMenuItem.Name = "valueMenuItem";
|
||||
this.valueMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.valueMenuItem.Text = "Value";
|
||||
this.valueMenuItem.CheckedChanged += new System.EventHandler(this.valueMenuItem_CheckedChanged);
|
||||
//
|
||||
// minMenuItem
|
||||
//
|
||||
this.minMenuItem.Checked = true;
|
||||
this.minMenuItem.CheckOnClick = true;
|
||||
this.minMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.minMenuItem.Name = "minMenuItem";
|
||||
this.minMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.minMenuItem.Text = "Min";
|
||||
this.minMenuItem.CheckedChanged += new System.EventHandler(this.minMenuItem_CheckedChanged);
|
||||
//
|
||||
// maxMenuItem
|
||||
//
|
||||
this.maxMenuItem.Checked = true;
|
||||
this.maxMenuItem.CheckOnClick = true;
|
||||
this.maxMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.maxMenuItem.Name = "maxMenuItem";
|
||||
this.maxMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.maxMenuItem.Text = "Max";
|
||||
this.maxMenuItem.CheckedChanged += new System.EventHandler(this.maxMenuItem_CheckedChanged);
|
||||
//
|
||||
// limitMenuItem
|
||||
//
|
||||
this.limitMenuItem.Checked = true;
|
||||
this.limitMenuItem.CheckOnClick = true;
|
||||
this.limitMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.limitMenuItem.Name = "limitMenuItem";
|
||||
this.limitMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.limitMenuItem.Text = "Limit";
|
||||
this.limitMenuItem.CheckedChanged += new System.EventHandler(this.limitMenuItem_CheckedChanged);
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -578,7 +508,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "Open Hardware Monitor";
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
|
||||
this.columnsContextMenuStrip.ResumeLayout(false);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.splitContainer.Panel1.ResumeLayout(false);
|
||||
@@ -614,21 +543,9 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private Aga.Controls.Tree.TreeColumn limit;
|
||||
private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxLimit;
|
||||
private System.Windows.Forms.ContextMenuStrip columnsContextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem minMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem maxMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem limitMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem valueToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveReportToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem sensorsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem clocksMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem tempMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fansMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem voltMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem hddMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem loadMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip notifyContextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem hideShowToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||
@@ -637,10 +554,16 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
|
||||
private System.Windows.Forms.ContextMenuStrip sensorContextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem startMinMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem flowsMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem startupMenuItem;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog;
|
||||
private System.Windows.Forms.Timer timer;
|
||||
private System.Windows.Forms.ToolStripMenuItem hiddenMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem columnsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem valueMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem minMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem maxMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem limitMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+61
-79
@@ -60,7 +60,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private SensorSystemTray sensorSystemTray;
|
||||
private NotifyIcon notifyIcon;
|
||||
private StartupManager startupManager = new StartupManager();
|
||||
private SensorProperties sensorProperties = new SensorProperties();
|
||||
private UpdateVisitor updateVisitor = new UpdateVisitor();
|
||||
|
||||
public MainForm() {
|
||||
@@ -119,7 +118,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
timer.Enabled = true;
|
||||
|
||||
plotColorPalette = new Color[14];
|
||||
plotColorPalette = new Color[13];
|
||||
plotColorPalette[0] = Color.Blue;
|
||||
plotColorPalette[1] = Color.OrangeRed;
|
||||
plotColorPalette[2] = Color.Green;
|
||||
@@ -128,14 +127,16 @@ namespace OpenHardwareMonitor.GUI {
|
||||
plotColorPalette[5] = Color.DarkViolet;
|
||||
plotColorPalette[6] = Color.YellowGreen;
|
||||
plotColorPalette[7] = Color.SaddleBrown;
|
||||
plotColorPalette[8] = Color.Gray;
|
||||
plotColorPalette[9] = Color.RoyalBlue;
|
||||
plotColorPalette[10] = Color.DeepPink;
|
||||
plotColorPalette[11] = Color.MediumSeaGreen;
|
||||
plotColorPalette[12] = Color.Olive;
|
||||
plotColorPalette[13] = Color.Firebrick;
|
||||
plotColorPalette[8] = Color.RoyalBlue;
|
||||
plotColorPalette[9] = Color.DeepPink;
|
||||
plotColorPalette[10] = Color.MediumSeaGreen;
|
||||
plotColorPalette[11] = Color.Olive;
|
||||
plotColorPalette[12] = Color.Firebrick;
|
||||
|
||||
hiddenMenuItem.Checked = Config.Get(hiddenMenuItem.Name, false);
|
||||
plotMenuItem.Checked = Config.Get(plotMenuItem.Name, false);
|
||||
|
||||
valueMenuItem.Checked = Config.Get(valueMenuItem.Name, true);
|
||||
minMenuItem.Checked = Config.Get(minMenuItem.Name, false);
|
||||
maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true);
|
||||
limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);
|
||||
@@ -143,14 +144,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false);
|
||||
minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
|
||||
startupMenuItem.Checked = startupManager.Startup;
|
||||
hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
|
||||
|
||||
voltMenuItem.Checked = Config.Get(voltMenuItem.Name, true);
|
||||
clocksMenuItem.Checked = Config.Get(clocksMenuItem.Name, true);
|
||||
loadMenuItem.Checked = Config.Get(loadMenuItem.Name, true);
|
||||
tempMenuItem.Checked = Config.Get(tempMenuItem.Name, true);
|
||||
fansMenuItem.Checked = Config.Get(fansMenuItem.Name, true);
|
||||
flowsMenuItem.Checked = Config.Get(flowsMenuItem.Name, true);
|
||||
hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
|
||||
|
||||
if (startMinMenuItem.Checked) {
|
||||
if (!minTrayMenuItem.Checked) {
|
||||
@@ -196,15 +190,18 @@ namespace OpenHardwareMonitor.GUI {
|
||||
e.Text = sensorNode.ValueToString(sensorNode.Sensor.Limit);
|
||||
}
|
||||
|
||||
private void nodeTextBoxText_DrawText(object sender, DrawEventArgs e) {
|
||||
if (!plotMenuItem.Checked)
|
||||
return;
|
||||
|
||||
SensorNode sensorNode = e.Node.Tag as SensorNode;
|
||||
if (sensorNode != null) {
|
||||
private void nodeTextBoxText_DrawText(object sender, DrawEventArgs e) {
|
||||
Node node = e.Node.Tag as Node;
|
||||
if (node != null) {
|
||||
Color color;
|
||||
if (sensorPlotColors.TryGetValue(sensorNode.Sensor, out color))
|
||||
e.TextColor = color;
|
||||
if (node.IsVisible) {
|
||||
SensorNode sensorNode = node as SensorNode;
|
||||
if (plotMenuItem.Checked && sensorNode != null &&
|
||||
sensorPlotColors.TryGetValue(sensorNode.Sensor, out color))
|
||||
e.TextColor = color;
|
||||
} else {
|
||||
e.TextColor = Color.DarkGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,22 +247,18 @@ namespace OpenHardwareMonitor.GUI {
|
||||
}
|
||||
|
||||
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
|
||||
|
||||
|
||||
Config.Set(hiddenMenuItem.Name, hiddenMenuItem.Checked);
|
||||
Config.Set(plotMenuItem.Name, plotMenuItem.Checked);
|
||||
|
||||
Config.Set(valueMenuItem.Name, valueMenuItem.Checked);
|
||||
Config.Set(minMenuItem.Name, minMenuItem.Checked);
|
||||
Config.Set(maxMenuItem.Name, maxMenuItem.Checked);
|
||||
Config.Set(limitMenuItem.Name, limitMenuItem.Checked);
|
||||
|
||||
Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
|
||||
Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
|
||||
Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
|
||||
|
||||
Config.Set(voltMenuItem.Name, voltMenuItem.Checked);
|
||||
Config.Set(clocksMenuItem.Name, clocksMenuItem.Checked);
|
||||
Config.Set(loadMenuItem.Name, loadMenuItem.Checked);
|
||||
Config.Set(tempMenuItem.Name, tempMenuItem.Checked);
|
||||
Config.Set(fansMenuItem.Name, fansMenuItem.Checked);
|
||||
Config.Set(flowsMenuItem.Name, flowsMenuItem.Checked);
|
||||
Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
|
||||
|
||||
if (WindowState != FormWindowState.Minimized) {
|
||||
Config.Set("mainForm.Location.X", Location.X);
|
||||
@@ -292,27 +285,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
treeView.Invalidate();
|
||||
}
|
||||
|
||||
private void valueToolStripMenuItem_CheckedChanged(object sender,
|
||||
EventArgs e)
|
||||
{
|
||||
treeView.Columns[1].IsVisible = valueToolStripMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void minToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
treeView.Columns[2].IsVisible = minMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void maxToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
treeView.Columns[3].IsVisible = maxMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void limitToolStripMenuItem_CheckedChanged(object sender,
|
||||
EventArgs e) {
|
||||
treeView.Columns[4].IsVisible = limitMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void treeView_Click(object sender, EventArgs e) {
|
||||
|
||||
MouseEventArgs m = e as MouseEventArgs;
|
||||
@@ -320,9 +292,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
return;
|
||||
|
||||
NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));
|
||||
if (info.Control == null) {
|
||||
columnsContextMenuStrip.Show(treeView, m.X, m.Y);
|
||||
} else {
|
||||
if (info.Control != null) {
|
||||
SensorNode node = info.Node.Tag as SensorNode;
|
||||
if (node != null && node.Sensor != null) {
|
||||
|
||||
@@ -334,6 +304,19 @@ namespace OpenHardwareMonitor.GUI {
|
||||
};
|
||||
sensorContextMenuStrip.Items.Add(item);
|
||||
}
|
||||
if (node.IsVisible) {
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("Hide");
|
||||
item.Click += delegate(object obj, EventArgs args) {
|
||||
node.IsVisible = false;
|
||||
};
|
||||
sensorContextMenuStrip.Items.Add(item);
|
||||
} else {
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("Unhide");
|
||||
item.Click += delegate(object obj, EventArgs args) {
|
||||
node.IsVisible = true;
|
||||
};
|
||||
sensorContextMenuStrip.Items.Add(item);
|
||||
}
|
||||
if (sensorSystemTray.Contains(node.Sensor)) {
|
||||
ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
|
||||
item.Click += delegate(object obj, EventArgs args) {
|
||||
@@ -365,31 +348,9 @@ namespace OpenHardwareMonitor.GUI {
|
||||
EventArgs e)
|
||||
{
|
||||
computer.HDDEnabled = hddMenuItem.Checked;
|
||||
UpdateSensorTypeChecked(null, null);
|
||||
UpdatePlotSelection(null, null);
|
||||
}
|
||||
|
||||
private void UpdateSensorTypeVisible(Node node) {
|
||||
HardwareNode hardwareNode = node as HardwareNode;
|
||||
if (hardwareNode == null)
|
||||
return;
|
||||
|
||||
hardwareNode.SetVisible(SensorType.Voltage, voltMenuItem.Checked);
|
||||
hardwareNode.SetVisible(SensorType.Clock, clocksMenuItem.Checked);
|
||||
hardwareNode.SetVisible(SensorType.Load, loadMenuItem.Checked);
|
||||
hardwareNode.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
|
||||
hardwareNode.SetVisible(SensorType.Fan, fansMenuItem.Checked);
|
||||
hardwareNode.SetVisible(SensorType.Flow, flowsMenuItem.Checked);
|
||||
|
||||
foreach (Node n in node.Nodes)
|
||||
UpdateSensorTypeVisible(n);
|
||||
}
|
||||
|
||||
private void UpdateSensorTypeChecked(object sender, EventArgs e) {
|
||||
foreach (HardwareNode node in root.Nodes)
|
||||
UpdateSensorTypeVisible(node);
|
||||
}
|
||||
|
||||
private void SysTrayHideShow() {
|
||||
Visible = !Visible;
|
||||
if (Visible)
|
||||
@@ -448,5 +409,26 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private void minTrayMenuItem_CheckedChanged(object sender, EventArgs e) {
|
||||
notifyIcon.Visible = minTrayMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void hiddenSensorsMenuItem_CheckedChanged(object sender,
|
||||
EventArgs e) {
|
||||
treeModel.ForceVisible = hiddenMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void valueMenuItem_CheckedChanged(object sender, EventArgs e) {
|
||||
treeView.Columns[1].IsVisible = valueMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void minMenuItem_CheckedChanged(object sender, EventArgs e) {
|
||||
treeView.Columns[2].IsVisible = minMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void maxMenuItem_CheckedChanged(object sender, EventArgs e) {
|
||||
treeView.Columns[3].IsVisible = maxMenuItem.Checked;
|
||||
}
|
||||
|
||||
private void limitMenuItem_CheckedChanged(object sender, EventArgs e) {
|
||||
treeView.Columns[4].IsVisible = limitMenuItem.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="columnsContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Open Hardware Monitor code.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael Möller <m.moeller@gmx.ch>.
|
||||
Portions created by the Initial Developer are Copyright (C) 2009-2010
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using Aga.Controls.Tree;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class Node {
|
||||
|
||||
private TreeModel treeModel;
|
||||
private Node parent;
|
||||
private NodeCollection nodes;
|
||||
|
||||
private string text;
|
||||
private Image image;
|
||||
private bool visible;
|
||||
|
||||
private TreeModel RootTreeModel() {
|
||||
Node node = this;
|
||||
while (node != null) {
|
||||
if (node.Model != null)
|
||||
return node.Model;
|
||||
node = node.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node() : this(string.Empty) { }
|
||||
|
||||
public Node(string text) {
|
||||
this.text = text;
|
||||
this.nodes = new NodeCollection(this);
|
||||
this.visible = true;
|
||||
}
|
||||
|
||||
public TreeModel Model {
|
||||
get { return treeModel; }
|
||||
set { treeModel = value; }
|
||||
}
|
||||
|
||||
public Node Parent {
|
||||
get { return parent; }
|
||||
set {
|
||||
if (value != parent) {
|
||||
if (parent != null)
|
||||
parent.nodes.Remove(this);
|
||||
if (value != null)
|
||||
value.nodes.Add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Node> Nodes {
|
||||
get { return nodes; }
|
||||
}
|
||||
|
||||
public virtual string Text {
|
||||
get { return text; }
|
||||
set {
|
||||
if (text != value) {
|
||||
text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Image Image {
|
||||
get { return image; }
|
||||
set {
|
||||
if (image != value) {
|
||||
image = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsVisible {
|
||||
get { return visible; }
|
||||
set {
|
||||
if (value != visible) {
|
||||
visible = value;
|
||||
TreeModel model = RootTreeModel();
|
||||
if (model != null && parent != null) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < parent.nodes.Count; i++) {
|
||||
Node node = parent.nodes[i];
|
||||
if (node == this)
|
||||
break;
|
||||
if (node.IsVisible || model.ForceVisible)
|
||||
index++;
|
||||
}
|
||||
if (model.ForceVisible) {
|
||||
model.OnNodeChanged(parent, index, this);
|
||||
} else {
|
||||
if (value)
|
||||
model.OnNodeInserted(parent, index, this);
|
||||
else
|
||||
model.OnNodeRemoved(parent, index, this);
|
||||
}
|
||||
}
|
||||
if (IsVisibleChanged != null)
|
||||
IsVisibleChanged(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void NodeEventHandler(Node node);
|
||||
|
||||
public event NodeEventHandler IsVisibleChanged;
|
||||
public event NodeEventHandler NodeAdded;
|
||||
public event NodeEventHandler NodeRemoved;
|
||||
|
||||
private class NodeCollection : Collection<Node> {
|
||||
private Node owner;
|
||||
|
||||
public NodeCollection(Node owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
protected override void ClearItems() {
|
||||
while (this.Count != 0)
|
||||
this.RemoveAt(this.Count - 1);
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, Node item) {
|
||||
if (item == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
if (item.parent != owner) {
|
||||
if (item.parent != null)
|
||||
item.parent.nodes.Remove(item);
|
||||
item.parent = owner;
|
||||
base.InsertItem(index, item);
|
||||
|
||||
TreeModel model = owner.RootTreeModel();
|
||||
if (model != null)
|
||||
model.OnStructureChanged(owner);
|
||||
if (owner.NodeAdded != null)
|
||||
owner.NodeAdded(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RemoveItem(int index) {
|
||||
Node item = this[index];
|
||||
item.parent = null;
|
||||
base.RemoveItem(index);
|
||||
|
||||
TreeModel model = owner.RootTreeModel();
|
||||
if (model != null)
|
||||
model.OnStructureChanged(owner);
|
||||
if (owner.NodeRemoved != null)
|
||||
owner.NodeRemoved(item);
|
||||
}
|
||||
|
||||
protected override void SetItem(int index, Node item) {
|
||||
if (item == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
RemoveAt(index);
|
||||
InsertItem(index, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-4
@@ -37,8 +37,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aga.Controls.Tree;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class SensorNode : Node {
|
||||
@@ -54,7 +54,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
return "-";
|
||||
}
|
||||
|
||||
public SensorNode(ISensor sensor) {
|
||||
public SensorNode(ISensor sensor) : base() {
|
||||
this.sensor = sensor;
|
||||
switch (sensor.SensorType) {
|
||||
case SensorType.Voltage: format = "{0:F2} V"; break;
|
||||
@@ -63,13 +63,26 @@ namespace OpenHardwareMonitor.GUI {
|
||||
case SensorType.Temperature: format = "{0:F1} °C"; break;
|
||||
case SensorType.Fan: format = "{0:F0} RPM"; break;
|
||||
case SensorType.Flow: format = "{0:F0} L/h"; break;
|
||||
}
|
||||
}
|
||||
|
||||
bool hidden = Config.Get(new Identifier(sensor.Identifier,
|
||||
"hidden").ToString(), sensor.IsDefaultHidden);
|
||||
IsVisible = !hidden;
|
||||
}
|
||||
|
||||
public override string Text {
|
||||
get { return sensor.Name; }
|
||||
set { sensor.Name = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsVisible {
|
||||
get { return base.IsVisible; }
|
||||
set {
|
||||
base.IsVisible = value;
|
||||
Config.Set(new Identifier(sensor.Identifier,
|
||||
"hidden").ToString(), !value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Plot {
|
||||
get { return plot; }
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Open Hardware Monitor code.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael Möller <m.moeller@gmx.ch>.
|
||||
Portions created by the Initial Developer are Copyright (C) 2009-2010
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class SensorProperties {
|
||||
|
||||
private IDictionary<Identifier, Properties> properties =
|
||||
new Dictionary<Identifier, Properties>();
|
||||
|
||||
private Properties GetProperties(ISensor sensor) {
|
||||
Properties value;
|
||||
if (!properties.TryGetValue(sensor.Identifier, out value)) {
|
||||
value = new Properties(sensor.Identifier, sensor.IsDefaultHidden);
|
||||
properties.Add(sensor.Identifier, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public bool IsHidden(ISensor sensor) {
|
||||
return GetProperties(sensor).IsHidden;
|
||||
}
|
||||
|
||||
private class Properties {
|
||||
private Identifier identifier;
|
||||
private bool hidden;
|
||||
|
||||
public Properties(Identifier identifier, bool defaultHidden) {
|
||||
this.identifier = identifier;
|
||||
|
||||
hidden = Config.Get(new Identifier(identifier, "hidden").ToString(),
|
||||
defaultHidden);
|
||||
}
|
||||
|
||||
public bool IsHidden { get { return hidden; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Open Hardware Monitor code.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael Möller <m.moeller@gmx.ch>.
|
||||
Portions created by the Initial Developer are Copyright (C) 2009-2010
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Aga.Controls.Tree;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class TreeModel : ITreeModel {
|
||||
|
||||
private Node root;
|
||||
private bool forceVisible = false;
|
||||
|
||||
public TreeModel() {
|
||||
root = new Node();
|
||||
root.Model = this;
|
||||
}
|
||||
|
||||
public TreePath GetPath(Node node) {
|
||||
if (node == root)
|
||||
return TreePath.Empty;
|
||||
else {
|
||||
Stack<object> stack = new Stack<object>();
|
||||
while (node != root) {
|
||||
stack.Push(node);
|
||||
node = node.Parent;
|
||||
}
|
||||
return new TreePath(stack.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Node> Nodes {
|
||||
get { return root.Nodes; }
|
||||
}
|
||||
|
||||
private Node GetNode(TreePath treePath) {
|
||||
Node parent = root;
|
||||
foreach (object obj in treePath.FullPath) {
|
||||
Node node = obj as Node;
|
||||
if (node == null || node.Parent != parent)
|
||||
return null;
|
||||
parent = node;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
public IEnumerable GetChildren(TreePath treePath) {
|
||||
Node node = GetNode(treePath);
|
||||
if (node != null) {
|
||||
foreach (Node n in node.Nodes)
|
||||
if (forceVisible || n.IsVisible)
|
||||
yield return n;
|
||||
} else {
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLeaf(TreePath treePath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ForceVisible {
|
||||
get {
|
||||
return forceVisible;
|
||||
}
|
||||
set {
|
||||
if (value != forceVisible) {
|
||||
forceVisible = value;
|
||||
OnStructureChanged(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable 67
|
||||
public event EventHandler<TreeModelEventArgs> NodesChanged;
|
||||
public event EventHandler<TreePathEventArgs> StructureChanged;
|
||||
public event EventHandler<TreeModelEventArgs> NodesInserted;
|
||||
public event EventHandler<TreeModelEventArgs> NodesRemoved;
|
||||
#pragma warning restore 67
|
||||
|
||||
public void OnNodeChanged(Node parent, int index, Node node) {
|
||||
if (NodesChanged != null && parent != null) {
|
||||
TreePath path = GetPath(parent);
|
||||
if (path != null)
|
||||
NodesChanged(this, new TreeModelEventArgs(
|
||||
path, new int[] { index }, new object[] { node }));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnStructureChanged(Node node) {
|
||||
if (StructureChanged != null)
|
||||
StructureChanged(this,
|
||||
new TreeModelEventArgs(GetPath(node), new object[0]));
|
||||
}
|
||||
|
||||
public void OnNodeInserted(Node parent, int index, Node node) {
|
||||
if (NodesInserted != null) {
|
||||
TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent),
|
||||
new int[] { index }, new object[] { node });
|
||||
NodesInserted(this, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnNodeRemoved(Node parent, int index, Node node) {
|
||||
if (NodesRemoved != null) {
|
||||
TreeModelEventArgs args = new TreeModelEventArgs(GetPath(parent),
|
||||
new int[] { index }, new object[] { node });
|
||||
NodesRemoved(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+22
-8
@@ -37,14 +37,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aga.Controls.Tree;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class TypeNode : Node {
|
||||
|
||||
private SensorType sensorType;
|
||||
private bool visible = true;
|
||||
|
||||
public TypeNode(SensorType sensorType) : base() {
|
||||
this.sensorType = sensorType;
|
||||
@@ -75,16 +73,32 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.Text = "Flows";
|
||||
break;
|
||||
}
|
||||
|
||||
NodeAdded += new NodeEventHandler(TypeNode_NodeAdded);
|
||||
NodeRemoved += new NodeEventHandler(TypeNode_NodeRemoved);
|
||||
}
|
||||
|
||||
private void TypeNode_NodeRemoved(Node node) {
|
||||
node.IsVisibleChanged -= new NodeEventHandler(node_IsVisibleChanged);
|
||||
node_IsVisibleChanged(null);
|
||||
}
|
||||
|
||||
private void TypeNode_NodeAdded(Node node) {
|
||||
node.IsVisibleChanged += new NodeEventHandler(node_IsVisibleChanged);
|
||||
node_IsVisibleChanged(null);
|
||||
}
|
||||
|
||||
private void node_IsVisibleChanged(Node node) {
|
||||
foreach (Node n in Nodes)
|
||||
if (n.IsVisible) {
|
||||
this.IsVisible = true;
|
||||
return;
|
||||
}
|
||||
this.IsVisible = false;
|
||||
}
|
||||
|
||||
public SensorType SensorType {
|
||||
get { return sensorType; }
|
||||
}
|
||||
|
||||
public bool IsVisible {
|
||||
get { return visible; }
|
||||
set { visible = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Merge|AnyCPU' ">
|
||||
<OutputPath>bin\Merge\</OutputPath>
|
||||
@@ -65,6 +66,7 @@
|
||||
<Compile Include="GUI\CrashReportForm.Designer.cs">
|
||||
<DependentUpon>CrashReportForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\Node.cs" />
|
||||
<Compile Include="GUI\ParameterForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -72,10 +74,10 @@
|
||||
<DependentUpon>ParameterForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\SensorNotifyIcon.cs" />
|
||||
<Compile Include="GUI\SensorProperties.cs" />
|
||||
<Compile Include="GUI\SensorSystemTray.cs" />
|
||||
<Compile Include="GUI\StartupManager.cs" />
|
||||
<Compile Include="GUI\TaskScheduler.cs" />
|
||||
<Compile Include="GUI\TreeModel.cs" />
|
||||
<Compile Include="GUI\TypeNode.cs" />
|
||||
<Compile Include="GUI\UpdateVisitor.cs" />
|
||||
<Compile Include="Hardware\CPU\AMD10CPU.cs" />
|
||||
|
||||
Reference in New Issue
Block a user