[11063] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[11401] | 3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[11063] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.ComponentModel;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Reflection;
|
---|
| 26 | using System.Windows.Forms;
|
---|
| 27 | using HeuristicLab.Common;
|
---|
| 28 | using HeuristicLab.Core;
|
---|
| 29 | using HeuristicLab.MainForm;
|
---|
| 30 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 31 |
|
---|
| 32 | namespace HeuristicLab.Modeler {
|
---|
| 33 | internal partial class ModelerDockingMainForm : DockingMainForm {
|
---|
| 34 | private string title;
|
---|
| 35 |
|
---|
| 36 | public ModelerDockingMainForm()
|
---|
| 37 | : base() {
|
---|
| 38 | InitializeComponent();
|
---|
| 39 | }
|
---|
| 40 | public ModelerDockingMainForm(Type userInterfaceItemType)
|
---|
| 41 | : base(userInterfaceItemType) {
|
---|
| 42 | InitializeComponent();
|
---|
| 43 | }
|
---|
| 44 | public ModelerDockingMainForm(Type userInterfaceItemType, bool showContentInViewHost)
|
---|
| 45 | : this(userInterfaceItemType) {
|
---|
| 46 | this.ShowContentInViewHost = showContentInViewHost;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | protected override void OnInitialized(EventArgs e) {
|
---|
| 50 | base.OnInitialized(e);
|
---|
| 51 |
|
---|
| 52 | AssemblyFileVersionAttribute version = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).
|
---|
| 53 | Cast<AssemblyFileVersionAttribute>().FirstOrDefault();
|
---|
| 54 | title = "HeuristicLab Modeler";
|
---|
| 55 | if (version != null) title += " " + version.Version;
|
---|
| 56 | Title = title;
|
---|
| 57 |
|
---|
| 58 | ContentManager.Initialize(new PersistenceContentManager());
|
---|
| 59 |
|
---|
| 60 | WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | protected override void OnClosing(CancelEventArgs e) {
|
---|
| 64 | base.OnClosing(e);
|
---|
| 65 | if (MainFormManager.MainForm.Views.OfType<IContentView>().Any(v=>v.Content is IStorableContent)) {
|
---|
| 66 | 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 Modeler?", "Close Modeler", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
|
---|
| 67 | e.Cancel = true;
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | protected override void OnClosed(EventArgs e) {
|
---|
| 71 | base.OnClosed(e);
|
---|
| 72 | Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized;
|
---|
| 73 | Properties.Settings.Default.Save();
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | protected override void OnActiveViewChanged() {
|
---|
| 77 | base.OnActiveViewChanged();
|
---|
| 78 | UpdateTitle();
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | public override void UpdateTitle() {
|
---|
| 82 | if (InvokeRequired)
|
---|
| 83 | Invoke(new Action(UpdateTitle));
|
---|
| 84 | else {
|
---|
| 85 | IContentView activeView = ActiveView as IContentView;
|
---|
| 86 | if ((activeView != null) && (activeView.Content is IStorableContent)) {
|
---|
| 87 | IStorableContent content = (IStorableContent)activeView.Content;
|
---|
| 88 | Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]";
|
---|
| 89 | } else {
|
---|
| 90 | Title = title;
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 | }
|
---|