Merge branch 'Added customizable pen colors'
This commit is contained in:
+30
-3
@@ -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.HasValue) {
|
||||
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) {
|
||||
@@ -521,7 +524,13 @@ namespace OpenHardwareMonitor.GUI {
|
||||
} else {
|
||||
usedColors.Add(curColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (TreeNodeAdv node in treeView.AllNodes) {
|
||||
SensorNode sensorNode = node.Tag as SensorNode;
|
||||
if (sensorNode != null && sensorNode.Plot && sensorNode.PenColor.HasValue)
|
||||
colors.Add(sensorNode.Sensor, sensorNode.PenColor.Value);
|
||||
}
|
||||
|
||||
sensorPlotColors = colors;
|
||||
plotPanel.SetSensors(selected, colors);
|
||||
@@ -673,6 +682,24 @@ 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 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);
|
||||
|
||||
+24
-2
@@ -4,11 +4,12 @@
|
||||
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/.
|
||||
|
||||
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2009-2016 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
@@ -20,7 +21,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private PersistentSettings settings;
|
||||
private UnitManager unitManager;
|
||||
private string format;
|
||||
private bool plot = false;
|
||||
private bool plot = false;
|
||||
private Color? penColor = null;
|
||||
|
||||
public string ValueToString(float? value) {
|
||||
if (value.HasValue) {
|
||||
@@ -60,6 +62,10 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
this.Plot = settings.GetValue(new Identifier(sensor.Identifier,
|
||||
"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 {
|
||||
@@ -76,6 +82,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 {
|
||||
get { return plot; }
|
||||
set {
|
||||
|
||||
Reference in New Issue
Block a user