[2754] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17180] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2754] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[13586] | 22 | using System.Drawing;
|
---|
[8818] | 23 | using System.Linq;
|
---|
[2931] | 24 | using System.Windows.Forms;
|
---|
[8076] | 25 | using HeuristicLab.Clients.Access;
|
---|
[6827] | 26 | using HeuristicLab.Optimizer.Properties;
|
---|
[2754] | 27 | using HeuristicLab.PluginInfrastructure;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Optimizer {
|
---|
[17184] | 30 | [Plugin("HeuristicLab.Optimizer", "3.3.16.$WCREV$")]
|
---|
[2754] | 31 | [PluginFile("HeuristicLab.Optimizer-3.3.dll", PluginFileType.Assembly)]
|
---|
[17023] | 32 | [PluginDependency("HeuristicLab.Attic", "1.0")]
|
---|
[16658] | 33 | [PluginDependency("HeuristicLab.Clients.Access", "3.3")]
|
---|
[4387] | 34 | [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
|
---|
[4650] | 35 | [PluginDependency("HeuristicLab.Collections", "3.3")]
|
---|
[3384] | 36 | [PluginDependency("HeuristicLab.Common", "3.3")]
|
---|
[3702] | 37 | [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
|
---|
[2754] | 38 | [PluginDependency("HeuristicLab.Core", "3.3")]
|
---|
| 39 | [PluginDependency("HeuristicLab.Core.Views", "3.3")]
|
---|
[7908] | 40 | [PluginDependency("HeuristicLab.Data", "3.3")]
|
---|
[7985] | 41 | [PluginDependency("HeuristicLab.Data.Views", "3.3")]
|
---|
[3437] | 42 | [PluginDependency("HeuristicLab.MainForm", "3.3")]
|
---|
| 43 | [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
|
---|
[3759] | 44 | [PluginDependency("HeuristicLab.Optimization", "3.3")]
|
---|
[7908] | 45 | [PluginDependency("HeuristicLab.Parameters", "3.3")]
|
---|
[7841] | 46 | [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
|
---|
[2754] | 47 | public class HeuristicLabOptimizerPlugin : PluginBase {
|
---|
| 48 | }
|
---|
[2931] | 49 |
|
---|
[17183] | 50 | [Application("Optimizer", "HeuristicLab Optimizer 3.3.16.$WCREV$")]
|
---|
[2931] | 51 | internal class HeuristicLabOptimizerApplication : ApplicationBase {
|
---|
[8818] | 52 | public override void Run(ICommandLineArgument[] args) {
|
---|
| 53 | HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null;
|
---|
[6827] | 54 |
|
---|
| 55 | if (Settings.Default.MainFormType == OptimizerMainFormTypes.DockingMainForm) {
|
---|
| 56 | mainForm = new OptimizerDockingMainForm(typeof(IOptimizerUserInterfaceItemProvider));
|
---|
| 57 | } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.MultipleDocumentMainForm) {
|
---|
| 58 | mainForm = new OptimizerMultipleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
|
---|
| 59 | } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.SingleDocumentMainForm) {
|
---|
| 60 | mainForm = new OptimizerSingleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
|
---|
| 61 | }
|
---|
| 62 |
|
---|
[13586] | 63 | if (mainForm != null) {
|
---|
| 64 | if (CheckSavedMainFormSettings()) {
|
---|
| 65 | mainForm.Location = Settings.Default.MainFormLocation;
|
---|
| 66 | mainForm.Size = Settings.Default.MainFormSize;
|
---|
[13567] | 67 | mainForm.WindowState = Settings.Default.MainFormWindowState;
|
---|
[13586] | 68 | }
|
---|
[13567] | 69 |
|
---|
| 70 | mainForm.FormClosing += (sender, eventArgs) => {
|
---|
[13586] | 71 | if (mainForm.WindowState != FormWindowState.Minimized)
|
---|
| 72 | Settings.Default.MainFormWindowState = mainForm.WindowState;
|
---|
[13567] | 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 |
|
---|
[8076] | 83 | ClientInformation.InitializeAsync();
|
---|
| 84 | UserInformation.InitializeAsync();
|
---|
| 85 |
|
---|
[6827] | 86 | mainForm.ShowContentInViewHost = true;
|
---|
[8821] | 87 | var filesToOpen = args.OfType<OpenArgument>().Select(x => x.Value);
|
---|
[8818] | 88 | mainForm.Load += (sender, eventArgs) => FileManager.OpenFiles(filesToOpen);
|
---|
[6827] | 89 | Application.Run(mainForm);
|
---|
| 90 | } else {
|
---|
| 91 | MessageBox.Show("Error loading setting for the MainForm Type. Please check your configuration file!", "HeuristicLab", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
| 92 | }
|
---|
[2931] | 93 | }
|
---|
[13586] | 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 | }
|
---|
[2931] | 102 | }
|
---|
[2754] | 103 | }
|
---|