#region License Information /* HeuristicLab * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Windows.Forms; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.MainForm; using HeuristicLab.MainForm.WindowsForms; namespace HeuristicLab.Modeler { internal partial class ModelerDockingMainForm : DockingMainForm { private string title; public ModelerDockingMainForm() : base() { InitializeComponent(); } public ModelerDockingMainForm(Type userInterfaceItemType) : base(userInterfaceItemType) { InitializeComponent(); } public ModelerDockingMainForm(Type userInterfaceItemType, bool showContentInViewHost) : this(userInterfaceItemType) { this.ShowContentInViewHost = showContentInViewHost; } protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); AssemblyFileVersionAttribute version = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true). Cast().FirstOrDefault(); title = "HeuristicLab Modeler"; if (version != null) title += " " + version.Version; Title = title; ContentManager.Initialize(new PersistenceContentManager()); WindowState = Properties.Settings.Default.ShowMaximized ? FormWindowState.Maximized : FormWindowState.Normal; } protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); if (MainFormManager.MainForm.Views.OfType().Any(v=>v.Content is IStorableContent)) { 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) e.Cancel = true; } } protected override void OnClosed(EventArgs e) { base.OnClosed(e); Properties.Settings.Default.ShowMaximized = WindowState == FormWindowState.Maximized; Properties.Settings.Default.Save(); } protected override void OnActiveViewChanged() { base.OnActiveViewChanged(); UpdateTitle(); } public override void UpdateTitle() { if (InvokeRequired) Invoke(new Action(UpdateTitle)); else { IContentView activeView = ActiveView as IContentView; if ((activeView != null) && (activeView.Content is IStorableContent)) { IStorableContent content = (IStorableContent)activeView.Content; Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]"; } else { Title = title; } } } } }