예제 #1
0
        public override void Run(ICommandLineArgument[] args)
        {
            HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null;

            if (Settings.Default.MainFormType == OptimizerMainFormTypes.DockingMainForm)
            {
                mainForm = new OptimizerDockingMainForm(typeof(IOptimizerUserInterfaceItemProvider));
            }
            else if (Settings.Default.MainFormType == OptimizerMainFormTypes.MultipleDocumentMainForm)
            {
                mainForm = new OptimizerMultipleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
            }
            else if (Settings.Default.MainFormType == OptimizerMainFormTypes.SingleDocumentMainForm)
            {
                mainForm = new OptimizerSingleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
            }

            if (mainForm != null)
            {
                ClientInformation.InitializeAsync();
                UserInformation.InitializeAsync();

                mainForm.ShowContentInViewHost = true;
                var filesToOpen = args.OfType <OpenArgument>().Select(x => x.Value);
                mainForm.Load += (sender, eventArgs) => FileManager.OpenFiles(filesToOpen);
                Application.Run(mainForm);
            }
            else
            {
                MessageBox.Show("Error loading setting for the MainForm Type. Please check your configuration file!", "HeuristicLab", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
    public override void Run(ICommandLineArgument[] args) {
      HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null;

      if (Settings.Default.MainFormType == OptimizerMainFormTypes.DockingMainForm) {
        mainForm = new OptimizerDockingMainForm(typeof(IOptimizerUserInterfaceItemProvider));
      } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.MultipleDocumentMainForm) {
        mainForm = new OptimizerMultipleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
      } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.SingleDocumentMainForm) {
        mainForm = new OptimizerSingleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
      }

      if (mainForm != null) {
        if (CheckSavedMainFormSettings()) {
          mainForm.Location = Settings.Default.MainFormLocation;
          mainForm.Size = Settings.Default.MainFormSize;
          mainForm.WindowState = Settings.Default.MainFormWindowState;
        }

        mainForm.FormClosing += (sender, eventArgs) => {
          if (mainForm.WindowState != FormWindowState.Minimized)
            Settings.Default.MainFormWindowState = mainForm.WindowState;
          if (mainForm.WindowState != FormWindowState.Normal) {
            Settings.Default.MainFormLocation = mainForm.RestoreBounds.Location;
            Settings.Default.MainFormSize = mainForm.RestoreBounds.Size;
          } else if (mainForm.WindowState == FormWindowState.Normal) {
            Settings.Default.MainFormLocation = mainForm.Location;
            Settings.Default.MainFormSize = mainForm.Size;
          }
        };


        ClientInformation.InitializeAsync();
        UserInformation.InitializeAsync();

        mainForm.ShowContentInViewHost = true;
        var filesToOpen = args.OfType<OpenArgument>().Select(x => x.Value);
        mainForm.Load += (sender, eventArgs) => FileManager.OpenFiles(filesToOpen);
        Application.Run(mainForm);
      } else {
        MessageBox.Show("Error loading setting for the MainForm Type. Please check your configuration file!", "HeuristicLab", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
    }