Fixed Issue 215.

This commit is contained in:
Michael Möller
2011-05-16 22:04:04 +00:00
parent c62fb23f99
commit 9805d4cf52
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -176,12 +176,16 @@ namespace OpenHardwareMonitor.GUI {
set {
if (value != window.Visible) {
window.Visible = value;
if (VisibleChanged != null)
VisibleChanged(this, EventArgs.Empty);
if (value)
Redraw();
}
}
}
public event EventHandler VisibleChanged;
public void Redraw() {
if (!window.Visible)
return;
+14
View File
@@ -201,6 +201,20 @@ namespace OpenHardwareMonitor.GUI {
Redraw();
};
VisibleChanged += delegate(object sender, EventArgs e) {
Rectangle bounds = new Rectangle(Location, 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))
{
Location = new Point(
screen.WorkingArea.Width / 2 - bounds.Width / 2,
screen.WorkingArea.Height / 2 - bounds.Height / 2);
}
};
MouseDoubleClick += delegate(object obj, MouseEventArgs args) {
SendHideShowCommand();
};