Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.cs @ 2253

Last change on this file since 2253 was 2253, checked in by mkommend, 15 years ago

added support for multiple document mainform without docking (ticket #716)

File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9
10namespace HeuristicLab.MainForm {
11  public partial class MultipleDocumentMainForm : MainFormBase {
12    public MultipleDocumentMainForm(Type userInterfaceType)
13      : base(userInterfaceType) {
14      InitializeComponent();
15      this.IsMdiContainer = true;
16    }
17
18    public override void ShowView(IView view) {
19      if (InvokeRequired) Invoke((Action<IView>)ShowView, view);
20      else {
21        base.ShowView(view);
22        MultipleDocumentForm form = new MultipleDocumentForm(view);
23        form.Activated += new EventHandler(MultipleDocumentFormActivated);
24        form.FormClosing += new FormClosingEventHandler(MultipleDocumentFormClosing);
25        form.MdiParent = this;
26        form.Show();
27      }
28    }
29
30    private void MultipleDocumentFormActivated(object sender, EventArgs e) {
31      base.activeView = ((MultipleDocumentForm)sender).View;
32      base.StatusStripText = ((MultipleDocumentForm)sender).View.Caption;
33    }
34
35    private void MultipleDocumentFormClosing(object sender, FormClosingEventArgs e) {
36      MultipleDocumentForm form = (MultipleDocumentForm)sender;
37      openViews.Remove(form.View);
38      if (openViews.Count == 0)
39        activeView = null;
40      form.Activated -= new EventHandler(MultipleDocumentFormActivated);
41      form.FormClosing -= new FormClosingEventHandler(MultipleDocumentFormClosing);
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.