Fixed Issue 123.
authorpaulwerelds
Tue, 05 Oct 2010 19:34:59 +0000
changeset 213d93c927e4fd6
parent 212 7e98c9e1a4f4
child 214 9ddbb54998ac
Fixed Issue 123.
GUI/MainForm.cs
     1.1 --- a/GUI/MainForm.cs	Tue Oct 05 19:27:51 2010 +0000
     1.2 +++ b/GUI/MainForm.cs	Tue Oct 05 19:34:59 2010 +0000
     1.3 @@ -100,19 +100,25 @@
     1.4        nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
     1.5        nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
     1.6  
     1.7 -      if (settings.Contains("mainForm.Location.X")) {
     1.8 -        int x = settings.GetValue("mainForm.Location.X", Location.X);
     1.9 -        x = x < 0 ? 0 : x;
    1.10 -        int y = settings.GetValue("mainForm.Location.Y", Location.Y);
    1.11 -        y = y < 0 ? 0 : y;
    1.12 -        this.Location = new Point(x, y);
    1.13 -      } else {
    1.14 -        StartPosition = FormStartPosition.CenterScreen;
    1.15 -      }
    1.16 +      Rectangle newBounds = new Rectangle {
    1.17 +        X = settings.GetValue("mainForm.Location.X", Location.X),
    1.18 +        Y = settings.GetValue("mainForm.Location.Y", Location.Y),
    1.19 +        Width = settings.GetValue("mainForm.Width", 470),
    1.20 +        Height = settings.GetValue("mainForm.Height", 640)
    1.21 +      };
    1.22  
    1.23 -      ClientSize = new Size(
    1.24 -        settings.GetValue("mainForm.Width", 470),
    1.25 -        settings.GetValue("mainForm.Height", 640));
    1.26 +      Screen[] screens = Screen.AllScreens;
    1.27 +      Rectangle totalWorkingArea = new Rectangle(int.MaxValue, int.MaxValue,
    1.28 +        int.MinValue, int.MinValue);
    1.29 +
    1.30 +      foreach(Screen screen in screens)
    1.31 +        totalWorkingArea = Rectangle.Union(totalWorkingArea, screen.Bounds);
    1.32 +
    1.33 +      this.Bounds = newBounds;
    1.34 +
    1.35 +      if (!totalWorkingArea.Contains(newBounds) ||
    1.36 +        !settings.Contains("mainForm.Location.X"))
    1.37 +        this.StartPosition = FormStartPosition.CenterScreen;
    1.38  
    1.39        foreach (TreeColumn column in treeView.Columns) 
    1.40          column.Width = Math.Max(20, Math.Min(400,