Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/VisibleNestedPaneCollection.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/VisibleNestedPaneCollection.cs
r2645 r4068 1 using System;2 1 using System.Collections.Generic; 3 2 using System.Collections.ObjectModel; 4 3 using System.Drawing; 5 using System.Windows.Forms;6 4 7 namespace WeifenLuo.WinFormsUI.Docking 8 { 9 public sealed class VisibleNestedPaneCollection : ReadOnlyCollection<DockPane> 10 { 11 private NestedPaneCollection m_nestedPanes; 5 namespace WeifenLuo.WinFormsUI.Docking { 6 public sealed class VisibleNestedPaneCollection : ReadOnlyCollection<DockPane> { 7 private NestedPaneCollection m_nestedPanes; 12 8 13 internal VisibleNestedPaneCollection(NestedPaneCollection nestedPanes) 14 : base(new List<DockPane>()) 15 { 16 m_nestedPanes = nestedPanes; 9 internal VisibleNestedPaneCollection(NestedPaneCollection nestedPanes) 10 : base(new List<DockPane>()) { 11 m_nestedPanes = nestedPanes; 12 } 13 14 public NestedPaneCollection NestedPanes { 15 get { return m_nestedPanes; } 16 } 17 18 public INestedPanesContainer Container { 19 get { return NestedPanes.Container; } 20 } 21 22 public DockState DockState { 23 get { return NestedPanes.DockState; } 24 } 25 26 public bool IsFloat { 27 get { return NestedPanes.IsFloat; } 28 } 29 30 internal void Refresh() { 31 Items.Clear(); 32 for (int i = 0; i < NestedPanes.Count; i++) { 33 DockPane pane = NestedPanes[i]; 34 NestedDockingStatus status = pane.NestedDockingStatus; 35 status.SetDisplayingStatus(true, status.PreviousPane, status.Alignment, status.Proportion); 36 Items.Add(pane); 37 } 38 39 foreach (DockPane pane in NestedPanes) 40 if (pane.DockState != DockState || pane.IsHidden) { 41 pane.Bounds = Rectangle.Empty; 42 pane.SplitterBounds = Rectangle.Empty; 43 Remove(pane); 17 44 } 18 45 19 public NestedPaneCollection NestedPanes 20 { 21 get { return m_nestedPanes; } 22 } 46 CalculateBounds(); 23 47 24 public INestedPanesContainer Container 25 { 26 get { return NestedPanes.Container; } 27 } 48 foreach (DockPane pane in this) { 49 NestedDockingStatus status = pane.NestedDockingStatus; 50 pane.Bounds = status.PaneBounds; 51 pane.SplitterBounds = status.SplitterBounds; 52 pane.SplitterAlignment = status.Alignment; 53 } 54 } 28 55 29 public DockState DockState 30 { 31 get { return NestedPanes.DockState; } 32 } 56 private void Remove(DockPane pane) { 57 if (!Contains(pane)) 58 return; 33 59 34 public bool IsFloat 35 { 36 get { return NestedPanes.IsFloat; } 37 } 60 NestedDockingStatus statusPane = pane.NestedDockingStatus; 61 DockPane lastNestedPane = null; 62 for (int i = Count - 1; i > IndexOf(pane); i--) { 63 if (this[i].NestedDockingStatus.PreviousPane == pane) { 64 lastNestedPane = this[i]; 65 break; 66 } 67 } 38 68 39 internal void Refresh() 40 { 41 Items.Clear(); 42 for (int i=0; i<NestedPanes.Count; i++) 43 { 44 DockPane pane = NestedPanes[i]; 45 NestedDockingStatus status = pane.NestedDockingStatus; 46 status.SetDisplayingStatus(true, status.PreviousPane, status.Alignment, status.Proportion); 47 Items.Add(pane); 48 } 69 if (lastNestedPane != null) { 70 int indexLastNestedPane = IndexOf(lastNestedPane); 71 Items.Remove(lastNestedPane); 72 Items[IndexOf(pane)] = lastNestedPane; 73 NestedDockingStatus lastNestedDock = lastNestedPane.NestedDockingStatus; 74 lastNestedDock.SetDisplayingStatus(true, statusPane.DisplayingPreviousPane, statusPane.DisplayingAlignment, statusPane.DisplayingProportion); 75 for (int i = indexLastNestedPane - 1; i > IndexOf(lastNestedPane); i--) { 76 NestedDockingStatus status = this[i].NestedDockingStatus; 77 if (status.PreviousPane == pane) 78 status.SetDisplayingStatus(true, lastNestedPane, status.DisplayingAlignment, status.DisplayingProportion); 79 } 80 } else 81 Items.Remove(pane); 49 82 50 foreach (DockPane pane in NestedPanes) 51 if (pane.DockState != DockState || pane.IsHidden) 52 { 53 pane.Bounds = Rectangle.Empty; 54 pane.SplitterBounds = Rectangle.Empty; 55 Remove(pane); 56 } 83 statusPane.SetDisplayingStatus(false, null, DockAlignment.Left, 0.5); 84 } 57 85 58 CalculateBounds(); 86 private void CalculateBounds() { 87 if (Count == 0) 88 return; 59 89 60 foreach (DockPane pane in this) 61 { 62 NestedDockingStatus status = pane.NestedDockingStatus; 63 pane.Bounds = status.PaneBounds; 64 pane.SplitterBounds = status.SplitterBounds; 65 pane.SplitterAlignment = status.Alignment; 66 } 67 } 90 this[0].NestedDockingStatus.SetDisplayingBounds(Container.DisplayingRectangle, Container.DisplayingRectangle, Rectangle.Empty); 68 91 69 private void Remove(DockPane pane) 70 { 71 if (!Contains(pane)) 72 return; 92 for (int i = 1; i < Count; i++) { 93 DockPane pane = this[i]; 94 NestedDockingStatus status = pane.NestedDockingStatus; 95 DockPane prevPane = status.DisplayingPreviousPane; 96 NestedDockingStatus statusPrev = prevPane.NestedDockingStatus; 73 97 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 } 98 Rectangle rect = statusPrev.PaneBounds; 99 bool bVerticalSplitter = (status.DisplayingAlignment == DockAlignment.Left || status.DisplayingAlignment == DockAlignment.Right); 84 100 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.SetDisplayingStatus(true, statusPane.DisplayingPreviousPane, statusPane.DisplayingAlignment, statusPane.DisplayingProportion); 92 for (int i=indexLastNestedPane - 1; i>IndexOf(lastNestedPane); i--) 93 { 94 NestedDockingStatus status = this[i].NestedDockingStatus; 95 if (status.PreviousPane == pane) 96 status.SetDisplayingStatus(true, lastNestedPane, status.DisplayingAlignment, status.DisplayingProportion); 97 } 98 } 99 else 100 Items.Remove(pane); 101 Rectangle rectThis = rect; 102 Rectangle rectPrev = rect; 103 Rectangle rectSplitter = rect; 104 if (status.DisplayingAlignment == DockAlignment.Left) { 105 rectThis.Width = (int)((double)rect.Width * status.DisplayingProportion) - (Measures.SplitterSize / 2); 106 rectSplitter.X = rectThis.X + rectThis.Width; 107 rectSplitter.Width = Measures.SplitterSize; 108 rectPrev.X = rectSplitter.X + rectSplitter.Width; 109 rectPrev.Width = rect.Width - rectThis.Width - rectSplitter.Width; 110 } else if (status.DisplayingAlignment == DockAlignment.Right) { 111 rectPrev.Width = (rect.Width - (int)((double)rect.Width * status.DisplayingProportion)) - (Measures.SplitterSize / 2); 112 rectSplitter.X = rectPrev.X + rectPrev.Width; 113 rectSplitter.Width = Measures.SplitterSize; 114 rectThis.X = rectSplitter.X + rectSplitter.Width; 115 rectThis.Width = rect.Width - rectPrev.Width - rectSplitter.Width; 116 } else if (status.DisplayingAlignment == DockAlignment.Top) { 117 rectThis.Height = (int)((double)rect.Height * status.DisplayingProportion) - (Measures.SplitterSize / 2); 118 rectSplitter.Y = rectThis.Y + rectThis.Height; 119 rectSplitter.Height = Measures.SplitterSize; 120 rectPrev.Y = rectSplitter.Y + rectSplitter.Height; 121 rectPrev.Height = rect.Height - rectThis.Height - rectSplitter.Height; 122 } else if (status.DisplayingAlignment == DockAlignment.Bottom) { 123 rectPrev.Height = (rect.Height - (int)((double)rect.Height * status.DisplayingProportion)) - (Measures.SplitterSize / 2); 124 rectSplitter.Y = rectPrev.Y + rectPrev.Height; 125 rectSplitter.Height = Measures.SplitterSize; 126 rectThis.Y = rectSplitter.Y + rectSplitter.Height; 127 rectThis.Height = rect.Height - rectPrev.Height - rectSplitter.Height; 128 } else 129 rectThis = Rectangle.Empty; 101 130 102 statusPane.SetDisplayingStatus(false, null, DockAlignment.Left, 0.5); 103 } 104 105 private void CalculateBounds() 106 { 107 if (Count == 0) 108 return; 109 110 this[0].NestedDockingStatus.SetDisplayingBounds(Container.DisplayingRectangle, Container.DisplayingRectangle, Rectangle.Empty); 111 112 for (int i=1; i<Count; i++) 113 { 114 DockPane pane = this[i]; 115 NestedDockingStatus status = pane.NestedDockingStatus; 116 DockPane prevPane = status.DisplayingPreviousPane; 117 NestedDockingStatus statusPrev = prevPane.NestedDockingStatus; 118 119 Rectangle rect = statusPrev.PaneBounds; 120 bool bVerticalSplitter = (status.DisplayingAlignment == DockAlignment.Left || status.DisplayingAlignment == DockAlignment.Right); 121 122 Rectangle rectThis = rect; 123 Rectangle rectPrev = rect; 124 Rectangle rectSplitter = rect; 125 if (status.DisplayingAlignment == DockAlignment.Left) 126 { 127 rectThis.Width = (int)((double)rect.Width * status.DisplayingProportion) - (Measures.SplitterSize / 2); 128 rectSplitter.X = rectThis.X + rectThis.Width; 129 rectSplitter.Width = Measures.SplitterSize; 130 rectPrev.X = rectSplitter.X + rectSplitter.Width; 131 rectPrev.Width = rect.Width - rectThis.Width - rectSplitter.Width; 132 } 133 else if (status.DisplayingAlignment == DockAlignment.Right) 134 { 135 rectPrev.Width = (rect.Width - (int)((double)rect.Width * status.DisplayingProportion)) - (Measures.SplitterSize / 2); 136 rectSplitter.X = rectPrev.X + rectPrev.Width; 137 rectSplitter.Width = Measures.SplitterSize; 138 rectThis.X = rectSplitter.X + rectSplitter.Width; 139 rectThis.Width = rect.Width - rectPrev.Width - rectSplitter.Width; 140 } 141 else if (status.DisplayingAlignment == DockAlignment.Top) 142 { 143 rectThis.Height = (int)((double)rect.Height * status.DisplayingProportion) - (Measures.SplitterSize / 2); 144 rectSplitter.Y = rectThis.Y + rectThis.Height; 145 rectSplitter.Height = Measures.SplitterSize; 146 rectPrev.Y = rectSplitter.Y + rectSplitter.Height; 147 rectPrev.Height = rect.Height - rectThis.Height - rectSplitter.Height; 148 } 149 else if (status.DisplayingAlignment == DockAlignment.Bottom) 150 { 151 rectPrev.Height = (rect.Height - (int)((double)rect.Height * status.DisplayingProportion)) - (Measures.SplitterSize / 2); 152 rectSplitter.Y = rectPrev.Y + rectPrev.Height; 153 rectSplitter.Height = Measures.SplitterSize; 154 rectThis.Y = rectSplitter.Y + rectSplitter.Height; 155 rectThis.Height = rect.Height - rectPrev.Height - rectSplitter.Height; 156 } 157 else 158 rectThis = Rectangle.Empty; 159 160 rectSplitter.Intersect(rect); 161 rectThis.Intersect(rect); 162 rectPrev.Intersect(rect); 163 status.SetDisplayingBounds(rect, rectThis, rectSplitter); 164 statusPrev.SetDisplayingBounds(statusPrev.LogicalBounds, rectPrev, statusPrev.SplitterBounds); 165 } 166 } 167 } 131 rectSplitter.Intersect(rect); 132 rectThis.Intersect(rect); 133 rectPrev.Intersect(rect); 134 status.SetDisplayingBounds(rect, rectThis, rectSplitter); 135 statusPrev.SetDisplayingBounds(statusPrev.LogicalBounds, rectPrev, statusPrev.SplitterBounds); 136 } 137 } 138 } 168 139 }
Note: See TracChangeset
for help on using the changeset viewer.