Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/WinFormsUI/Docking/NestedPaneCollection.cs @ 4593

Last change on this file since 4593 was 2134, checked in by gkronber, 15 years ago

Added up to date source of Weifen Luo dock panel suit in a separate project (and added strong name key). Removed binary versions of Weifen Luo dock panel suite and references to it. #687 (Update AdvancedOptimizationFrontend to use more recent version of Weifen Luo Docking library)

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