public static void ForTarget(Window target) { var wnd = new AdornerWindow(target); wnd.Content = new DockTargetPanel { Visibility = Visibility.Collapsed }; targetLookup.Add(target, wnd); }
private static void TrackWindow(Window wnd) { AdornerWindow.ForTarget(wnd); if (wnd == Application.Current.MainWindow) { return; } var hwnd = PresentationSource.FromVisual(wnd) as HwndSource; hwnd.RemoveHook(WndProc); hwnd.AddHook(WndProc); }
public WindowInfo(Window wnd) { Window = wnd; Adorner = AdornerWindow.FromTarget(wnd); WindowBounds = new Rect(wnd.PointToScreenScaled(new Point()), wnd.RenderSize); var container = trackedElements[wnd].OfType <DockContainer>().FirstOrDefault(); if (container?.DockCommand != null) { DockBounds = Tuple.Create(new Rect(container.PointToScreenScaled(new Point()), container.RenderSize), container); } var docPanel = trackedElements[wnd].OfType <DocumentContainer>().FirstOrDefault(); if (docPanel?.DockCommand != null) { DocumentBounds = Tuple.Create(new Rect(docPanel.PointToScreenScaled(new Point()), docPanel.RenderSize), docPanel); } WellBounds = new List <Tuple <Rect, TabWellBase> >(); foreach (var w in trackedElements[wnd].OfType <TabWellBase>().Where(w => w.IsVisible && w.DockCommand != null)) { WellBounds.Add(Tuple.Create(new Rect(w.PointToScreenScaled(new Point()), w.RenderSize), w)); } TabBounds = new List <Tuple <Rect, TabWellItem> >(); foreach (var g in trackedElements[wnd].OfType <TabWellItem>().Where(t => t.IsVisible && t.ActualHeight > 0 && t.ActualWidth > 0).GroupBy(t => t.FindVisualAncestor <TabWellBase>())) { if (!WellBounds.Any(b => b.Item2 == g.Key)) { continue; } foreach (var t in g) { TabBounds.Add(Tuple.Create(new Rect(t.PointToScreenScaled(new Point()), t.RenderSize), t)); } } }