# HG changeset patch
# User paulwerelds
# Date 1286307299 0
# Node ID d93c927e4fd60f73eca5b52f6d3264f67709fac6
# Parent  7e98c9e1a4f4b7abf9a0537384b709f252d141fc
Fixed Issue 123.

diff -r 7e98c9e1a4f4 -r d93c927e4fd6 GUI/MainForm.cs
--- a/GUI/MainForm.cs	Tue Oct 05 19:27:51 2010 +0000
+++ b/GUI/MainForm.cs	Tue Oct 05 19:34:59 2010 +0000
@@ -100,19 +100,25 @@
       nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
       nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
 
-      if (settings.Contains("mainForm.Location.X")) {
-        int x = settings.GetValue("mainForm.Location.X", Location.X);
-        x = x < 0 ? 0 : x;
-        int y = settings.GetValue("mainForm.Location.Y", Location.Y);
-        y = y < 0 ? 0 : y;
-        this.Location = new Point(x, y);
-      } else {
-        StartPosition = FormStartPosition.CenterScreen;
-      }
+      Rectangle newBounds = new Rectangle {
+        X = settings.GetValue("mainForm.Location.X", Location.X),
+        Y = settings.GetValue("mainForm.Location.Y", Location.Y),
+        Width = settings.GetValue("mainForm.Width", 470),
+        Height = settings.GetValue("mainForm.Height", 640)
+      };
 
-      ClientSize = new Size(
-        settings.GetValue("mainForm.Width", 470),
-        settings.GetValue("mainForm.Height", 640));
+      Screen[] screens = Screen.AllScreens;
+      Rectangle totalWorkingArea = new Rectangle(int.MaxValue, int.MaxValue,
+        int.MinValue, int.MinValue);
+
+      foreach(Screen screen in screens)
+        totalWorkingArea = Rectangle.Union(totalWorkingArea, screen.Bounds);
+
+      this.Bounds = newBounds;
+
+      if (!totalWorkingArea.Contains(newBounds) ||
+        !settings.Contains("mainForm.Location.X"))
+        this.StartPosition = FormStartPosition.CenterScreen;
 
       foreach (TreeColumn column in treeView.Columns) 
         column.Width = Math.Max(20, Math.Min(400,