1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Data;
|
---|
5 | using System.Drawing;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 |
|
---|
10 | namespace 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 | foreach (IToolStripItem item in viewStateChangeToolStripItems)
|
---|
27 | view.StateChanged += new EventHandler(item.ViewStateChanged);
|
---|
28 | form.Show();
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | private void MultipleDocumentFormActivated(object sender, EventArgs e) {
|
---|
33 | base.ActiveView = ((MultipleDocumentForm)sender).View;
|
---|
34 | base.StatusStripText = ((MultipleDocumentForm)sender).View.Caption;
|
---|
35 | }
|
---|
36 |
|
---|
37 | private void MultipleDocumentFormClosing(object sender, FormClosingEventArgs e) {
|
---|
38 | MultipleDocumentForm form = (MultipleDocumentForm)sender;
|
---|
39 | openViews.Remove(form.View);
|
---|
40 | if (openViews.Count == 0)
|
---|
41 | ActiveView = null;
|
---|
42 | form.Activated -= new EventHandler(MultipleDocumentFormActivated);
|
---|
43 | form.FormClosing -= new FormClosingEventHandler(MultipleDocumentFormClosing);
|
---|
44 | foreach (IToolStripItem item in viewStateChangeToolStripItems)
|
---|
45 | form.View.StateChanged -= new EventHandler(item.ViewStateChanged);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|