Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerMainForm.cs @ 3514

Last change on this file since 3514 was 3483, checked in by swagner, 14 years ago

Worked on the refactoring of saving and loading items (#990)

File size: 4.6 KB
RevLine 
[2790]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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;
[2931]23using System.Linq;
[2547]24using System.Reflection;
25using System.Windows.Forms;
[3376]26using HeuristicLab.Common;
[3298]27using HeuristicLab.Core;
[2790]28using HeuristicLab.Core.Views;
[2547]29using HeuristicLab.MainForm;
30using HeuristicLab.MainForm.WindowsForms;
31
32namespace HeuristicLab.Optimizer {
33  internal partial class OptimizerMainForm : DockingMainForm {
[3483]34    private string title;
35    private int appStartingCursors;
36    private int waitingCursors;
37
[3298]38    private Clipboard<IItem> clipboard;
39    public Clipboard<IItem> Clipboard {
[3292]40      get { return clipboard; }
41    }
42
[2547]43    public OptimizerMainForm()
44      : base() {
45      InitializeComponent();
[3483]46      appStartingCursors = 0;
47      waitingCursors = 0;
[2547]48    }
49    public OptimizerMainForm(Type userInterfaceItemType)
50      : base(userInterfaceItemType) {
51      InitializeComponent();
[3483]52      appStartingCursors = 0;
53      waitingCursors = 0;
[2547]54    }
[3395]55    public OptimizerMainForm(Type userInterfaceItemType, bool showViewsInViewHost)
[3394]56      : this(userInterfaceItemType) {
[3395]57      this.ShowViewsInViewHost = showViewsInViewHost;
[3394]58    }
[2547]59
[2791]60    protected override void OnInitialized(EventArgs e) {
61      base.OnInitialized(e);
[2931]62      AssemblyFileVersionAttribute version = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).
63                                             Cast<AssemblyFileVersionAttribute>().FirstOrDefault();
[3483]64      title = "HeuristicLab Optimizer";
65      if (version != null) title += " " + version.Version;
66      Title = title;
[3292]67
[3483]68      ContentManager.Initialize(new PersistenceContentManager());
69
[3298]70      clipboard = new Clipboard<IItem>();
[3292]71      clipboard.Dock = DockStyle.Left;
72      if (Properties.Settings.Default.ShowClipboard) {
73        clipboard.Show();
74      }
[3290]75      if (Properties.Settings.Default.ShowOperatorsSidebar) {
76        OperatorsSidebar operatorsSidebar = new OperatorsSidebar();
77        operatorsSidebar.Dock = DockStyle.Left;
78        operatorsSidebar.Show();
79      }
[3163]80      if (Properties.Settings.Default.ShowStartPage) {
81        StartPage startPage = new StartPage();
82        startPage.Show();
83      }
[2547]84    }
[3483]85
86    protected override void OnActiveViewChanged() {
87      base.OnActiveViewChanged();
88      UpdateTitle();
89    }
90
91    public void UpdateTitle() {
92      if (InvokeRequired)
93        Invoke(new Action(UpdateTitle));
94      else {
95        IContentView activeView = ActiveView as IContentView;
96        if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IStorableContent)) {
97          IStorableContent content = (IStorableContent)activeView.Content;
98          Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]";
99        } else {
100          Title = title;
101        }
102      }
103    }
104
105    #region Cursor Handling
106    public void SetAppStartingCursor() {
107      if (InvokeRequired)
108        Invoke(new Action(SetAppStartingCursor));
109      else {
110        appStartingCursors++;
111        SetCursor();
112      }
113    }
114    public void ResetAppStartingCursor() {
115      if (InvokeRequired)
116        Invoke(new Action(ResetAppStartingCursor));
117      else {
118        appStartingCursors--;
119        SetCursor();
120      }
121    }
122    public void SetWaitCursor() {
123      if (InvokeRequired)
124        Invoke(new Action(SetWaitCursor));
125      else {
126        waitingCursors++;
127        SetCursor();
128      }
129    }
130    public void ResetWaitCursor() {
131      if (InvokeRequired)
132        Invoke(new Action(ResetWaitCursor));
133      else {
134        waitingCursors--;
135        SetCursor();
136      }
137    }
138    private void SetCursor() {
139      if (waitingCursors > 0) Cursor = Cursors.WaitCursor;
140      else if (appStartingCursors > 0) Cursor = Cursors.AppStarting;
141      else Cursor = Cursors.Default;
142    }
143    #endregion
[2547]144  }
145}
Note: See TracBrowser for help on using the repository browser.