private bool CheckGroupDock(IdePanel idePanel) { if (idePanel == null) return false; var headerBounds = idePanel.RectangleToScreen(idePanel.Header.Bounds); if (!headerBounds.Contains(Cursor.Position)) return false; DockSuggestion = new DockSuggestion { Bounds = headerBounds, JoinPanel = idePanel }; return true; }
private void SuggestClosestSplit(LayoutSplit closestSplit, List<LayoutSplit> splits, Rectangle absoluteBounds, bool horizontal) { var cursorIndex = (horizontal ? Cursor.Position.X : Cursor.Position.Y); var closestSplitDistance = Math.Abs(cursorIndex - closestSplit.Location); foreach (var split in splits) { var distance = Math.Abs(cursorIndex - split.Location); if (distance < closestSplitDistance) { closestSplitDistance = distance; closestSplit = split; } } Rectangle suggestion; if (horizontal) { var targetWidth = absoluteBounds.Width / (splits.Count + 1); suggestion = new Rectangle(closestSplit.Location - (targetWidth / 2), absoluteBounds.Top, targetWidth, absoluteBounds.Height); var oversized = suggestion.Right - absoluteBounds.Right; if (oversized > 0) suggestion.X -= oversized; oversized = absoluteBounds.Left - suggestion.Left; if (oversized > 0) suggestion.X += oversized; } else { var targetHeight = absoluteBounds.Height / (splits.Count + 1); suggestion = new Rectangle(absoluteBounds.Left, closestSplit.Location - (targetHeight / 2), absoluteBounds.Width, targetHeight); var oversized = suggestion.Bottom - absoluteBounds.Bottom; if (oversized > 0) suggestion.Y -= oversized; oversized = absoluteBounds.Top - suggestion.Top; if (oversized > 0) suggestion.Y += oversized; } if (DockSuggestion == null || suggestion != DockSuggestion.Bounds) { DockSuggestion = new DockSuggestion { Bounds = suggestion, LayoutSplit = closestSplit }; } }