Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockPaneStripBase.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/DockPaneStripBase.cs
r2645 r4068 1 1 using System; 2 using System.Windows.Forms; 2 using System.Collections; 3 using System.Collections.Generic; 4 using System.Diagnostics.CodeAnalysis; 3 5 using System.Drawing; 4 6 using System.Drawing.Drawing2D; 5 using System.Collections;6 using System.Collections.Generic;7 7 using System.Security.Permissions; 8 using System.Diagnostics.CodeAnalysis; 9 10 namespace WeifenLuo.WinFormsUI.Docking 11 { 12 public abstract class DockPaneStripBase : Control 13 { 14 [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] 15 protected internal class Tab : IDisposable 16 { 17 private IDockContent m_content; 18 19 public Tab(IDockContent content) 20 { 21 m_content = content; 22 } 23 24 ~Tab() 25 { 26 Dispose(false); 27 } 28 29 public IDockContent Content 30 { 31 get { return m_content; } 32 } 33 34 public Form ContentForm 35 { 36 get { return m_content as Form; } 37 } 38 39 public void Dispose() 40 { 41 Dispose(true); 42 GC.SuppressFinalize(this); 43 } 44 45 protected virtual void Dispose(bool disposing) 46 { 47 } 8 using System.Windows.Forms; 9 10 namespace WeifenLuo.WinFormsUI.Docking { 11 public abstract class DockPaneStripBase : Control { 12 [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] 13 protected internal class Tab : IDisposable { 14 private IDockContent m_content; 15 16 public Tab(IDockContent content) { 17 m_content = content; 18 } 19 20 ~Tab() { 21 Dispose(false); 22 } 23 24 public IDockContent Content { 25 get { return m_content; } 26 } 27 28 public Form ContentForm { 29 get { return m_content as Form; } 30 } 31 32 public void Dispose() { 33 Dispose(true); 34 GC.SuppressFinalize(this); 35 } 36 37 protected virtual void Dispose(bool disposing) { 38 } 39 } 40 41 [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] 42 protected sealed class TabCollection : IEnumerable<Tab> { 43 #region IEnumerable Members 44 IEnumerator<Tab> IEnumerable<Tab>.GetEnumerator() { 45 for (int i = 0; i < Count; i++) 46 yield return this[i]; 47 } 48 49 IEnumerator IEnumerable.GetEnumerator() { 50 for (int i = 0; i < Count; i++) 51 yield return this[i]; 52 } 53 #endregion 54 55 internal TabCollection(DockPane pane) { 56 m_dockPane = pane; 57 } 58 59 private DockPane m_dockPane; 60 public DockPane DockPane { 61 get { return m_dockPane; } 62 } 63 64 public int Count { 65 get { return DockPane.DisplayingContents.Count; } 66 } 67 68 public Tab this[int index] { 69 get { 70 IDockContent content = DockPane.DisplayingContents[index]; 71 if (content == null) 72 throw (new ArgumentOutOfRangeException("index")); 73 return content.DockHandler.GetTab(DockPane.TabStripControl); 48 74 } 49 50 [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] 51 protected sealed class TabCollection : IEnumerable<Tab> 52 { 53 #region IEnumerable Members 54 IEnumerator<Tab> IEnumerable<Tab>.GetEnumerator() 55 { 56 for (int i = 0; i < Count; i++) 57 yield return this[i]; 58 } 59 60 IEnumerator IEnumerable.GetEnumerator() 61 { 62 for (int i = 0; i < Count; i++) 63 yield return this[i]; 64 } 65 #endregion 66 67 internal TabCollection(DockPane pane) 68 { 69 m_dockPane = pane; 70 } 71 72 private DockPane m_dockPane; 73 public DockPane DockPane 74 { 75 get { return m_dockPane; } 76 } 77 78 public int Count 79 { 80 get { return DockPane.DisplayingContents.Count; } 81 } 82 83 public Tab this[int index] 84 { 85 get 86 { 87 IDockContent content = DockPane.DisplayingContents[index]; 88 if (content == null) 89 throw (new ArgumentOutOfRangeException("index")); 90 return content.DockHandler.GetTab(DockPane.TabStripControl); 91 } 92 } 93 94 public bool Contains(Tab tab) 95 { 96 return (IndexOf(tab) != -1); 97 } 98 99 public bool Contains(IDockContent content) 100 { 101 return (IndexOf(content) != -1); 102 } 103 104 public int IndexOf(Tab tab) 105 { 106 if (tab == null) 107 return -1; 108 109 return DockPane.DisplayingContents.IndexOf(tab.Content); 110 } 111 112 public int IndexOf(IDockContent content) 113 { 114 return DockPane.DisplayingContents.IndexOf(content); 115 } 75 } 76 77 public bool Contains(Tab tab) { 78 return (IndexOf(tab) != -1); 79 } 80 81 public bool Contains(IDockContent content) { 82 return (IndexOf(content) != -1); 83 } 84 85 public int IndexOf(Tab tab) { 86 if (tab == null) 87 return -1; 88 89 return DockPane.DisplayingContents.IndexOf(tab.Content); 90 } 91 92 public int IndexOf(IDockContent content) { 93 return DockPane.DisplayingContents.IndexOf(content); 94 } 95 } 96 97 protected DockPaneStripBase(DockPane pane) { 98 m_dockPane = pane; 99 100 SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 101 SetStyle(ControlStyles.Selectable, false); 102 AllowDrop = true; 103 } 104 105 private DockPane m_dockPane; 106 protected DockPane DockPane { 107 get { return m_dockPane; } 108 } 109 110 protected DockPane.AppearanceStyle Appearance { 111 get { return DockPane.Appearance; } 112 } 113 114 private TabCollection m_tabs = null; 115 protected TabCollection Tabs { 116 get { 117 if (m_tabs == null) 118 m_tabs = new TabCollection(DockPane); 119 120 return m_tabs; 121 } 122 } 123 124 internal void RefreshChanges() { 125 if (IsDisposed) 126 return; 127 128 OnRefreshChanges(); 129 } 130 131 protected virtual void OnRefreshChanges() { 132 } 133 134 protected internal abstract int MeasureHeight(); 135 136 protected internal abstract void EnsureTabVisible(IDockContent content); 137 138 protected int HitTest() { 139 return HitTest(PointToClient(Control.MousePosition)); 140 } 141 142 protected internal abstract int HitTest(Point point); 143 144 protected internal abstract GraphicsPath GetOutline(int index); 145 146 protected internal virtual Tab CreateTab(IDockContent content) { 147 return new Tab(content); 148 } 149 150 protected override void OnMouseDown(MouseEventArgs e) { 151 base.OnMouseDown(e); 152 153 int index = HitTest(); 154 if (index != -1) { 155 IDockContent content = Tabs[index].Content; 156 if (DockPane.ActiveContent != content) 157 DockPane.ActiveContent = content; 158 } 159 160 if (e.Button == MouseButtons.Left) { 161 if (DockPane.DockPanel.AllowEndUserDocking && DockPane.AllowDockDragAndDrop && DockPane.ActiveContent.DockHandler.AllowEndUserDocking) 162 DockPane.DockPanel.BeginDrag(DockPane.ActiveContent.DockHandler); 163 } 164 } 165 166 protected bool HasTabPageContextMenu { 167 get { return DockPane.HasTabPageContextMenu; } 168 } 169 170 protected void ShowTabPageContextMenu(Point position) { 171 DockPane.ShowTabPageContextMenu(this, position); 172 } 173 174 protected override void OnMouseUp(MouseEventArgs e) { 175 base.OnMouseUp(e); 176 177 if (e.Button == MouseButtons.Right) 178 ShowTabPageContextMenu(new Point(e.X, e.Y)); 179 } 180 181 [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] 182 protected override void WndProc(ref Message m) { 183 if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK) { 184 base.WndProc(ref m); 185 186 int index = HitTest(); 187 if (DockPane.DockPanel.AllowEndUserDocking && index != -1) { 188 IDockContent content = Tabs[index].Content; 189 if (content.DockHandler.CheckDockState(!content.DockHandler.IsFloat) != DockState.Unknown) 190 content.DockHandler.IsFloat = !content.DockHandler.IsFloat; 116 191 } 117 192 118 protected DockPaneStripBase(DockPane pane) 119 { 120 m_dockPane = pane; 121 122 SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 123 SetStyle(ControlStyles.Selectable, false); 124 AllowDrop = true; 125 } 126 127 private DockPane m_dockPane; 128 protected DockPane DockPane 129 { 130 get { return m_dockPane; } 131 } 132 133 protected DockPane.AppearanceStyle Appearance 134 { 135 get { return DockPane.Appearance; } 136 } 137 138 private TabCollection m_tabs = null; 139 protected TabCollection Tabs 140 { 141 get 142 { 143 if (m_tabs == null) 144 m_tabs = new TabCollection(DockPane); 145 146 return m_tabs; 147 } 148 } 149 150 internal void RefreshChanges() 151 { 152 if (IsDisposed) 153 return; 154 155 OnRefreshChanges(); 156 } 157 158 protected virtual void OnRefreshChanges() 159 { 160 } 161 162 protected internal abstract int MeasureHeight(); 163 164 protected internal abstract void EnsureTabVisible(IDockContent content); 165 166 protected int HitTest() 167 { 168 return HitTest(PointToClient(Control.MousePosition)); 169 } 170 171 protected internal abstract int HitTest(Point point); 172 173 protected internal abstract GraphicsPath GetOutline(int index); 174 175 protected internal virtual Tab CreateTab(IDockContent content) 176 { 177 return new Tab(content); 178 } 179 180 protected override void OnMouseDown(MouseEventArgs e) 181 { 182 base.OnMouseDown(e); 183 184 int index = HitTest(); 185 if (index != -1) 186 { 187 IDockContent content = Tabs[index].Content; 188 if (DockPane.ActiveContent != content) 189 DockPane.ActiveContent = content; 190 } 191 192 if (e.Button == MouseButtons.Left) 193 { 194 if (DockPane.DockPanel.AllowEndUserDocking && DockPane.AllowDockDragAndDrop && DockPane.ActiveContent.DockHandler.AllowEndUserDocking) 195 DockPane.DockPanel.BeginDrag(DockPane.ActiveContent.DockHandler); 196 } 197 } 198 199 protected bool HasTabPageContextMenu 200 { 201 get { return DockPane.HasTabPageContextMenu; } 202 } 203 204 protected void ShowTabPageContextMenu(Point position) 205 { 206 DockPane.ShowTabPageContextMenu(this, position); 207 } 208 209 protected override void OnMouseUp(MouseEventArgs e) 210 { 211 base.OnMouseUp(e); 212 213 if (e.Button == MouseButtons.Right) 214 ShowTabPageContextMenu(new Point(e.X, e.Y)); 215 } 216 217 [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] 218 protected override void WndProc(ref Message m) 219 { 220 if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK) 221 { 222 base.WndProc(ref m); 223 224 int index = HitTest(); 225 if (DockPane.DockPanel.AllowEndUserDocking && index != -1) 226 { 227 IDockContent content = Tabs[index].Content; 228 if (content.DockHandler.CheckDockState(!content.DockHandler.IsFloat) != DockState.Unknown) 229 content.DockHandler.IsFloat = !content.DockHandler.IsFloat; 230 } 231 232 return; 233 } 234 235 base.WndProc(ref m); 236 return; 237 } 238 239 protected override void OnDragOver(DragEventArgs drgevent) 240 { 241 base.OnDragOver(drgevent); 242 243 int index = HitTest(); 244 if (index != -1) 245 { 246 IDockContent content = Tabs[index].Content; 247 if (DockPane.ActiveContent != content) 248 DockPane.ActiveContent = content; 249 } 250 } 251 } 193 return; 194 } 195 196 base.WndProc(ref m); 197 return; 198 } 199 200 protected override void OnDragOver(DragEventArgs drgevent) { 201 base.OnDragOver(drgevent); 202 203 int index = HitTest(); 204 if (index != -1) { 205 IDockContent content = Tabs[index].Content; 206 if (DockPane.ActiveContent != content) 207 DockPane.ActiveContent = content; 208 } 209 } 210 } 252 211 }
Note: See TracChangeset
for help on using the changeset viewer.