private void SetOutline(DockPane pane, DockStyle dock, int contentIndex) { if (dock != DockStyle.Fill) { var rect = pane.DisplayingRectangle; if (dock == DockStyle.Right) { rect.X += rect.Width / 2; } if (dock == DockStyle.Bottom) { rect.Y += rect.Height / 2; } if (dock == DockStyle.Left || dock == DockStyle.Right) { rect.Width -= rect.Width / 2; } if (dock == DockStyle.Top || dock == DockStyle.Bottom) { rect.Height -= rect.Height / 2; } rect.Location = pane.PointToScreen(rect.Location); SetDragForm(rect); } else if (contentIndex == -1) { var rect = pane.DisplayingRectangle; rect.Location = pane.PointToScreen(rect.Location); SetDragForm(rect); } else { using (var path = pane.TabStripControl.GetOutline(contentIndex)) { var rectF = path.GetBounds(); var rect = new Rectangle((int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height); using (var matrix = new Matrix(rect, new[] { new Point(0, 0), new Point(rect.Width, 0), new Point(0, rect.Height) })) { path.Transform(matrix); } var region = new Region(path); SetDragForm(rect, region); } } }
protected override GraphicsPath GetOutline(int index) { Point[] pts = new Point[8]; if (Appearance == DockPane.AppearanceStyle.Document) { Rectangle rectTab = GetTabRectangle(index); rectTab.Intersect(TabsRectangle); int y = DockPane.PointToClient(PointToScreen(new Point(0, rectTab.Bottom))).Y; Rectangle rectPaneClient = DockPane.ClientRectangle; pts[0] = DockPane.PointToScreen(new Point(rectPaneClient.Left, y)); pts[1] = PointToScreen(new Point(rectTab.Left, rectTab.Bottom)); pts[2] = PointToScreen(new Point(rectTab.Left, rectTab.Top)); pts[3] = PointToScreen(new Point(rectTab.Right, rectTab.Top)); pts[4] = PointToScreen(new Point(rectTab.Right, rectTab.Bottom)); pts[5] = DockPane.PointToScreen(new Point(rectPaneClient.Right, y)); pts[6] = DockPane.PointToScreen(new Point(rectPaneClient.Right, rectPaneClient.Bottom)); pts[7] = DockPane.PointToScreen(new Point(rectPaneClient.Left, rectPaneClient.Bottom)); } else { Rectangle rectTab = GetTabRectangle(index); rectTab.Intersect(TabsRectangle); int y = DockPane.PointToClient(PointToScreen(new Point(0, rectTab.Top))).Y; Rectangle rectPaneClient = DockPane.ClientRectangle; pts[0] = DockPane.PointToScreen(new Point(rectPaneClient.Left, rectPaneClient.Top)); pts[1] = DockPane.PointToScreen(new Point(rectPaneClient.Right, rectPaneClient.Top)); pts[2] = DockPane.PointToScreen(new Point(rectPaneClient.Right, y)); pts[3] = PointToScreen(new Point(rectTab.Right, rectTab.Top)); pts[4] = PointToScreen(new Point(rectTab.Right, rectTab.Bottom)); pts[5] = PointToScreen(new Point(rectTab.Left, rectTab.Bottom)); pts[6] = PointToScreen(new Point(rectTab.Left, rectTab.Top)); pts[7] = DockPane.PointToScreen(new Point(rectPaneClient.Left, y)); } GraphicsPath path = new GraphicsPath(); path.AddLines(pts); return(path); }