Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/NestedPaneCollection.cs @ 6675

Last change on this file since 6675 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 3.3 KB
Line 
1using System.Collections.Generic;
2using System.Collections.ObjectModel;
3using System.Drawing;
4
5namespace WeifenLuo.WinFormsUI.Docking {
6  public sealed class NestedPaneCollection : ReadOnlyCollection<DockPane> {
7    private INestedPanesContainer m_container;
8    private VisibleNestedPaneCollection m_visibleNestedPanes;
9
10    internal NestedPaneCollection(INestedPanesContainer container)
11      : base(new List<DockPane>()) {
12      m_container = container;
13      m_visibleNestedPanes = new VisibleNestedPaneCollection(this);
14    }
15
16    public INestedPanesContainer Container {
17      get { return m_container; }
18    }
19
20    public VisibleNestedPaneCollection VisibleNestedPanes {
21      get { return m_visibleNestedPanes; }
22    }
23
24    public DockState DockState {
25      get { return Container.DockState; }
26    }
27
28    public bool IsFloat {
29      get { return DockState == DockState.Float; }
30    }
31
32    internal void Add(DockPane pane) {
33      if (pane == null)
34        return;
35
36      NestedPaneCollection oldNestedPanes = (pane.NestedPanesContainer == null) ? null : pane.NestedPanesContainer.NestedPanes;
37      if (oldNestedPanes != null)
38        oldNestedPanes.InternalRemove(pane);
39      Items.Add(pane);
40      if (oldNestedPanes != null)
41        oldNestedPanes.CheckFloatWindowDispose();
42    }
43
44    private void CheckFloatWindowDispose() {
45      if (Count == 0 && Container.DockState == DockState.Float) {
46        FloatWindow floatWindow = (FloatWindow)Container;
47        if (!floatWindow.Disposing && !floatWindow.IsDisposed)
48          NativeMethods.PostMessage(((FloatWindow)Container).Handle, FloatWindow.WM_CHECKDISPOSE, 0, 0);
49      }
50    }
51
52    internal void Remove(DockPane pane) {
53      InternalRemove(pane);
54      CheckFloatWindowDispose();
55    }
56
57    private void InternalRemove(DockPane pane) {
58      if (!Contains(pane))
59        return;
60
61      NestedDockingStatus statusPane = pane.NestedDockingStatus;
62      DockPane lastNestedPane = null;
63      for (int i = Count - 1; i > IndexOf(pane); i--) {
64        if (this[i].NestedDockingStatus.PreviousPane == pane) {
65          lastNestedPane = this[i];
66          break;
67        }
68      }
69
70      if (lastNestedPane != null) {
71        int indexLastNestedPane = IndexOf(lastNestedPane);
72        Items.Remove(lastNestedPane);
73        Items[IndexOf(pane)] = lastNestedPane;
74        NestedDockingStatus lastNestedDock = lastNestedPane.NestedDockingStatus;
75        lastNestedDock.SetStatus(this, statusPane.PreviousPane, statusPane.Alignment, statusPane.Proportion);
76        for (int i = indexLastNestedPane - 1; i > IndexOf(lastNestedPane); i--) {
77          NestedDockingStatus status = this[i].NestedDockingStatus;
78          if (status.PreviousPane == pane)
79            status.SetStatus(this, lastNestedPane, status.Alignment, status.Proportion);
80        }
81      } else
82        Items.Remove(pane);
83
84      statusPane.SetStatus(null, null, DockAlignment.Left, 0.5);
85      statusPane.SetDisplayingStatus(false, null, DockAlignment.Left, 0.5);
86      statusPane.SetDisplayingBounds(Rectangle.Empty, Rectangle.Empty, Rectangle.Empty);
87    }
88
89    public DockPane GetDefaultPreviousPane(DockPane pane) {
90      for (int i = Count - 1; i >= 0; i--)
91        if (this[i] != pane)
92          return this[i];
93
94      return null;
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.