private DockPane PaneAtPointNativeFloatingWindows(IDragSource source, double deltaX, double deltaY, out bool stopHitTest) { stopHitTest = false; FloatingWindowCollection floatingWindows = DockControl.FloatingWindows; Point pt = GetStartMousePosition(_overlayWindow); pt.Offset(deltaX, deltaY); for (int i = floatingWindows.Count - 1; i >= 0; i--) { FloatingWindow floatingWindow = floatingWindows[i]; if (!floatingWindow.IsVisible) { continue; } NativeFloatingWindow nativeWindow = NativeFloatingWindow.GetNativeFloatingWindow(floatingWindow); Rect windowBounds = nativeWindow.GetPreviewBounds(_overlayWindow); stopHitTest = windowBounds.Contains(pt); if (stopHitTest) { pt = GetStartMousePosition(nativeWindow); pt.Offset(deltaX, deltaY); var result = PaneFromHitTestResult(source, VisualTreeHelper.HitTest(nativeWindow, pt)); if (result == null || !source.CanDrop(result)) { stopHitTest = false; continue; } return(result); } } return(null); }
/// <summary>Create a new dock container</summary> public DockContainer() { InitializeComponent(); Options = new OptionsData(); m_all_content = new HashSet <DockControl>(); ActiveContentManager = new ActiveContentManager(this); // The auto hide tab strips dock around the edge of the main dock container // but remain hidden unless there are auto hide panels with content. // The rest of the docking area is within 'centre' which contains the // root branch (filling the canvas) and four AutoHidePanels. // Add a Canvas for the centre area and add the root branch (filling the canvas) var centre = new Canvas { Name = "DockContainerCentre" }; // Create the auto hide panels AutoHidePanels = new AutoHidePanelCollection(this, centre); // Create a collection for floating windows FloatingWindows = new FloatingWindowCollection(this); // Add the centre content Children.Add2(centre); Root = centre.Children.Add2(new Branch(this, DockSizeData.Quarters)); Root.SetBinding(Branch.WidthProperty, new Binding(nameof(Canvas.ActualWidth)) { Source = centre }); Root.SetBinding(Branch.HeightProperty, new Binding(nameof(Canvas.ActualHeight)) { Source = centre }); // Ensure the default centre pane exists Root.PruneBranches(); ActivePane = (DockPane?)Root.Descendants[EDockSite.Centre].Item ?? throw new ArgumentNullException("Expected a DockPane"); // Create Commands CmdLoadLayout = Command.Create(this, CmdLoadLayoutInternal); CmdSaveLayout = Command.Create(this, CmdSaveLayoutInternal); CmdResetLayout = Command.Create(this, CmdResetLayoutInternal); }
private void TargetAtPointNativeWindows(double deltaX, double deltaY) { Point pt = GetStartMousePosition(_overlayWindow); pt.Offset(deltaX, deltaY); VisualTreeHelper.HitTest(_overlayWindow, null, new HitTestResultCallback(TargetAtPointHitTestResultCallback), new PointHitTestParameters(pt)); if (_targetAtPoint.HasValue) { return; } FloatingWindowCollection floatingWindows = DockControl.FloatingWindows; for (int i = floatingWindows.Count - 1; i >= 0; i--) { FloatingWindow floatingWindow = floatingWindows[i]; if (!floatingWindow.IsVisible) { continue; } NativeFloatingWindow nativeWindow = NativeFloatingWindow.GetNativeFloatingWindow(floatingWindow); if (nativeWindow == null) { continue; } Rect windowBounds = nativeWindow.GetPreviewBounds(_overlayWindow); if (windowBounds.Contains(pt)) { pt = GetStartMousePosition(nativeWindow); pt.Offset(deltaX, deltaY); _targetAtPoint = TargetFromHitTestResult(VisualTreeHelper.HitTest(nativeWindow, pt)); if (!_targetAtPoint.HasValue) { _targetAtPoint = Target.Empty; } return; } } }
private DockPane PaneAtPointWpfFloatingWindows(IDragSource source, double deltaX, double deltaY, out bool stopHitTest) { stopHitTest = false; FloatingWindowCollection floatingWindows = DockControl.FloatingWindows; Point pt = GetStartMousePosition(_wpfFloatingWindowClient); pt.Offset(deltaX, deltaY); for (int i = floatingWindows.Count - 1; i >= 0; i--) { FloatingWindow floatingWindow = floatingWindows[i]; if (!floatingWindow.IsVisible) { continue; } WpfFloatingWindow window = _wpfFloatingWindowClient.ItemContainerGenerator.ContainerFromItem(floatingWindow) as WpfFloatingWindow; if (window == null) { continue; } Rect windowBounds = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); stopHitTest = windowBounds.Contains(pt); if (stopHitTest) { pt = _wpfFloatingWindowClient.TranslatePoint(pt, window); var result = PaneFromHitTestResult(source, VisualTreeHelper.HitTest(window, pt)); if (result == null || !source.CanDrop(result)) { stopHitTest = false; continue; } return(result); } } return(null); }