Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerSingleDocumentMainForm.cs @ 7005

Last change on this file since 7005 was 6935, checked in by ascheibe, 13 years ago

#1652 fixed a bug when saving a file in SD or MD mode

File size: 3.9 KB
RevLine 
[6827]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using System.ComponentModel;
24using System.Linq;
25using System.Windows.Forms;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Core.Views;
29using HeuristicLab.MainForm;
30using HeuristicLab.MainForm.WindowsForms;
31
32namespace HeuristicLab.Optimizer {
33  internal partial class OptimizerSingleDocumentMainForm : SingleDocumentMainForm {
34
35    private Clipboard<IItem> clipboard;
36    public Clipboard<IItem> Clipboard {
37      get { return clipboard; }
38    }
39
40    public OptimizerSingleDocumentMainForm()
41      : base() {
42      InitializeComponent();
43    }
44    public OptimizerSingleDocumentMainForm(Type userInterfaceItemType)
45      : base(userInterfaceItemType) {
46      InitializeComponent();
47    }
48    public OptimizerSingleDocumentMainForm(Type userInterfaceItemType, bool showContentInViewHost)
49      : this(userInterfaceItemType) {
50      this.ShowContentInViewHost = showContentInViewHost;
51    }
52
53    protected override void OnInitialized(EventArgs e) {
54      base.OnInitialized(e);
55
56      ContentManager.Initialize(new PersistenceContentManager());
57
58      clipboard = new Clipboard<IItem>();
59      clipboard.Dock = DockStyle.Left;
60      clipboard.Collapsed = Properties.Settings.Default.CollapseClipboard;
61      if (Properties.Settings.Default.ShowClipboard) {
62        clipboard.Show();
63      }
64      if (Properties.Settings.Default.ShowOperatorsSidebar) {
65        OperatorsSidebar operatorsSidebar = new OperatorsSidebar();
66        operatorsSidebar.Dock = DockStyle.Left;
67        operatorsSidebar.Show();
68        operatorsSidebar.Collapsed = Properties.Settings.Default.CollapseOperatorsSidebar;
69      }
70      if (Properties.Settings.Default.ShowStartPage) {
71        StartPage startPage = new StartPage();
72        startPage.Show();
73      }
74
75      WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
76    }
77
78    protected override void OnClosing(CancelEventArgs e) {
79      base.OnClosing(e);
80      if (MainFormManager.MainForm.Views.OfType<IContentView>().FirstOrDefault() != null) {
81        if (MessageBox.Show(this, "Some views are still opened. If their content has not been saved, it will be lost after closing. Do you really want to close HeuristicLab Optimizer?", "Close Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
82          e.Cancel = true;
83      }
84    }
85    protected override void OnClosed(EventArgs e) {
86      base.OnClosed(e);
87      Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized;
88      Properties.Settings.Default.CollapseClipboard = clipboard.Collapsed;
89      OperatorsSidebar operatorsSidebar = MainFormManager.MainForm.Views.OfType<OperatorsSidebar>().FirstOrDefault();
90      if (operatorsSidebar != null) Properties.Settings.Default.CollapseOperatorsSidebar = operatorsSidebar.Collapsed;
91      Properties.Settings.Default.Save();
92    }
93
94    protected override void OnActiveViewChanged() {
95      base.OnActiveViewChanged();
96      UpdateTitle();
97    }
98  }
99}
Note: See TracBrowser for help on using the repository browser.