Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockPanel.DockDragHandler.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/DockPanel.DockDragHandler.cs
r2645 r4068 1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.Windows.Forms; 1 using System.ComponentModel; 5 2 using System.Drawing; 6 3 using System.Drawing.Drawing2D; 7 using System.ComponentModel; 8 9 namespace WeifenLuo.WinFormsUI.Docking 10 { 11 partial class DockPanel 12 { 13 private sealed class DockDragHandler : DragHandler 14 { 15 private class DockIndicator : DragForm 16 { 17 #region IHitTest 18 private interface IHitTest 19 { 20 DockStyle HitTest(Point pt); 21 DockStyle Status { get; set; } 22 } 23 #endregion 24 25 #region PanelIndicator 26 private class PanelIndicator : PictureBox, IHitTest 27 { 28 private static Image _imagePanelLeft = Resources.DockIndicator_PanelLeft; 29 private static Image _imagePanelRight = Resources.DockIndicator_PanelRight; 30 private static Image _imagePanelTop = Resources.DockIndicator_PanelTop; 31 private static Image _imagePanelBottom = Resources.DockIndicator_PanelBottom; 32 private static Image _imagePanelFill = Resources.DockIndicator_PanelFill; 33 private static Image _imagePanelLeftActive = Resources.DockIndicator_PanelLeft_Active; 34 private static Image _imagePanelRightActive = Resources.DockIndicator_PanelRight_Active; 35 private static Image _imagePanelTopActive = Resources.DockIndicator_PanelTop_Active; 36 private static Image _imagePanelBottomActive = Resources.DockIndicator_PanelBottom_Active; 37 private static Image _imagePanelFillActive = Resources.DockIndicator_PanelFill_Active; 38 39 public PanelIndicator(DockStyle dockStyle) 40 { 41 m_dockStyle = dockStyle; 42 SizeMode = PictureBoxSizeMode.AutoSize; 43 Image = ImageInactive; 44 } 45 46 private DockStyle m_dockStyle; 47 private DockStyle DockStyle 48 { 49 get { return m_dockStyle; } 50 } 51 52 private DockStyle m_status; 53 public DockStyle Status 54 { 55 get { return m_status; } 56 set 57 { 58 if (value != DockStyle && value != DockStyle.None) 59 throw new InvalidEnumArgumentException(); 60 61 if (m_status == value) 62 return; 63 64 m_status = value; 65 IsActivated = (m_status != DockStyle.None); 66 } 67 } 68 69 private Image ImageInactive 70 { 71 get 72 { 73 if (DockStyle == DockStyle.Left) 74 return _imagePanelLeft; 75 else if (DockStyle == DockStyle.Right) 76 return _imagePanelRight; 77 else if (DockStyle == DockStyle.Top) 78 return _imagePanelTop; 79 else if (DockStyle == DockStyle.Bottom) 80 return _imagePanelBottom; 81 else if (DockStyle == DockStyle.Fill) 82 return _imagePanelFill; 83 else 84 return null; 85 } 86 } 87 88 private Image ImageActive 89 { 90 get 91 { 92 if (DockStyle == DockStyle.Left) 93 return _imagePanelLeftActive; 94 else if (DockStyle == DockStyle.Right) 95 return _imagePanelRightActive; 96 else if (DockStyle == DockStyle.Top) 97 return _imagePanelTopActive; 98 else if (DockStyle == DockStyle.Bottom) 99 return _imagePanelBottomActive; 100 else if (DockStyle == DockStyle.Fill) 101 return _imagePanelFillActive; 102 else 103 return null; 104 } 105 } 106 107 private bool m_isActivated = false; 108 private bool IsActivated 109 { 110 get { return m_isActivated; } 111 set 112 { 113 m_isActivated = value; 114 Image = IsActivated ? ImageActive : ImageInactive; 115 } 116 } 117 118 public DockStyle HitTest(Point pt) 119 { 120 return this.Visible && ClientRectangle.Contains(PointToClient(pt)) ? DockStyle : DockStyle.None; 121 } 122 } 123 #endregion PanelIndicator 124 125 #region PaneIndicator 126 private class PaneIndicator : PictureBox, IHitTest 127 { 128 private struct HotSpotIndex 129 { 130 public HotSpotIndex(int x, int y, DockStyle dockStyle) 131 { 132 m_x = x; 133 m_y = y; 134 m_dockStyle = dockStyle; 135 } 136 137 private int m_x; 138 public int X 139 { 140 get { return m_x; } 141 } 142 143 private int m_y; 144 public int Y 145 { 146 get { return m_y; } 147 } 148 149 private DockStyle m_dockStyle; 150 public DockStyle DockStyle 151 { 152 get { return m_dockStyle; } 153 } 154 } 155 156 private static Bitmap _bitmapPaneDiamond = Resources.DockIndicator_PaneDiamond; 157 private static Bitmap _bitmapPaneDiamondLeft = Resources.DockIndicator_PaneDiamond_Left; 158 private static Bitmap _bitmapPaneDiamondRight = Resources.DockIndicator_PaneDiamond_Right; 159 private static Bitmap _bitmapPaneDiamondTop = Resources.DockIndicator_PaneDiamond_Top; 160 private static Bitmap _bitmapPaneDiamondBottom = Resources.DockIndicator_PaneDiamond_Bottom; 161 private static Bitmap _bitmapPaneDiamondFill = Resources.DockIndicator_PaneDiamond_Fill; 162 private static Bitmap _bitmapPaneDiamondHotSpot = Resources.DockIndicator_PaneDiamond_HotSpot; 163 private static Bitmap _bitmapPaneDiamondHotSpotIndex = Resources.DockIndicator_PaneDiamond_HotSpotIndex; 164 private static HotSpotIndex[] _hotSpots = new HotSpotIndex[] 4 using System.Windows.Forms; 5 6 namespace WeifenLuo.WinFormsUI.Docking { 7 partial class DockPanel { 8 private sealed class DockDragHandler : DragHandler { 9 private class DockIndicator : DragForm { 10 #region IHitTest 11 private interface IHitTest { 12 DockStyle HitTest(Point pt); 13 DockStyle Status { get; set; } 14 } 15 #endregion 16 17 #region PanelIndicator 18 private class PanelIndicator : PictureBox, IHitTest { 19 private static Image _imagePanelLeft = Resources.DockIndicator_PanelLeft; 20 private static Image _imagePanelRight = Resources.DockIndicator_PanelRight; 21 private static Image _imagePanelTop = Resources.DockIndicator_PanelTop; 22 private static Image _imagePanelBottom = Resources.DockIndicator_PanelBottom; 23 private static Image _imagePanelFill = Resources.DockIndicator_PanelFill; 24 private static Image _imagePanelLeftActive = Resources.DockIndicator_PanelLeft_Active; 25 private static Image _imagePanelRightActive = Resources.DockIndicator_PanelRight_Active; 26 private static Image _imagePanelTopActive = Resources.DockIndicator_PanelTop_Active; 27 private static Image _imagePanelBottomActive = Resources.DockIndicator_PanelBottom_Active; 28 private static Image _imagePanelFillActive = Resources.DockIndicator_PanelFill_Active; 29 30 public PanelIndicator(DockStyle dockStyle) { 31 m_dockStyle = dockStyle; 32 SizeMode = PictureBoxSizeMode.AutoSize; 33 Image = ImageInactive; 34 } 35 36 private DockStyle m_dockStyle; 37 private DockStyle DockStyle { 38 get { return m_dockStyle; } 39 } 40 41 private DockStyle m_status; 42 public DockStyle Status { 43 get { return m_status; } 44 set { 45 if (value != DockStyle && value != DockStyle.None) 46 throw new InvalidEnumArgumentException(); 47 48 if (m_status == value) 49 return; 50 51 m_status = value; 52 IsActivated = (m_status != DockStyle.None); 53 } 54 } 55 56 private Image ImageInactive { 57 get { 58 if (DockStyle == DockStyle.Left) 59 return _imagePanelLeft; 60 else if (DockStyle == DockStyle.Right) 61 return _imagePanelRight; 62 else if (DockStyle == DockStyle.Top) 63 return _imagePanelTop; 64 else if (DockStyle == DockStyle.Bottom) 65 return _imagePanelBottom; 66 else if (DockStyle == DockStyle.Fill) 67 return _imagePanelFill; 68 else 69 return null; 70 } 71 } 72 73 private Image ImageActive { 74 get { 75 if (DockStyle == DockStyle.Left) 76 return _imagePanelLeftActive; 77 else if (DockStyle == DockStyle.Right) 78 return _imagePanelRightActive; 79 else if (DockStyle == DockStyle.Top) 80 return _imagePanelTopActive; 81 else if (DockStyle == DockStyle.Bottom) 82 return _imagePanelBottomActive; 83 else if (DockStyle == DockStyle.Fill) 84 return _imagePanelFillActive; 85 else 86 return null; 87 } 88 } 89 90 private bool m_isActivated = false; 91 private bool IsActivated { 92 get { return m_isActivated; } 93 set { 94 m_isActivated = value; 95 Image = IsActivated ? ImageActive : ImageInactive; 96 } 97 } 98 99 public DockStyle HitTest(Point pt) { 100 return this.Visible && ClientRectangle.Contains(PointToClient(pt)) ? DockStyle : DockStyle.None; 101 } 102 } 103 #endregion PanelIndicator 104 105 #region PaneIndicator 106 private class PaneIndicator : PictureBox, IHitTest { 107 private struct HotSpotIndex { 108 public HotSpotIndex(int x, int y, DockStyle dockStyle) { 109 m_x = x; 110 m_y = y; 111 m_dockStyle = dockStyle; 112 } 113 114 private int m_x; 115 public int X { 116 get { return m_x; } 117 } 118 119 private int m_y; 120 public int Y { 121 get { return m_y; } 122 } 123 124 private DockStyle m_dockStyle; 125 public DockStyle DockStyle { 126 get { return m_dockStyle; } 127 } 128 } 129 130 private static Bitmap _bitmapPaneDiamond = Resources.DockIndicator_PaneDiamond; 131 private static Bitmap _bitmapPaneDiamondLeft = Resources.DockIndicator_PaneDiamond_Left; 132 private static Bitmap _bitmapPaneDiamondRight = Resources.DockIndicator_PaneDiamond_Right; 133 private static Bitmap _bitmapPaneDiamondTop = Resources.DockIndicator_PaneDiamond_Top; 134 private static Bitmap _bitmapPaneDiamondBottom = Resources.DockIndicator_PaneDiamond_Bottom; 135 private static Bitmap _bitmapPaneDiamondFill = Resources.DockIndicator_PaneDiamond_Fill; 136 private static Bitmap _bitmapPaneDiamondHotSpot = Resources.DockIndicator_PaneDiamond_HotSpot; 137 private static Bitmap _bitmapPaneDiamondHotSpotIndex = Resources.DockIndicator_PaneDiamond_HotSpotIndex; 138 private static HotSpotIndex[] _hotSpots = new HotSpotIndex[] 165 139 { 166 140 new HotSpotIndex(1, 0, DockStyle.Top), … … 170 144 new HotSpotIndex(1, 2, DockStyle.Bottom) 171 145 }; 172 private static GraphicsPath _displayingGraphicsPath = DrawHelper.CalculateGraphicsPathFromBitmap(_bitmapPaneDiamond); 173 174 public PaneIndicator() 175 { 176 SizeMode = PictureBoxSizeMode.AutoSize; 177 Image = _bitmapPaneDiamond; 178 Region = new Region(DisplayingGraphicsPath); 179 } 180 181 public static GraphicsPath DisplayingGraphicsPath 182 { 183 get { return _displayingGraphicsPath; } 184 } 185 186 public DockStyle HitTest(Point pt) 187 { 188 if (!Visible) 189 return DockStyle.None; 190 191 pt = PointToClient(pt); 192 if (!ClientRectangle.Contains(pt)) 193 return DockStyle.None; 194 195 for (int i = _hotSpots.GetLowerBound(0); i <= _hotSpots.GetUpperBound(0); i++) 196 { 197 if (_bitmapPaneDiamondHotSpot.GetPixel(pt.X, pt.Y) == _bitmapPaneDiamondHotSpotIndex.GetPixel(_hotSpots[i].X, _hotSpots[i].Y)) 198 return _hotSpots[i].DockStyle; 199 } 200 201 return DockStyle.None; 202 } 203 204 private DockStyle m_status = DockStyle.None; 205 public DockStyle Status 206 { 207 get { return m_status; } 208 set 209 { 210 m_status = value; 211 if (m_status == DockStyle.None) 212 Image = _bitmapPaneDiamond; 213 else if (m_status == DockStyle.Left) 214 Image = _bitmapPaneDiamondLeft; 215 else if (m_status == DockStyle.Right) 216 Image = _bitmapPaneDiamondRight; 217 else if (m_status == DockStyle.Top) 218 Image = _bitmapPaneDiamondTop; 219 else if (m_status == DockStyle.Bottom) 220 Image = _bitmapPaneDiamondBottom; 221 else if (m_status == DockStyle.Fill) 222 Image = _bitmapPaneDiamondFill; 223 } 224 } 225 } 226 #endregion PaneIndicator 227 228 #region consts 229 private int _PanelIndicatorMargin = 10; 230 #endregion 231 232 private DockDragHandler m_dragHandler; 233 234 public DockIndicator(DockDragHandler dragHandler) 235 { 236 m_dragHandler = dragHandler; 237 Controls.AddRange(new Control[] { 146 private static GraphicsPath _displayingGraphicsPath = DrawHelper.CalculateGraphicsPathFromBitmap(_bitmapPaneDiamond); 147 148 public PaneIndicator() { 149 SizeMode = PictureBoxSizeMode.AutoSize; 150 Image = _bitmapPaneDiamond; 151 Region = new Region(DisplayingGraphicsPath); 152 } 153 154 public static GraphicsPath DisplayingGraphicsPath { 155 get { return _displayingGraphicsPath; } 156 } 157 158 public DockStyle HitTest(Point pt) { 159 if (!Visible) 160 return DockStyle.None; 161 162 pt = PointToClient(pt); 163 if (!ClientRectangle.Contains(pt)) 164 return DockStyle.None; 165 166 for (int i = _hotSpots.GetLowerBound(0); i <= _hotSpots.GetUpperBound(0); i++) { 167 if (_bitmapPaneDiamondHotSpot.GetPixel(pt.X, pt.Y) == _bitmapPaneDiamondHotSpotIndex.GetPixel(_hotSpots[i].X, _hotSpots[i].Y)) 168 return _hotSpots[i].DockStyle; 169 } 170 171 return DockStyle.None; 172 } 173 174 private DockStyle m_status = DockStyle.None; 175 public DockStyle Status { 176 get { return m_status; } 177 set { 178 m_status = value; 179 if (m_status == DockStyle.None) 180 Image = _bitmapPaneDiamond; 181 else if (m_status == DockStyle.Left) 182 Image = _bitmapPaneDiamondLeft; 183 else if (m_status == DockStyle.Right) 184 Image = _bitmapPaneDiamondRight; 185 else if (m_status == DockStyle.Top) 186 Image = _bitmapPaneDiamondTop; 187 else if (m_status == DockStyle.Bottom) 188 Image = _bitmapPaneDiamondBottom; 189 else if (m_status == DockStyle.Fill) 190 Image = _bitmapPaneDiamondFill; 191 } 192 } 193 } 194 #endregion PaneIndicator 195 196 #region consts 197 private int _PanelIndicatorMargin = 10; 198 #endregion 199 200 private DockDragHandler m_dragHandler; 201 202 public DockIndicator(DockDragHandler dragHandler) { 203 m_dragHandler = dragHandler; 204 Controls.AddRange(new Control[] { 238 205 PaneDiamond, 239 206 PanelLeft, … … 243 210 PanelFill 244 211 }); 245 Region = new Region(Rectangle.Empty); 246 } 247 248 private PaneIndicator m_paneDiamond = null; 249 private PaneIndicator PaneDiamond 250 { 251 get 252 { 253 if (m_paneDiamond == null) 254 m_paneDiamond = new PaneIndicator(); 255 256 return m_paneDiamond; 257 } 258 } 259 260 private PanelIndicator m_panelLeft = null; 261 private PanelIndicator PanelLeft 262 { 263 get 264 { 265 if (m_panelLeft == null) 266 m_panelLeft = new PanelIndicator(DockStyle.Left); 267 268 return m_panelLeft; 269 } 270 } 271 272 private PanelIndicator m_panelRight = null; 273 private PanelIndicator PanelRight 274 { 275 get 276 { 277 if (m_panelRight == null) 278 m_panelRight = new PanelIndicator(DockStyle.Right); 279 280 return m_panelRight; 281 } 282 } 283 284 private PanelIndicator m_panelTop = null; 285 private PanelIndicator PanelTop 286 { 287 get 288 { 289 if (m_panelTop == null) 290 m_panelTop = new PanelIndicator(DockStyle.Top); 291 292 return m_panelTop; 293 } 294 } 295 296 private PanelIndicator m_panelBottom = null; 297 private PanelIndicator PanelBottom 298 { 299 get 300 { 301 if (m_panelBottom == null) 302 m_panelBottom = new PanelIndicator(DockStyle.Bottom); 303 304 return m_panelBottom; 305 } 306 } 307 308 private PanelIndicator m_panelFill = null; 309 private PanelIndicator PanelFill 310 { 311 get 312 { 313 if (m_panelFill == null) 314 m_panelFill = new PanelIndicator(DockStyle.Fill); 315 316 return m_panelFill; 317 } 318 } 319 320 private bool m_fullPanelEdge = false; 321 public bool FullPanelEdge 322 { 323 get { return m_fullPanelEdge; } 324 set 325 { 326 if (m_fullPanelEdge == value) 327 return; 328 329 m_fullPanelEdge = value; 330 RefreshChanges(); 331 } 332 } 333 334 public DockDragHandler DragHandler 335 { 336 get { return m_dragHandler; } 337 } 338 339 public DockPanel DockPanel 340 { 341 get { return DragHandler.DockPanel; } 342 } 343 344 private DockPane m_dockPane = null; 345 public DockPane DockPane 346 { 347 get { return m_dockPane; } 348 internal set 349 { 350 if (m_dockPane == value) 351 return; 352 353 DockPane oldDisplayingPane = DisplayingPane; 354 m_dockPane = value; 355 if (oldDisplayingPane != DisplayingPane) 356 RefreshChanges(); 357 } 358 } 359 360 private IHitTest m_hitTest = null; 361 private IHitTest HitTestResult 362 { 363 get { return m_hitTest; } 364 set 365 { 366 if (m_hitTest == value) 367 return; 368 369 if (m_hitTest != null) 370 m_hitTest.Status = DockStyle.None; 371 372 m_hitTest = value; 373 } 374 } 375 376 private DockPane DisplayingPane 377 { 378 get { return ShouldPaneDiamondVisible() ? DockPane : null; } 379 } 380 381 private void RefreshChanges() 382 { 383 Region region = new Region(Rectangle.Empty); 384 Rectangle rectDockArea = FullPanelEdge ? DockPanel.DockArea : DockPanel.DocumentWindowBounds; 385 386 rectDockArea = RectangleToClient(DockPanel.RectangleToScreen(rectDockArea)); 387 if (ShouldPanelIndicatorVisible(DockState.DockLeft)) 388 { 389 PanelLeft.Location = new Point(rectDockArea.X + _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); 390 PanelLeft.Visible = true; 391 region.Union(PanelLeft.Bounds); 392 } 393 else 394 PanelLeft.Visible = false; 395 396 if (ShouldPanelIndicatorVisible(DockState.DockRight)) 397 { 398 PanelRight.Location = new Point(rectDockArea.X + rectDockArea.Width - PanelRight.Width - _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); 399 PanelRight.Visible = true; 400 region.Union(PanelRight.Bounds); 401 } 402 else 403 PanelRight.Visible = false; 404 405 if (ShouldPanelIndicatorVisible(DockState.DockTop)) 406 { 407 PanelTop.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelTop.Width) / 2, rectDockArea.Y + _PanelIndicatorMargin); 408 PanelTop.Visible = true; 409 region.Union(PanelTop.Bounds); 410 } 411 else 412 PanelTop.Visible = false; 413 414 if (ShouldPanelIndicatorVisible(DockState.DockBottom)) 415 { 416 PanelBottom.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelBottom.Width) / 2, rectDockArea.Y + rectDockArea.Height - PanelBottom.Height - _PanelIndicatorMargin); 417 PanelBottom.Visible = true; 418 region.Union(PanelBottom.Bounds); 419 } 420 else 421 PanelBottom.Visible = false; 422 423 if (ShouldPanelIndicatorVisible(DockState.Document)) 424 { 425 Rectangle rectDocumentWindow = RectangleToClient(DockPanel.RectangleToScreen(DockPanel.DocumentWindowBounds)); 426 PanelFill.Location = new Point(rectDocumentWindow.X + (rectDocumentWindow.Width - PanelFill.Width) / 2, rectDocumentWindow.Y + (rectDocumentWindow.Height - PanelFill.Height) / 2); 427 PanelFill.Visible = true; 428 region.Union(PanelFill.Bounds); 429 } 430 else 431 PanelFill.Visible = false; 432 433 if (ShouldPaneDiamondVisible()) 434 { 435 Rectangle rect = RectangleToClient(DockPane.RectangleToScreen(DockPane.ClientRectangle)); 436 PaneDiamond.Location = new Point(rect.Left + (rect.Width - PaneDiamond.Width) / 2, rect.Top + (rect.Height - PaneDiamond.Height) / 2); 437 PaneDiamond.Visible = true; 438 using (GraphicsPath graphicsPath = PaneIndicator.DisplayingGraphicsPath.Clone() as GraphicsPath) 439 { 440 Point[] pts = new Point[] 212 Region = new Region(Rectangle.Empty); 213 } 214 215 private PaneIndicator m_paneDiamond = null; 216 private PaneIndicator PaneDiamond { 217 get { 218 if (m_paneDiamond == null) 219 m_paneDiamond = new PaneIndicator(); 220 221 return m_paneDiamond; 222 } 223 } 224 225 private PanelIndicator m_panelLeft = null; 226 private PanelIndicator PanelLeft { 227 get { 228 if (m_panelLeft == null) 229 m_panelLeft = new PanelIndicator(DockStyle.Left); 230 231 return m_panelLeft; 232 } 233 } 234 235 private PanelIndicator m_panelRight = null; 236 private PanelIndicator PanelRight { 237 get { 238 if (m_panelRight == null) 239 m_panelRight = new PanelIndicator(DockStyle.Right); 240 241 return m_panelRight; 242 } 243 } 244 245 private PanelIndicator m_panelTop = null; 246 private PanelIndicator PanelTop { 247 get { 248 if (m_panelTop == null) 249 m_panelTop = new PanelIndicator(DockStyle.Top); 250 251 return m_panelTop; 252 } 253 } 254 255 private PanelIndicator m_panelBottom = null; 256 private PanelIndicator PanelBottom { 257 get { 258 if (m_panelBottom == null) 259 m_panelBottom = new PanelIndicator(DockStyle.Bottom); 260 261 return m_panelBottom; 262 } 263 } 264 265 private PanelIndicator m_panelFill = null; 266 private PanelIndicator PanelFill { 267 get { 268 if (m_panelFill == null) 269 m_panelFill = new PanelIndicator(DockStyle.Fill); 270 271 return m_panelFill; 272 } 273 } 274 275 private bool m_fullPanelEdge = false; 276 public bool FullPanelEdge { 277 get { return m_fullPanelEdge; } 278 set { 279 if (m_fullPanelEdge == value) 280 return; 281 282 m_fullPanelEdge = value; 283 RefreshChanges(); 284 } 285 } 286 287 public DockDragHandler DragHandler { 288 get { return m_dragHandler; } 289 } 290 291 public DockPanel DockPanel { 292 get { return DragHandler.DockPanel; } 293 } 294 295 private DockPane m_dockPane = null; 296 public DockPane DockPane { 297 get { return m_dockPane; } 298 internal set { 299 if (m_dockPane == value) 300 return; 301 302 DockPane oldDisplayingPane = DisplayingPane; 303 m_dockPane = value; 304 if (oldDisplayingPane != DisplayingPane) 305 RefreshChanges(); 306 } 307 } 308 309 private IHitTest m_hitTest = null; 310 private IHitTest HitTestResult { 311 get { return m_hitTest; } 312 set { 313 if (m_hitTest == value) 314 return; 315 316 if (m_hitTest != null) 317 m_hitTest.Status = DockStyle.None; 318 319 m_hitTest = value; 320 } 321 } 322 323 private DockPane DisplayingPane { 324 get { return ShouldPaneDiamondVisible() ? DockPane : null; } 325 } 326 327 private void RefreshChanges() { 328 Region region = new Region(Rectangle.Empty); 329 Rectangle rectDockArea = FullPanelEdge ? DockPanel.DockArea : DockPanel.DocumentWindowBounds; 330 331 rectDockArea = RectangleToClient(DockPanel.RectangleToScreen(rectDockArea)); 332 if (ShouldPanelIndicatorVisible(DockState.DockLeft)) { 333 PanelLeft.Location = new Point(rectDockArea.X + _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); 334 PanelLeft.Visible = true; 335 region.Union(PanelLeft.Bounds); 336 } else 337 PanelLeft.Visible = false; 338 339 if (ShouldPanelIndicatorVisible(DockState.DockRight)) { 340 PanelRight.Location = new Point(rectDockArea.X + rectDockArea.Width - PanelRight.Width - _PanelIndicatorMargin, rectDockArea.Y + (rectDockArea.Height - PanelRight.Height) / 2); 341 PanelRight.Visible = true; 342 region.Union(PanelRight.Bounds); 343 } else 344 PanelRight.Visible = false; 345 346 if (ShouldPanelIndicatorVisible(DockState.DockTop)) { 347 PanelTop.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelTop.Width) / 2, rectDockArea.Y + _PanelIndicatorMargin); 348 PanelTop.Visible = true; 349 region.Union(PanelTop.Bounds); 350 } else 351 PanelTop.Visible = false; 352 353 if (ShouldPanelIndicatorVisible(DockState.DockBottom)) { 354 PanelBottom.Location = new Point(rectDockArea.X + (rectDockArea.Width - PanelBottom.Width) / 2, rectDockArea.Y + rectDockArea.Height - PanelBottom.Height - _PanelIndicatorMargin); 355 PanelBottom.Visible = true; 356 region.Union(PanelBottom.Bounds); 357 } else 358 PanelBottom.Visible = false; 359 360 if (ShouldPanelIndicatorVisible(DockState.Document)) { 361 Rectangle rectDocumentWindow = RectangleToClient(DockPanel.RectangleToScreen(DockPanel.DocumentWindowBounds)); 362 PanelFill.Location = new Point(rectDocumentWindow.X + (rectDocumentWindow.Width - PanelFill.Width) / 2, rectDocumentWindow.Y + (rectDocumentWindow.Height - PanelFill.Height) / 2); 363 PanelFill.Visible = true; 364 region.Union(PanelFill.Bounds); 365 } else 366 PanelFill.Visible = false; 367 368 if (ShouldPaneDiamondVisible()) { 369 Rectangle rect = RectangleToClient(DockPane.RectangleToScreen(DockPane.ClientRectangle)); 370 PaneDiamond.Location = new Point(rect.Left + (rect.Width - PaneDiamond.Width) / 2, rect.Top + (rect.Height - PaneDiamond.Height) / 2); 371 PaneDiamond.Visible = true; 372 using (GraphicsPath graphicsPath = PaneIndicator.DisplayingGraphicsPath.Clone() as GraphicsPath) { 373 Point[] pts = new Point[] 441 374 { 442 375 new Point(PaneDiamond.Left, PaneDiamond.Top), … … 444 377 new Point(PaneDiamond.Left, PaneDiamond.Bottom) 445 378 }; 446 using (Matrix matrix = new Matrix(PaneDiamond.ClientRectangle, pts)) 447 { 448 graphicsPath.Transform(matrix); 449 } 450 region.Union(graphicsPath); 451 } 452 } 453 else 454 PaneDiamond.Visible = false; 455 456 Region = region; 457 } 458 459 private bool ShouldPanelIndicatorVisible(DockState dockState) 460 { 461 if (!Visible) 462 return false; 463 464 if (DockPanel.DockWindows[dockState].Visible) 465 return false; 466 467 return DragHandler.DragSource.IsDockStateValid(dockState); 468 } 469 470 private bool ShouldPaneDiamondVisible() 471 { 472 if (DockPane == null) 473 return false; 474 475 if (!DockPanel.AllowEndUserNestedDocking) 476 return false; 477 478 return DragHandler.DragSource.CanDockTo(DockPane); 479 } 480 481 public override void Show(bool bActivate) 482 { 483 base.Show(bActivate); 484 Bounds = SystemInformation.VirtualScreen; 485 RefreshChanges(); 486 } 487 488 public void TestDrop() 489 { 490 Point pt = Control.MousePosition; 491 DockPane = DockHelper.PaneAtPoint(pt, DockPanel); 492 493 if (TestDrop(PanelLeft, pt) != DockStyle.None) 494 HitTestResult = PanelLeft; 495 else if (TestDrop(PanelRight, pt) != DockStyle.None) 496 HitTestResult = PanelRight; 497 else if (TestDrop(PanelTop, pt) != DockStyle.None) 498 HitTestResult = PanelTop; 499 else if (TestDrop(PanelBottom, pt) != DockStyle.None) 500 HitTestResult = PanelBottom; 501 else if (TestDrop(PanelFill, pt) != DockStyle.None) 502 HitTestResult = PanelFill; 503 else if (TestDrop(PaneDiamond, pt) != DockStyle.None) 504 HitTestResult = PaneDiamond; 505 else 506 HitTestResult = null; 507 508 if (HitTestResult != null) 509 { 510 if (HitTestResult is PaneIndicator) 511 DragHandler.Outline.Show(DockPane, HitTestResult.Status); 512 else 513 DragHandler.Outline.Show(DockPanel, HitTestResult.Status, FullPanelEdge); 514 } 515 } 516 517 private static DockStyle TestDrop(IHitTest hitTest, Point pt) 518 { 519 return hitTest.Status = hitTest.HitTest(pt); 520 } 521 } 522 523 private class DockOutline : DockOutlineBase 524 { 525 public DockOutline() 526 { 527 m_dragForm = new DragForm(); 528 SetDragForm(Rectangle.Empty); 529 DragForm.BackColor = SystemColors.ActiveCaption; 530 DragForm.Opacity = 0.5; 531 DragForm.Show(false); 532 } 533 534 DragForm m_dragForm; 535 private DragForm DragForm 536 { 537 get { return m_dragForm; } 538 } 539 540 protected override void OnShow() 541 { 542 CalculateRegion(); 543 } 544 545 protected override void OnClose() 546 { 547 DragForm.Close(); 548 } 549 550 private void CalculateRegion() 551 { 552 if (SameAsOldValue) 553 return; 554 555 if (!FloatWindowBounds.IsEmpty) 556 SetOutline(FloatWindowBounds); 557 else if (DockTo is DockPanel) 558 SetOutline(DockTo as DockPanel, Dock, (ContentIndex != 0)); 559 else if (DockTo is DockPane) 560 SetOutline(DockTo as DockPane, Dock, ContentIndex); 561 else 562 SetOutline(); 563 } 564 565 private void SetOutline() 566 { 567 SetDragForm(Rectangle.Empty); 568 } 569 570 private void SetOutline(Rectangle floatWindowBounds) 571 { 572 SetDragForm(floatWindowBounds); 573 } 574 575 private void SetOutline(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge) 576 { 577 Rectangle rect = fullPanelEdge ? dockPanel.DockArea : dockPanel.DocumentWindowBounds; 578 rect.Location = dockPanel.PointToScreen(rect.Location); 579 if (dock == DockStyle.Top) 580 { 581 int height = dockPanel.GetDockWindowSize(DockState.DockTop); 582 rect = new Rectangle(rect.X, rect.Y, rect.Width, height); 583 } 584 else if (dock == DockStyle.Bottom) 585 { 586 int height = dockPanel.GetDockWindowSize(DockState.DockBottom); 587 rect = new Rectangle(rect.X, rect.Bottom - height, rect.Width, height); 588 } 589 else if (dock == DockStyle.Left) 590 { 591 int width = dockPanel.GetDockWindowSize(DockState.DockLeft); 592 rect = new Rectangle(rect.X, rect.Y, width, rect.Height); 593 } 594 else if (dock == DockStyle.Right) 595 { 596 int width = dockPanel.GetDockWindowSize(DockState.DockRight); 597 rect = new Rectangle(rect.Right - width, rect.Y, width, rect.Height); 598 } 599 else if (dock == DockStyle.Fill) 600 { 601 rect = dockPanel.DocumentWindowBounds; 602 rect.Location = dockPanel.PointToScreen(rect.Location); 603 } 604 605 SetDragForm(rect); 606 } 607 608 private void SetOutline(DockPane pane, DockStyle dock, int contentIndex) 609 { 610 if (dock != DockStyle.Fill) 611 { 612 Rectangle rect = pane.DisplayingRectangle; 613 if (dock == DockStyle.Right) 614 rect.X += rect.Width / 2; 615 if (dock == DockStyle.Bottom) 616 rect.Y += rect.Height / 2; 617 if (dock == DockStyle.Left || dock == DockStyle.Right) 618 rect.Width -= rect.Width / 2; 619 if (dock == DockStyle.Top || dock == DockStyle.Bottom) 620 rect.Height -= rect.Height / 2; 621 rect.Location = pane.PointToScreen(rect.Location); 622 623 SetDragForm(rect); 624 } 625 else if (contentIndex == -1) 626 { 627 Rectangle rect = pane.DisplayingRectangle; 628 rect.Location = pane.PointToScreen(rect.Location); 629 SetDragForm(rect); 630 } 631 else 632 { 633 using (GraphicsPath path = pane.TabStripControl.GetOutline(contentIndex)) 634 { 635 RectangleF rectF = path.GetBounds(); 636 Rectangle rect = new Rectangle((int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height); 637 using (Matrix matrix = new Matrix(rect, new Point[] { new Point(0, 0), new Point(rect.Width, 0), new Point(0, rect.Height) })) 638 { 639 path.Transform(matrix); 640 } 641 Region region = new Region(path); 642 SetDragForm(rect, region); 643 } 644 } 645 } 646 647 private void SetDragForm(Rectangle rect) 648 { 649 DragForm.Bounds = rect; 650 if (rect == Rectangle.Empty) 651 DragForm.Region = new Region(Rectangle.Empty); 652 else if (DragForm.Region != null) 653 DragForm.Region = null; 654 } 655 656 private void SetDragForm(Rectangle rect, Region region) 657 { 658 DragForm.Bounds = rect; 659 DragForm.Region = region; 660 } 661 } 662 663 public DockDragHandler(DockPanel panel) 664 : base(panel) 665 { 666 } 667 668 public new IDockDragSource DragSource 669 { 670 get { return base.DragSource as IDockDragSource; } 671 set { base.DragSource = value; } 672 } 673 674 private DockOutlineBase m_outline; 675 public DockOutlineBase Outline 676 { 677 get { return m_outline; } 678 private set { m_outline = value; } 679 } 680 681 private DockIndicator m_indicator; 682 private DockIndicator Indicator 683 { 684 get { return m_indicator; } 685 set { m_indicator = value; } 686 } 687 688 private Rectangle m_floatOutlineBounds; 689 private Rectangle FloatOutlineBounds 690 { 691 get { return m_floatOutlineBounds; } 692 set { m_floatOutlineBounds = value; } 693 } 694 695 public void BeginDrag(IDockDragSource dragSource) 696 { 697 DragSource = dragSource; 698 699 if (!BeginDrag()) 700 { 701 DragSource = null; 702 return; 703 } 704 705 Outline = new DockOutline(); 706 Indicator = new DockIndicator(this); 707 Indicator.Show(false); 708 709 FloatOutlineBounds = DragSource.BeginDrag(StartMousePosition); 710 } 711 712 protected override void OnDragging() 713 { 714 TestDrop(); 715 } 716 717 protected override void OnEndDrag(bool abort) 718 { 719 DockPanel.SuspendLayout(true); 720 721 Outline.Close(); 722 Indicator.Close(); 723 724 EndDrag(abort); 725 726 // Queue a request to layout all children controls 727 DockPanel.PerformMdiClientLayout(); 728 729 DockPanel.ResumeLayout(true, true); 730 731 DragSource = null; 732 } 733 734 private void TestDrop() 735 { 736 Outline.FlagTestDrop = false; 737 738 Indicator.FullPanelEdge = ((Control.ModifierKeys & Keys.Shift) != 0); 739 740 if ((Control.ModifierKeys & Keys.Control) == 0) 741 { 742 Indicator.TestDrop(); 743 744 if (!Outline.FlagTestDrop) 745 { 746 DockPane pane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); 747 if (pane != null && DragSource.IsDockStateValid(pane.DockState)) 748 pane.TestDrop(DragSource, Outline); 749 } 750 751 if (!Outline.FlagTestDrop && DragSource.IsDockStateValid(DockState.Float)) 752 { 753 FloatWindow floatWindow = DockHelper.FloatWindowAtPoint(Control.MousePosition, DockPanel); 754 if (floatWindow != null) 755 floatWindow.TestDrop(DragSource, Outline); 756 } 757 } 758 else 759 Indicator.DockPane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); 760 761 if (!Outline.FlagTestDrop) 762 { 763 if (DragSource.IsDockStateValid(DockState.Float)) 764 { 765 Rectangle rect = FloatOutlineBounds; 766 rect.Offset(Control.MousePosition.X - StartMousePosition.X, Control.MousePosition.Y - StartMousePosition.Y); 767 Outline.Show(rect); 768 } 769 } 770 771 if (!Outline.FlagTestDrop) 772 { 773 Cursor.Current = Cursors.No; 774 Outline.Show(); 775 } 776 else 777 Cursor.Current = DragControl.Cursor; 778 } 779 780 private void EndDrag(bool abort) 781 { 782 if (abort) 783 return; 784 785 if (!Outline.FloatWindowBounds.IsEmpty) 786 DragSource.FloatAt(Outline.FloatWindowBounds); 787 else if (Outline.DockTo is DockPane) 788 { 789 DockPane pane = Outline.DockTo as DockPane; 790 DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); 791 } 792 else if (Outline.DockTo is DockPanel) 793 { 794 DockPanel panel = Outline.DockTo as DockPanel; 795 panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); 796 DragSource.DockTo(panel, Outline.Dock); 797 } 798 } 799 } 800 801 private DockDragHandler m_dockDragHandler = null; 802 private DockDragHandler GetDockDragHandler() 803 { 804 if (m_dockDragHandler == null) 805 m_dockDragHandler = new DockDragHandler(this); 806 return m_dockDragHandler; 807 } 808 809 internal void BeginDrag(IDockDragSource dragSource) 810 { 811 GetDockDragHandler().BeginDrag(dragSource); 812 } 379 using (Matrix matrix = new Matrix(PaneDiamond.ClientRectangle, pts)) { 380 graphicsPath.Transform(matrix); 381 } 382 region.Union(graphicsPath); 383 } 384 } else 385 PaneDiamond.Visible = false; 386 387 Region = region; 388 } 389 390 private bool ShouldPanelIndicatorVisible(DockState dockState) { 391 if (!Visible) 392 return false; 393 394 if (DockPanel.DockWindows[dockState].Visible) 395 return false; 396 397 return DragHandler.DragSource.IsDockStateValid(dockState); 398 } 399 400 private bool ShouldPaneDiamondVisible() { 401 if (DockPane == null) 402 return false; 403 404 if (!DockPanel.AllowEndUserNestedDocking) 405 return false; 406 407 return DragHandler.DragSource.CanDockTo(DockPane); 408 } 409 410 public override void Show(bool bActivate) { 411 base.Show(bActivate); 412 Bounds = SystemInformation.VirtualScreen; 413 RefreshChanges(); 414 } 415 416 public void TestDrop() { 417 Point pt = Control.MousePosition; 418 DockPane = DockHelper.PaneAtPoint(pt, DockPanel); 419 420 if (TestDrop(PanelLeft, pt) != DockStyle.None) 421 HitTestResult = PanelLeft; 422 else if (TestDrop(PanelRight, pt) != DockStyle.None) 423 HitTestResult = PanelRight; 424 else if (TestDrop(PanelTop, pt) != DockStyle.None) 425 HitTestResult = PanelTop; 426 else if (TestDrop(PanelBottom, pt) != DockStyle.None) 427 HitTestResult = PanelBottom; 428 else if (TestDrop(PanelFill, pt) != DockStyle.None) 429 HitTestResult = PanelFill; 430 else if (TestDrop(PaneDiamond, pt) != DockStyle.None) 431 HitTestResult = PaneDiamond; 432 else 433 HitTestResult = null; 434 435 if (HitTestResult != null) { 436 if (HitTestResult is PaneIndicator) 437 DragHandler.Outline.Show(DockPane, HitTestResult.Status); 438 else 439 DragHandler.Outline.Show(DockPanel, HitTestResult.Status, FullPanelEdge); 440 } 441 } 442 443 private static DockStyle TestDrop(IHitTest hitTest, Point pt) { 444 return hitTest.Status = hitTest.HitTest(pt); 445 } 446 } 447 448 private class DockOutline : DockOutlineBase { 449 public DockOutline() { 450 m_dragForm = new DragForm(); 451 SetDragForm(Rectangle.Empty); 452 DragForm.BackColor = SystemColors.ActiveCaption; 453 DragForm.Opacity = 0.5; 454 DragForm.Show(false); 455 } 456 457 DragForm m_dragForm; 458 private DragForm DragForm { 459 get { return m_dragForm; } 460 } 461 462 protected override void OnShow() { 463 CalculateRegion(); 464 } 465 466 protected override void OnClose() { 467 DragForm.Close(); 468 } 469 470 private void CalculateRegion() { 471 if (SameAsOldValue) 472 return; 473 474 if (!FloatWindowBounds.IsEmpty) 475 SetOutline(FloatWindowBounds); 476 else if (DockTo is DockPanel) 477 SetOutline(DockTo as DockPanel, Dock, (ContentIndex != 0)); 478 else if (DockTo is DockPane) 479 SetOutline(DockTo as DockPane, Dock, ContentIndex); 480 else 481 SetOutline(); 482 } 483 484 private void SetOutline() { 485 SetDragForm(Rectangle.Empty); 486 } 487 488 private void SetOutline(Rectangle floatWindowBounds) { 489 SetDragForm(floatWindowBounds); 490 } 491 492 private void SetOutline(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge) { 493 Rectangle rect = fullPanelEdge ? dockPanel.DockArea : dockPanel.DocumentWindowBounds; 494 rect.Location = dockPanel.PointToScreen(rect.Location); 495 if (dock == DockStyle.Top) { 496 int height = dockPanel.GetDockWindowSize(DockState.DockTop); 497 rect = new Rectangle(rect.X, rect.Y, rect.Width, height); 498 } else if (dock == DockStyle.Bottom) { 499 int height = dockPanel.GetDockWindowSize(DockState.DockBottom); 500 rect = new Rectangle(rect.X, rect.Bottom - height, rect.Width, height); 501 } else if (dock == DockStyle.Left) { 502 int width = dockPanel.GetDockWindowSize(DockState.DockLeft); 503 rect = new Rectangle(rect.X, rect.Y, width, rect.Height); 504 } else if (dock == DockStyle.Right) { 505 int width = dockPanel.GetDockWindowSize(DockState.DockRight); 506 rect = new Rectangle(rect.Right - width, rect.Y, width, rect.Height); 507 } else if (dock == DockStyle.Fill) { 508 rect = dockPanel.DocumentWindowBounds; 509 rect.Location = dockPanel.PointToScreen(rect.Location); 510 } 511 512 SetDragForm(rect); 513 } 514 515 private void SetOutline(DockPane pane, DockStyle dock, int contentIndex) { 516 if (dock != DockStyle.Fill) { 517 Rectangle rect = pane.DisplayingRectangle; 518 if (dock == DockStyle.Right) 519 rect.X += rect.Width / 2; 520 if (dock == DockStyle.Bottom) 521 rect.Y += rect.Height / 2; 522 if (dock == DockStyle.Left || dock == DockStyle.Right) 523 rect.Width -= rect.Width / 2; 524 if (dock == DockStyle.Top || dock == DockStyle.Bottom) 525 rect.Height -= rect.Height / 2; 526 rect.Location = pane.PointToScreen(rect.Location); 527 528 SetDragForm(rect); 529 } else if (contentIndex == -1) { 530 Rectangle rect = pane.DisplayingRectangle; 531 rect.Location = pane.PointToScreen(rect.Location); 532 SetDragForm(rect); 533 } else { 534 using (GraphicsPath path = pane.TabStripControl.GetOutline(contentIndex)) { 535 RectangleF rectF = path.GetBounds(); 536 Rectangle rect = new Rectangle((int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height); 537 using (Matrix matrix = new Matrix(rect, new Point[] { new Point(0, 0), new Point(rect.Width, 0), new Point(0, rect.Height) })) { 538 path.Transform(matrix); 539 } 540 Region region = new Region(path); 541 SetDragForm(rect, region); 542 } 543 } 544 } 545 546 private void SetDragForm(Rectangle rect) { 547 DragForm.Bounds = rect; 548 if (rect == Rectangle.Empty) 549 DragForm.Region = new Region(Rectangle.Empty); 550 else if (DragForm.Region != null) 551 DragForm.Region = null; 552 } 553 554 private void SetDragForm(Rectangle rect, Region region) { 555 DragForm.Bounds = rect; 556 DragForm.Region = region; 557 } 558 } 559 560 public DockDragHandler(DockPanel panel) 561 : base(panel) { 562 } 563 564 public new IDockDragSource DragSource { 565 get { return base.DragSource as IDockDragSource; } 566 set { base.DragSource = value; } 567 } 568 569 private DockOutlineBase m_outline; 570 public DockOutlineBase Outline { 571 get { return m_outline; } 572 private set { m_outline = value; } 573 } 574 575 private DockIndicator m_indicator; 576 private DockIndicator Indicator { 577 get { return m_indicator; } 578 set { m_indicator = value; } 579 } 580 581 private Rectangle m_floatOutlineBounds; 582 private Rectangle FloatOutlineBounds { 583 get { return m_floatOutlineBounds; } 584 set { m_floatOutlineBounds = value; } 585 } 586 587 public void BeginDrag(IDockDragSource dragSource) { 588 DragSource = dragSource; 589 590 if (!BeginDrag()) { 591 DragSource = null; 592 return; 593 } 594 595 Outline = new DockOutline(); 596 Indicator = new DockIndicator(this); 597 Indicator.Show(false); 598 599 FloatOutlineBounds = DragSource.BeginDrag(StartMousePosition); 600 } 601 602 protected override void OnDragging() { 603 TestDrop(); 604 } 605 606 protected override void OnEndDrag(bool abort) { 607 DockPanel.SuspendLayout(true); 608 609 Outline.Close(); 610 Indicator.Close(); 611 612 EndDrag(abort); 613 614 // Queue a request to layout all children controls 615 DockPanel.PerformMdiClientLayout(); 616 617 DockPanel.ResumeLayout(true, true); 618 619 DragSource = null; 620 } 621 622 private void TestDrop() { 623 Outline.FlagTestDrop = false; 624 625 Indicator.FullPanelEdge = ((Control.ModifierKeys & Keys.Shift) != 0); 626 627 if ((Control.ModifierKeys & Keys.Control) == 0) { 628 Indicator.TestDrop(); 629 630 if (!Outline.FlagTestDrop) { 631 DockPane pane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); 632 if (pane != null && DragSource.IsDockStateValid(pane.DockState)) 633 pane.TestDrop(DragSource, Outline); 634 } 635 636 if (!Outline.FlagTestDrop && DragSource.IsDockStateValid(DockState.Float)) { 637 FloatWindow floatWindow = DockHelper.FloatWindowAtPoint(Control.MousePosition, DockPanel); 638 if (floatWindow != null) 639 floatWindow.TestDrop(DragSource, Outline); 640 } 641 } else 642 Indicator.DockPane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); 643 644 if (!Outline.FlagTestDrop) { 645 if (DragSource.IsDockStateValid(DockState.Float)) { 646 Rectangle rect = FloatOutlineBounds; 647 rect.Offset(Control.MousePosition.X - StartMousePosition.X, Control.MousePosition.Y - StartMousePosition.Y); 648 Outline.Show(rect); 649 } 650 } 651 652 if (!Outline.FlagTestDrop) { 653 Cursor.Current = Cursors.No; 654 Outline.Show(); 655 } else 656 Cursor.Current = DragControl.Cursor; 657 } 658 659 private void EndDrag(bool abort) { 660 if (abort) 661 return; 662 663 if (!Outline.FloatWindowBounds.IsEmpty) 664 DragSource.FloatAt(Outline.FloatWindowBounds); 665 else if (Outline.DockTo is DockPane) { 666 DockPane pane = Outline.DockTo as DockPane; 667 DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); 668 } else if (Outline.DockTo is DockPanel) { 669 DockPanel panel = Outline.DockTo as DockPanel; 670 panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); 671 DragSource.DockTo(panel, Outline.Dock); 672 } 673 } 813 674 } 675 676 private DockDragHandler m_dockDragHandler = null; 677 private DockDragHandler GetDockDragHandler() { 678 if (m_dockDragHandler == null) 679 m_dockDragHandler = new DockDragHandler(this); 680 return m_dockDragHandler; 681 } 682 683 internal void BeginDrag(IDockDragSource dragSource) { 684 GetDockDragHandler().BeginDrag(dragSource); 685 } 686 } 814 687 }
Note: See TracChangeset
for help on using the changeset viewer.