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

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