mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-31 06:15:08 +00:00
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:
@@ -89,6 +89,8 @@ 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);
|
||||||
}
|
}
|
||||||
|
2
GUI/MainForm.Designer.cs
generated
2
GUI/MainForm.Designer.cs
generated
@@ -111,6 +111,7 @@ 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();
|
||||||
@@ -762,6 +763,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -494,8 +494,10 @@ 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) {
|
||||||
colors.Add(sensorNode.Sensor,
|
if (sensorNode.penColor == null) {
|
||||||
plotColorPalette[colorIndex % plotColorPalette.Length]);
|
colors.Add(sensorNode.Sensor,
|
||||||
|
plotColorPalette[colorIndex % plotColorPalette.Length]);
|
||||||
|
}
|
||||||
selected.Add(sensorNode.Sensor);
|
selected.Add(sensorNode.Sensor);
|
||||||
}
|
}
|
||||||
colorIndex++;
|
colorIndex++;
|
||||||
@@ -509,6 +511,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
// from the plot
|
// from the plot
|
||||||
var usedColors = new List<Color>();
|
var usedColors = new List<Color>();
|
||||||
foreach (var curSelectedSensor in selected) {
|
foreach (var curSelectedSensor in selected) {
|
||||||
|
if (!colors.ContainsKey(curSelectedSensor)) continue;
|
||||||
var curColor = colors[curSelectedSensor];
|
var curColor = colors[curSelectedSensor];
|
||||||
if (usedColors.Contains(curColor)) {
|
if (usedColors.Contains(curColor)) {
|
||||||
foreach (var potentialNewColor in plotColorPalette) {
|
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;
|
sensorPlotColors = colors;
|
||||||
plotPanel.SetSensors(selected, colors);
|
plotPanel.SetSensors(selected, colors);
|
||||||
}
|
}
|
||||||
@@ -673,6 +682,18 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
treeContextMenu.MenuItems.Add(item);
|
treeContextMenu.MenuItems.Add(item);
|
||||||
}
|
}
|
||||||
treeContextMenu.MenuItems.Add(new MenuItem("-"));
|
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");
|
MenuItem item = new MenuItem("Show in Tray");
|
||||||
item.Checked = systemTray.Contains(node.Sensor);
|
item.Checked = systemTray.Contains(node.Sensor);
|
||||||
|
@@ -129,6 +129,9 @@
|
|||||||
<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>
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenHardwareMonitor.Hardware;
|
using OpenHardwareMonitor.Hardware;
|
||||||
using OpenHardwareMonitor.Utilities;
|
using OpenHardwareMonitor.Utilities;
|
||||||
@@ -21,6 +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;
|
||||||
|
|
||||||
public string ValueToString(float? value) {
|
public string ValueToString(float? value) {
|
||||||
if (value.HasValue) {
|
if (value.HasValue) {
|
||||||
|
@@ -66,6 +66,7 @@
|
|||||||
</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" />
|
||||||
|
Reference in New Issue
Block a user