Added customizable pen colors

New node property, penColor, is null by default; this means that color
will be picked using the existing plotColorPalette method.
New node context menu item, Pen color, lets user choose the color to be
used when plotting this particular node.
This property is also saved/loaded from settings based on sensor
identifier.
This commit is contained in:
shrddr
2016-07-13 21:17:01 +03:00
parent da432ef07c
commit 9479c08df9
6 changed files with 35 additions and 4 deletions

View File

@@ -89,6 +89,8 @@ namespace OpenHardwareMonitor.GUI {
((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
i++;
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;
node.Nodes.Insert(i, sensorNode);
}

View File

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

View File

@@ -494,8 +494,10 @@ namespace OpenHardwareMonitor.GUI {
SensorNode sensorNode = node.Tag as SensorNode;
if (sensorNode != null) {
if (sensorNode.Plot) {
colors.Add(sensorNode.Sensor,
plotColorPalette[colorIndex % plotColorPalette.Length]);
if (sensorNode.penColor == null) {
colors.Add(sensorNode.Sensor,
plotColorPalette[colorIndex % plotColorPalette.Length]);
}
selected.Add(sensorNode.Sensor);
}
colorIndex++;
@@ -509,6 +511,7 @@ namespace OpenHardwareMonitor.GUI {
// from the plot
var usedColors = new List<Color>();
foreach (var curSelectedSensor in selected) {
if (!colors.ContainsKey(curSelectedSensor)) continue;
var curColor = colors[curSelectedSensor];
if (usedColors.Contains(curColor)) {
foreach (var potentialNewColor in plotColorPalette) {
@@ -523,6 +526,12 @@ 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);
}
sensorPlotColors = colors;
plotPanel.SetSensors(selected, colors);
}
@@ -673,6 +682,18 @@ namespace OpenHardwareMonitor.GUI {
treeContextMenu.MenuItems.Add(item);
}
treeContextMenu.MenuItems.Add(new MenuItem("-"));
{
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);
}
};
treeContextMenu.MenuItems.Add(item);
}
{
MenuItem item = new MenuItem("Show in Tray");
item.Checked = systemTray.Contains(node.Sensor);

View File

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

View File

@@ -9,6 +9,7 @@
*/
using System;
using System.Drawing;
using System.Collections.Generic;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities;
@@ -21,6 +22,7 @@ namespace OpenHardwareMonitor.GUI {
private UnitManager unitManager;
private string format;
private bool plot = false;
public Color? penColor = null;
public string ValueToString(float? value) {
if (value.HasValue) {

View File

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