Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/08/16 15:29:05 (8 years ago)
Author:
mkommend
Message:

#2567: Merged r13567 and r13586 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimizer

  • stable/HeuristicLab.Optimizer/3.3/Plugin.cs.frame

    r13316 r13884  
    2020#endregion
    2121
     22using System.Drawing;
    2223using System.Linq;
    2324using System.Windows.Forms;
     
    6162
    6263      if (mainForm != null) {
     64        if (CheckSavedMainFormSettings()) {
     65          mainForm.Location = Settings.Default.MainFormLocation;
     66          mainForm.Size = Settings.Default.MainFormSize;
     67          mainForm.WindowState = Settings.Default.MainFormWindowState;
     68        }
     69
     70        mainForm.FormClosing += (sender, eventArgs) => {
     71          if (mainForm.WindowState != FormWindowState.Minimized)
     72            Settings.Default.MainFormWindowState = mainForm.WindowState;
     73          if (mainForm.WindowState != FormWindowState.Normal) {
     74            Settings.Default.MainFormLocation = mainForm.RestoreBounds.Location;
     75            Settings.Default.MainFormSize = mainForm.RestoreBounds.Size;
     76          } else if (mainForm.WindowState == FormWindowState.Normal) {
     77            Settings.Default.MainFormLocation = mainForm.Location;
     78            Settings.Default.MainFormSize = mainForm.Size;
     79          }
     80        };
     81
     82
    6383        ClientInformation.InitializeAsync();
    6484        UserInformation.InitializeAsync();
     
    7292      }
    7393    }
     94
     95    private bool CheckSavedMainFormSettings() {
     96      var formArea = new Rectangle(Settings.Default.MainFormLocation, Settings.Default.MainFormSize);
     97      var screenArea = Screen.FromRectangle(formArea).WorkingArea;
     98      var overlappingArea = Rectangle.Intersect(formArea, screenArea);
     99      bool offLimits = overlappingArea.IsEmpty || overlappingArea.Width * overlappingArea.Height < formArea.Width * formArea.Height * 0.25;
     100      return !formArea.IsEmpty && !offLimits;
     101    }
    74102  }
    75103}
Note: See TracChangeset for help on using the changeset viewer.