private void ShowOverlayWindow() { _overlayWindow = OverlayWindow.Show(DockControl); SetStartMousePosition(_overlayWindow, _overlayWindow.PointFromScreen(_startMousePoint)); foreach (FloatingWindow floatingWindow in DockControl.FloatingWindows) { if (!floatingWindow.IsVisible) { continue; } NativeFloatingWindow nativeWindow = NativeFloatingWindow.GetNativeFloatingWindow(floatingWindow); if (nativeWindow == null) { continue; } Point pointFromScreen = _startMousePoint; try { pointFromScreen = nativeWindow.PointFromScreen(_startMousePoint); } catch (Exception e) { Debug.WriteLine(@"pointFromScreen: " + pointFromScreen); Debug.WriteLine(e); } SetStartMousePosition(nativeWindow, pointFromScreen); } }
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); }
private void ShowOverlayWindow() { _overlayWindow = OverlayWindow.Show(DockControl); SetStartMousePosition(_overlayWindow, _overlayWindow.PointFromScreen(_startMousePoint)); foreach (FloatingWindow floatingWindow in DockControl.FloatingWindows) { NativeFloatingWindow nativeWindow = NativeFloatingWindow.GetNativeFloatingWindow(floatingWindow); SetStartMousePosition(nativeWindow, nativeWindow.PointFromScreen(_startMousePoint)); } }
private void OnFloatingWindowsChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { FloatingWindow floatingWindow = (FloatingWindow)e.NewItems[0]; NativeFloatingWindow.SetNativeFloatingWindow(floatingWindow, new NativeFloatingWindow(floatingWindow)); } else if (e.Action == NotifyCollectionChangedAction.Remove) { FloatingWindow floatingWindow = (FloatingWindow)e.OldItems[0]; NativeFloatingWindow.SetNativeFloatingWindow(floatingWindow, null); } }
internal static void SetNativeFloatingWindow(FloatingWindow floatingWindow, NativeFloatingWindow value) { NativeFloatingWindow oldValue = GetNativeFloatingWindow(floatingWindow); if (oldValue != null) { oldValue.DataContext = null; // this should fix "Cannot set Visibility or call Show or ShowDialog after window has closed." exception oldValue.Close(); } if (value == null) { floatingWindow.ClearValue(NativeFloatingWindowProperty); } else { floatingWindow.SetValue(NativeFloatingWindowProperty, value); } }
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; } } }