Added an option to show the plot in a separate window or on the right of the tree-view.
This commit is contained in:
Generated
+35
-2
@@ -110,6 +110,10 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
|
||||
this.treeView = new Aga.Controls.Tree.TreeViewAdv();
|
||||
this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel();
|
||||
this.plotLocationMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.plotWindowMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.plotBottomMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.plotRightMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
this.splitContainer.SuspendLayout();
|
||||
@@ -326,6 +330,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.startupMenuItem,
|
||||
this.separatorMenuItem,
|
||||
this.temperatureUnitsMenuItem,
|
||||
this.plotLocationMenuItem,
|
||||
this.MenuItem4,
|
||||
this.hddMenuItem});
|
||||
this.optionsMenuItem.Text = "Options";
|
||||
@@ -377,12 +382,12 @@ namespace OpenHardwareMonitor.GUI {
|
||||
//
|
||||
// MenuItem4
|
||||
//
|
||||
this.MenuItem4.Index = 6;
|
||||
this.MenuItem4.Index = 7;
|
||||
this.MenuItem4.Text = "-";
|
||||
//
|
||||
// hddMenuItem
|
||||
//
|
||||
this.hddMenuItem.Index = 7;
|
||||
this.hddMenuItem.Index = 8;
|
||||
this.hddMenuItem.Text = "Read HDD sensors";
|
||||
//
|
||||
// helpMenuItem
|
||||
@@ -475,6 +480,30 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.plotPanel.Size = new System.Drawing.Size(386, 124);
|
||||
this.plotPanel.TabIndex = 0;
|
||||
//
|
||||
// plotLocationMenuItem
|
||||
//
|
||||
this.plotLocationMenuItem.Index = 6;
|
||||
this.plotLocationMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.plotWindowMenuItem,
|
||||
this.plotBottomMenuItem,
|
||||
this.plotRightMenuItem});
|
||||
this.plotLocationMenuItem.Text = "Plot Location";
|
||||
//
|
||||
// plotWindowMenuItem
|
||||
//
|
||||
this.plotWindowMenuItem.Index = 0;
|
||||
this.plotWindowMenuItem.Text = "Window";
|
||||
//
|
||||
// plotBottomMenuItem
|
||||
//
|
||||
this.plotBottomMenuItem.Index = 1;
|
||||
this.plotBottomMenuItem.Text = "Bottom";
|
||||
//
|
||||
// plotRightMenuItem
|
||||
//
|
||||
this.plotRightMenuItem.Index = 2;
|
||||
this.plotRightMenuItem.Text = "Right";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -547,6 +576,10 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private System.Windows.Forms.MenuItem minCloseMenuItem;
|
||||
private System.Windows.Forms.MenuItem resetMenuItem;
|
||||
private System.Windows.Forms.MenuItem menuItem6;
|
||||
private System.Windows.Forms.MenuItem plotLocationMenuItem;
|
||||
private System.Windows.Forms.MenuItem plotWindowMenuItem;
|
||||
private System.Windows.Forms.MenuItem plotBottomMenuItem;
|
||||
private System.Windows.Forms.MenuItem plotRightMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+98
-8
@@ -62,6 +62,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private StartupManager startupManager = new StartupManager();
|
||||
private UpdateVisitor updateVisitor = new UpdateVisitor();
|
||||
private SensorGadget gadget;
|
||||
private Form plotForm;
|
||||
|
||||
private UserOption showHiddenSensors;
|
||||
private UserOption showPlot;
|
||||
@@ -74,6 +75,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private UserOption autoStart;
|
||||
private UserOption readHddSensors;
|
||||
private UserOption showGadget;
|
||||
private UserRadioGroup plotLocation;
|
||||
|
||||
private WmiProvider wmiProvider;
|
||||
|
||||
@@ -149,8 +151,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
gadget.HideShowCommand += hideShowClick;
|
||||
|
||||
wmiProvider = new WmiProvider(computer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
|
||||
computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
|
||||
|
||||
@@ -179,12 +181,6 @@ namespace OpenHardwareMonitor.GUI {
|
||||
treeModel.ForceVisible = showHiddenSensors.Value;
|
||||
};
|
||||
|
||||
showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
|
||||
showPlot.Changed += delegate(object sender, EventArgs e) {
|
||||
splitContainer.Panel2Collapsed = !showPlot.Value;
|
||||
treeView.Invalidate();
|
||||
};
|
||||
|
||||
showValue = new UserOption("valueMenuItem", true, valueMenuItem,
|
||||
settings);
|
||||
showValue.Changed += delegate(object sender, EventArgs e) {
|
||||
@@ -243,6 +239,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
unitManager.TemperatureUnit == TemperatureUnit.Celcius;
|
||||
fahrenheitMenuItem.Checked = !celciusMenuItem.Checked;
|
||||
|
||||
InitializePlotForm();
|
||||
|
||||
startupMenuItem.Visible = startupManager.IsAvailable;
|
||||
|
||||
if (startMinMenuItem.Checked) {
|
||||
@@ -262,6 +260,98 @@ namespace OpenHardwareMonitor.GUI {
|
||||
SaveConfiguration();
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializePlotForm() {
|
||||
plotForm = new Form();
|
||||
plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
|
||||
plotForm.ShowInTaskbar = false;
|
||||
plotForm.StartPosition = FormStartPosition.Manual;
|
||||
this.AddOwnedForm(plotForm);
|
||||
plotForm.Bounds = new Rectangle {
|
||||
X = settings.GetValue("plotForm.Location.X", -100000),
|
||||
Y = settings.GetValue("plotForm.Location.Y", 100),
|
||||
Width = settings.GetValue("plotForm.Width", 600),
|
||||
Height = settings.GetValue("plotForm.Height", 400)
|
||||
};
|
||||
|
||||
showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
|
||||
plotLocation = new UserRadioGroup("plotLocation", 0,
|
||||
new[] { plotWindowMenuItem, plotBottomMenuItem, plotRightMenuItem },
|
||||
settings);
|
||||
|
||||
showPlot.Changed += delegate(object sender, EventArgs e) {
|
||||
if (plotLocation.Value == 0) {
|
||||
if (showPlot.Value && this.Visible)
|
||||
plotForm.Show();
|
||||
else
|
||||
plotForm.Hide();
|
||||
} else {
|
||||
splitContainer.Panel2Collapsed = !showPlot.Value;
|
||||
}
|
||||
treeView.Invalidate();
|
||||
};
|
||||
plotLocation.Changed += delegate(object sender, EventArgs e) {
|
||||
switch (plotLocation.Value) {
|
||||
case 0:
|
||||
splitContainer.Panel2.Controls.Clear();
|
||||
splitContainer.Panel2Collapsed = true;
|
||||
plotForm.Controls.Add(plotPanel);
|
||||
if (showPlot.Value && this.Visible)
|
||||
plotForm.Show();
|
||||
break;
|
||||
case 1:
|
||||
plotForm.Controls.Clear();
|
||||
plotForm.Hide();
|
||||
splitContainer.Orientation = Orientation.Horizontal;
|
||||
splitContainer.Panel2.Controls.Add(plotPanel);
|
||||
splitContainer.Panel2Collapsed = !showPlot.Value;
|
||||
break;
|
||||
case 2:
|
||||
plotForm.Controls.Clear();
|
||||
plotForm.Hide();
|
||||
splitContainer.Orientation = Orientation.Vertical;
|
||||
splitContainer.Panel2.Controls.Add(plotPanel);
|
||||
splitContainer.Panel2Collapsed = !showPlot.Value;
|
||||
break;
|
||||
}
|
||||
};
|
||||
plotForm.Closing += delegate(object sender, CancelEventArgs e) {
|
||||
if (plotLocation.Value == 0) {
|
||||
showPlot.Value = false;
|
||||
}
|
||||
e.Cancel = true;
|
||||
};
|
||||
EventHandler moveOrResizePlotForm = delegate(object sender, EventArgs e) {
|
||||
if (plotForm.WindowState != FormWindowState.Minimized) {
|
||||
settings.SetValue("plotForm.Location.X", plotForm.Bounds.X);
|
||||
settings.SetValue("plotForm.Location.Y", plotForm.Bounds.Y);
|
||||
settings.SetValue("plotForm.Width", plotForm.Bounds.Width);
|
||||
settings.SetValue("plotForm.Height", plotForm.Bounds.Height);
|
||||
}
|
||||
};
|
||||
plotForm.Move += moveOrResizePlotForm;
|
||||
plotForm.Resize += moveOrResizePlotForm;
|
||||
|
||||
plotForm.VisibleChanged += delegate(object sender, EventArgs e) {
|
||||
Rectangle bounds = new Rectangle(plotForm.Location, plotForm.Size);
|
||||
Screen screen = Screen.FromRectangle(bounds);
|
||||
Rectangle intersection =
|
||||
Rectangle.Intersect(screen.WorkingArea, bounds);
|
||||
if (intersection.Width < Math.Min(16, bounds.Width) ||
|
||||
intersection.Height < Math.Min(16, bounds.Height)) {
|
||||
plotForm.Location = new Point(
|
||||
screen.WorkingArea.Width / 2 - bounds.Width / 2,
|
||||
screen.WorkingArea.Height / 2 - bounds.Height / 2);
|
||||
}
|
||||
};
|
||||
|
||||
this.VisibleChanged += delegate(object sender, EventArgs e) {
|
||||
if (this.Visible && showPlot.Value && plotLocation.Value == 0)
|
||||
plotForm.Show();
|
||||
else
|
||||
plotForm.Hide();
|
||||
};
|
||||
}
|
||||
|
||||
private void SubHardwareAdded(IHardware hardware, Node node) {
|
||||
Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Open Hardware Monitor code.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael Möller <m.moeller@gmx.ch>.
|
||||
Portions created by the Initial Developer are Copyright (C) 20011
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class UserRadioGroup {
|
||||
private string name;
|
||||
private int value;
|
||||
private MenuItem[] menuItems;
|
||||
private event EventHandler changed;
|
||||
private PersistentSettings settings;
|
||||
|
||||
public UserRadioGroup(string name, int value,
|
||||
MenuItem[] menuItems, PersistentSettings settings) {
|
||||
this.settings = settings;
|
||||
this.name = name;
|
||||
if (name != null)
|
||||
this.value = settings.GetValue(name, value);
|
||||
else
|
||||
this.value = value;
|
||||
this.menuItems = menuItems;
|
||||
this.value = Math.Max(Math.Min(this.value, menuItems.Length - 1), 0);
|
||||
|
||||
for (int i = 0; i < this.menuItems.Length; i++) {
|
||||
this.menuItems[i].Checked = i == this.value;
|
||||
int index = i;
|
||||
this.menuItems[i].Click += delegate(object sender, EventArgs e) {
|
||||
this.Value = index;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public int Value {
|
||||
get { return value; }
|
||||
set {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
if (this.name != null)
|
||||
settings.SetValue(name, value);
|
||||
for (int i = 0; i < this.menuItems.Length; i++)
|
||||
this.menuItems[i].Checked = i == value;
|
||||
if (changed != null)
|
||||
changed(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler Changed {
|
||||
add {
|
||||
changed += value;
|
||||
if (changed != null)
|
||||
changed(this, null);
|
||||
}
|
||||
remove {
|
||||
changed -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user