Free cookie consent management tool by TermsFeed Policy Generator

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

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

corrected bug in MultipleDocumentMainForm !viewStateChanged were not handled (ticket #716)

File size: 1.8 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        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}
Note: See TracBrowser for help on using the repository browser.