Added a menu item to reset the pen color (to use again the plotColorPalette based color). Moved the saving/loading code to the SensorNode class (as with the other properties).

This commit is contained in:
Michael Möller
2016-11-06 14:51:24 +01:00
parent 9479c08df9
commit bb45f65447
6 changed files with 38 additions and 20 deletions

View File

@@ -89,8 +89,6 @@ namespace OpenHardwareMonitor.GUI {
((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index) ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
i++; i++;
SensorNode sensorNode = new SensorNode(sensor, settings, unitManager); SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
if (settings.Contains(sensor.Identifier + "/PenColor"))
sensorNode.penColor = settings.GetValue(sensor.Identifier + "/PenColor", Color.Black);
sensorNode.PlotSelectionChanged += SensorPlotSelectionChanged; sensorNode.PlotSelectionChanged += SensorPlotSelectionChanged;
node.Nodes.Insert(i, sensorNode); node.Nodes.Insert(i, sensorNode);
} }

View File

@@ -111,7 +111,6 @@ namespace OpenHardwareMonitor.GUI {
this.log1hMenuItem = new System.Windows.Forms.MenuItem(); this.log1hMenuItem = new System.Windows.Forms.MenuItem();
this.log2hMenuItem = new System.Windows.Forms.MenuItem(); this.log2hMenuItem = new System.Windows.Forms.MenuItem();
this.log6hMenuItem = new System.Windows.Forms.MenuItem(); this.log6hMenuItem = new System.Windows.Forms.MenuItem();
this.colorDialog = new System.Windows.Forms.ColorDialog();
this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.SuspendLayout(); this.splitContainer.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@@ -763,7 +762,6 @@ namespace OpenHardwareMonitor.GUI {
private System.Windows.Forms.MenuItem log1hMenuItem; private System.Windows.Forms.MenuItem log1hMenuItem;
private System.Windows.Forms.MenuItem log2hMenuItem; private System.Windows.Forms.MenuItem log2hMenuItem;
private System.Windows.Forms.MenuItem log6hMenuItem; private System.Windows.Forms.MenuItem log6hMenuItem;
private System.Windows.Forms.ColorDialog colorDialog;
} }
} }

View File

@@ -494,7 +494,7 @@ namespace OpenHardwareMonitor.GUI {
SensorNode sensorNode = node.Tag as SensorNode; SensorNode sensorNode = node.Tag as SensorNode;
if (sensorNode != null) { if (sensorNode != null) {
if (sensorNode.Plot) { if (sensorNode.Plot) {
if (sensorNode.penColor == null) { if (!sensorNode.PenColor.HasValue) {
colors.Add(sensorNode.Sensor, colors.Add(sensorNode.Sensor,
plotColorPalette[colorIndex % plotColorPalette.Length]); plotColorPalette[colorIndex % plotColorPalette.Length]);
} }
@@ -528,8 +528,8 @@ namespace OpenHardwareMonitor.GUI {
foreach (TreeNodeAdv node in treeView.AllNodes) { foreach (TreeNodeAdv node in treeView.AllNodes) {
SensorNode sensorNode = node.Tag as SensorNode; SensorNode sensorNode = node.Tag as SensorNode;
if (sensorNode != null && sensorNode.Plot && sensorNode.penColor != null) if (sensorNode != null && sensorNode.Plot && sensorNode.PenColor.HasValue)
colors.Add(sensorNode.Sensor, sensorNode.penColor.Value); colors.Add(sensorNode.Sensor, sensorNode.PenColor.Value);
} }
sensorPlotColors = colors; sensorPlotColors = colors;
@@ -683,17 +683,23 @@ namespace OpenHardwareMonitor.GUI {
} }
treeContextMenu.MenuItems.Add(new MenuItem("-")); treeContextMenu.MenuItems.Add(new MenuItem("-"));
{ {
MenuItem item = new MenuItem("Pen color"); MenuItem item = new MenuItem("Pen Color...");
item.Click += delegate(object obj, EventArgs args) { item.Click += delegate(object obj, EventArgs args) {
colorDialog.Color = node.penColor.GetValueOrDefault(); ColorDialog dialog = new ColorDialog();
if (colorDialog.ShowDialog() == DialogResult.OK) { dialog.Color = node.PenColor.GetValueOrDefault();
node.penColor = colorDialog.Color; if (dialog.ShowDialog() == DialogResult.OK)
settings.SetValue(node.Sensor.Identifier + "/PenColor", colorDialog.Color); node.PenColor = dialog.Color;
PlotSelectionChanged(this, null);
}
}; };
treeContextMenu.MenuItems.Add(item); treeContextMenu.MenuItems.Add(item);
} }
{
MenuItem item = new MenuItem("Reset Pen Color");
item.Click += delegate(object obj, EventArgs args) {
node.PenColor = null;
};
treeContextMenu.MenuItems.Add(item);
}
treeContextMenu.MenuItems.Add(new MenuItem("-"));
{ {
MenuItem item = new MenuItem("Show in Tray"); MenuItem item = new MenuItem("Show in Tray");
item.Checked = systemTray.Contains(node.Sensor); item.Checked = systemTray.Contains(node.Sensor);

View File

@@ -129,9 +129,6 @@
<metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>293, 17</value> <value>293, 17</value>
</metadata> </metadata>
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>483, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

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-2012 Michael Möller <mmoeller@openhardwaremonitor.org> Copyright (C) 2009-2016 Michael Möller <mmoeller@openhardwaremonitor.org>
*/ */
@@ -22,7 +22,7 @@ namespace OpenHardwareMonitor.GUI {
private UnitManager unitManager; private UnitManager unitManager;
private string format; private string format;
private bool plot = false; private bool plot = false;
public Color? penColor = null; private Color? penColor = null;
public string ValueToString(float? value) { public string ValueToString(float? value) {
if (value.HasValue) { if (value.HasValue) {
@@ -61,6 +61,10 @@ namespace OpenHardwareMonitor.GUI {
this.Plot = settings.GetValue(new Identifier(sensor.Identifier, this.Plot = settings.GetValue(new Identifier(sensor.Identifier,
"plot").ToString(), false); "plot").ToString(), false);
string id = new Identifier(sensor.Identifier, "penColor").ToString();
if (settings.Contains(id))
this.PenColor = settings.GetValue(id, Color.Black);
} }
public override string Text { public override string Text {
@@ -77,6 +81,22 @@ namespace OpenHardwareMonitor.GUI {
} }
} }
public Color? PenColor {
get { return penColor; }
set {
penColor = value;
string id = new Identifier(sensor.Identifier, "penColor").ToString();
if (value.HasValue)
settings.SetValue(id, value.Value);
else
settings.Remove(id);
if (PlotSelectionChanged != null)
PlotSelectionChanged(this, null);
}
}
public bool Plot { public bool Plot {
get { return plot; } get { return plot; }
set { set {

View File

@@ -66,7 +66,6 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" /> <Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Management" /> <Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />