mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-03 15:55:26 +00:00
Added a context menu to the plot which allows the user to configure the time window for plotting.
This commit is contained in:
13
GUI/MainForm.Designer.cs
generated
13
GUI/MainForm.Designer.cs
generated
@@ -108,8 +108,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.timer = new System.Windows.Forms.Timer(this.components);
|
this.timer = new System.Windows.Forms.Timer(this.components);
|
||||||
this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
|
this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
|
||||||
this.treeView = new Aga.Controls.Tree.TreeViewAdv();
|
this.treeView = new Aga.Controls.Tree.TreeViewAdv();
|
||||||
this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
|
|
||||||
this.plotLocationMenuItem = new System.Windows.Forms.MenuItem();
|
this.plotLocationMenuItem = new System.Windows.Forms.MenuItem();
|
||||||
this.plotWindowMenuItem = new System.Windows.Forms.MenuItem();
|
this.plotWindowMenuItem = new System.Windows.Forms.MenuItem();
|
||||||
this.plotBottomMenuItem = new System.Windows.Forms.MenuItem();
|
this.plotBottomMenuItem = new System.Windows.Forms.MenuItem();
|
||||||
@@ -431,7 +430,6 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
//
|
//
|
||||||
// splitContainer.Panel2
|
// splitContainer.Panel2
|
||||||
//
|
//
|
||||||
this.splitContainer.Panel2.Controls.Add(this.plotPanel);
|
|
||||||
this.splitContainer.Panel2.Cursor = System.Windows.Forms.Cursors.Default;
|
this.splitContainer.Panel2.Cursor = System.Windows.Forms.Cursors.Default;
|
||||||
this.splitContainer.Size = new System.Drawing.Size(386, 483);
|
this.splitContainer.Size = new System.Drawing.Size(386, 483);
|
||||||
this.splitContainer.SplitterDistance = 354;
|
this.splitContainer.SplitterDistance = 354;
|
||||||
@@ -472,14 +470,6 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove);
|
this.treeView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseMove);
|
||||||
this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp);
|
this.treeView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseUp);
|
||||||
//
|
//
|
||||||
// plotPanel
|
|
||||||
//
|
|
||||||
this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.plotPanel.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.plotPanel.Name = "plotPanel";
|
|
||||||
this.plotPanel.Size = new System.Drawing.Size(386, 124);
|
|
||||||
this.plotPanel.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// plotLocationMenuItem
|
// plotLocationMenuItem
|
||||||
//
|
//
|
||||||
this.plotLocationMenuItem.Index = 6;
|
this.plotLocationMenuItem.Index = 6;
|
||||||
@@ -542,7 +532,6 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMin;
|
private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMin;
|
||||||
private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMax;
|
private Aga.Controls.Tree.NodeControls.NodeTextBox nodeTextBoxMax;
|
||||||
private SplitContainerAdv splitContainer;
|
private SplitContainerAdv splitContainer;
|
||||||
private PlotPanel plotPanel;
|
|
||||||
private System.Windows.Forms.MenuItem viewMenuItem;
|
private System.Windows.Forms.MenuItem viewMenuItem;
|
||||||
private System.Windows.Forms.MenuItem plotMenuItem;
|
private System.Windows.Forms.MenuItem plotMenuItem;
|
||||||
private Aga.Controls.Tree.NodeControls.NodeCheckBox nodeCheckBox;
|
private Aga.Controls.Tree.NodeControls.NodeCheckBox nodeCheckBox;
|
||||||
|
@@ -63,6 +63,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
private UpdateVisitor updateVisitor = new UpdateVisitor();
|
private UpdateVisitor updateVisitor = new UpdateVisitor();
|
||||||
private SensorGadget gadget;
|
private SensorGadget gadget;
|
||||||
private Form plotForm;
|
private Form plotForm;
|
||||||
|
private PlotPanel plotPanel;
|
||||||
|
|
||||||
private UserOption showHiddenSensors;
|
private UserOption showHiddenSensors;
|
||||||
private UserOption showPlot;
|
private UserOption showPlot;
|
||||||
@@ -109,7 +110,10 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
this.Font = SystemFonts.MessageBoxFont;
|
this.Font = SystemFonts.MessageBoxFont;
|
||||||
treeView.Font = SystemFonts.MessageBoxFont;
|
treeView.Font = SystemFonts.MessageBoxFont;
|
||||||
plotPanel.Font = SystemFonts.MessageBoxFont;
|
|
||||||
|
plotPanel = new PlotPanel(settings);
|
||||||
|
plotPanel.Font = SystemFonts.MessageBoxFont;
|
||||||
|
plotPanel.Dock = DockStyle.Fill;
|
||||||
|
|
||||||
nodeCheckBox.IsVisibleValueNeeded += nodeCheckBox_IsVisibleValueNeeded;
|
nodeCheckBox.IsVisibleValueNeeded += nodeCheckBox_IsVisibleValueNeeded;
|
||||||
nodeCheckBox.CheckStateChanged += UpdatePlotSelection;
|
nodeCheckBox.CheckStateChanged += UpdatePlotSelection;
|
||||||
|
@@ -46,6 +46,8 @@ using OpenHardwareMonitor.Hardware;
|
|||||||
namespace OpenHardwareMonitor.GUI {
|
namespace OpenHardwareMonitor.GUI {
|
||||||
public class PlotPanel : UserControl {
|
public class PlotPanel : UserControl {
|
||||||
|
|
||||||
|
private PersistentSettings settings;
|
||||||
|
|
||||||
private DateTime now;
|
private DateTime now;
|
||||||
private List<ISensor> clocks = new List<ISensor>();
|
private List<ISensor> clocks = new List<ISensor>();
|
||||||
private List<ISensor> temperatures = new List<ISensor>();
|
private List<ISensor> temperatures = new List<ISensor>();
|
||||||
@@ -58,13 +60,19 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
private Brush lightBrush;
|
private Brush lightBrush;
|
||||||
private Pen lightPen;
|
private Pen lightPen;
|
||||||
|
|
||||||
public PlotPanel() {
|
private UserRadioGroup timeWindowRadioGroup;
|
||||||
|
|
||||||
|
public PlotPanel(PersistentSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
|
||||||
this.SetStyle(ControlStyles.DoubleBuffer |
|
this.SetStyle(ControlStyles.DoubleBuffer |
|
||||||
ControlStyles.UserPaint |
|
ControlStyles.UserPaint |
|
||||||
ControlStyles.AllPaintingInWmPaint |
|
ControlStyles.AllPaintingInWmPaint |
|
||||||
ControlStyles.ResizeRedraw, true);
|
ControlStyles.ResizeRedraw, true);
|
||||||
this.UpdateStyles();
|
this.UpdateStyles();
|
||||||
|
|
||||||
|
CreateContextMenu();
|
||||||
|
|
||||||
centerlower = new StringFormat();
|
centerlower = new StringFormat();
|
||||||
centerlower.Alignment = StringAlignment.Center;
|
centerlower.Alignment = StringAlignment.Center;
|
||||||
centerlower.LineAlignment = StringAlignment.Near;
|
centerlower.LineAlignment = StringAlignment.Near;
|
||||||
@@ -81,6 +89,34 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
lightPen = new Pen(Color.FromArgb(200, 200, 200));
|
lightPen = new Pen(Color.FromArgb(200, 200, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateContextMenu() {
|
||||||
|
MenuItem timeWindow = new MenuItem("Time Scale");
|
||||||
|
|
||||||
|
MenuItem[] timeWindowMenuItems =
|
||||||
|
{ new MenuItem("Auto"),
|
||||||
|
new MenuItem("5 min"),
|
||||||
|
new MenuItem("10 min"),
|
||||||
|
new MenuItem("20 min"),
|
||||||
|
new MenuItem("30 min"),
|
||||||
|
new MenuItem("45 min"),
|
||||||
|
new MenuItem("1 h"),
|
||||||
|
new MenuItem("1.5 h"),
|
||||||
|
new MenuItem("2 h"),
|
||||||
|
new MenuItem("3 h"),
|
||||||
|
new MenuItem("6 h"),
|
||||||
|
new MenuItem("12 h"),
|
||||||
|
new MenuItem("24 h") };
|
||||||
|
|
||||||
|
foreach (MenuItem mi in timeWindowMenuItems)
|
||||||
|
timeWindow.MenuItems.Add(mi);
|
||||||
|
|
||||||
|
timeWindowRadioGroup = new UserRadioGroup("timeWindow", 0,
|
||||||
|
timeWindowMenuItems, settings);
|
||||||
|
|
||||||
|
this.ContextMenu = new ContextMenu();
|
||||||
|
this.ContextMenu.MenuItems.Add(timeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
private List<float> GetTemperatureGrid() {
|
private List<float> GetTemperatureGrid() {
|
||||||
|
|
||||||
float? minTempNullable = null;
|
float? minTempNullable = null;
|
||||||
@@ -125,26 +161,34 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
private List<float> GetTimeGrid() {
|
private List<float> GetTimeGrid() {
|
||||||
|
|
||||||
float maxTime = 5;
|
float maxTime;
|
||||||
if (temperatures.Count > 0) {
|
if (timeWindowRadioGroup.Value == 0) { // Auto
|
||||||
IEnumerator<SensorValue> enumerator =
|
maxTime = 5;
|
||||||
temperatures[0].Values.GetEnumerator();
|
if (temperatures.Count > 0) {
|
||||||
if (enumerator.MoveNext()) {
|
IEnumerator<SensorValue> enumerator =
|
||||||
maxTime = (float)(now - enumerator.Current.Time).TotalMinutes;
|
temperatures[0].Values.GetEnumerator();
|
||||||
|
if (enumerator.MoveNext()) {
|
||||||
|
maxTime = (float)(now - enumerator.Current.Time).TotalMinutes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
float[] maxTimes =
|
||||||
|
{ 5, 10, 20, 30, 45, 60, 90, 120, 180, 360, 720, 1440 };
|
||||||
|
|
||||||
|
maxTime = maxTimes[timeWindowRadioGroup.Value - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int countTime = 10;
|
int countTime = 10;
|
||||||
float deltaTime = 5;
|
float deltaTime = 5;
|
||||||
while (deltaTime + 1 < maxTime && deltaTime < 10)
|
while (deltaTime + 1 <= maxTime && deltaTime < 10)
|
||||||
deltaTime += 1;
|
deltaTime += 1;
|
||||||
while (deltaTime + 2 < maxTime && deltaTime < 30)
|
while (deltaTime + 2 <= maxTime && deltaTime < 30)
|
||||||
deltaTime += 2;
|
deltaTime += 2;
|
||||||
while (deltaTime + 5 < maxTime && deltaTime < 100)
|
while (deltaTime + 5 <= maxTime && deltaTime < 100)
|
||||||
deltaTime += 5;
|
deltaTime += 5;
|
||||||
while (deltaTime + 50 < maxTime && deltaTime < 1000)
|
while (deltaTime + 50 <= maxTime && deltaTime < 1000)
|
||||||
deltaTime += 50;
|
deltaTime += 50;
|
||||||
while (deltaTime + 100 < maxTime && deltaTime < 10000)
|
while (deltaTime + 100 <= maxTime && deltaTime < 10000)
|
||||||
deltaTime += 100;
|
deltaTime += 100;
|
||||||
|
|
||||||
List<float> grid = new List<float>(countTime + 1);
|
List<float> grid = new List<float>(countTime + 1);
|
||||||
|
Reference in New Issue
Block a user