private static void WindowFocusChanging(object sender, FocusChangeEventArgs e) { foreach (var manager in _managers) { var hostContainingFocusedHandle = manager.FindLogicalChildren <HwndHost>().FirstOrDefault(hw => Win32Helper.IsChild(hw.Handle, e.GotFocusWinHandle)); if (hostContainingFocusedHandle != null) { var parentAnchorable = hostContainingFocusedHandle.FindVisualAncestor <LayoutAnchorableControl>(); if (parentAnchorable != null) { _modelFocusedWindowHandle[parentAnchorable.Model] = e.GotFocusWinHandle; if (parentAnchorable.Model != null) { parentAnchorable.Model.IsActive = true; } } else { var parentDocument = hostContainingFocusedHandle.FindVisualAncestor <LayoutDocumentControl>(); if (parentDocument != null) { _modelFocusedWindowHandle[parentDocument.Model] = e.GotFocusWinHandle; if (parentDocument.Model != null) { parentDocument.Model.IsActive = true; } } } } } }
private static void WindowFocusChanging(object sender, FocusChangeEventArgs e) { Func <HwndHost, bool> func = null; foreach (DockingManager _manager in FocusElementManager._managers) { IEnumerable <HwndHost> hwndHosts = _manager.FindLogicalChildren <HwndHost>(); Func <HwndHost, bool> func1 = func; if (func1 == null) { Func <HwndHost, bool> func2 = (HwndHost hw) => Win32Helper.IsChild(hw.Handle, e.GotFocusWinHandle); Func <HwndHost, bool> func3 = func2; func = func2; func1 = func3; } HwndHost hwndHost = hwndHosts.FirstOrDefault <HwndHost>(func1); if (hwndHost == null) { continue; } LayoutAnchorableControl gotFocusWinHandle = hwndHost.FindVisualAncestor <LayoutAnchorableControl>(); if (gotFocusWinHandle == null) { LayoutDocumentControl layoutDocumentControl = hwndHost.FindVisualAncestor <LayoutDocumentControl>(); if (layoutDocumentControl == null) { continue; } FocusElementManager._modelFocusedWindowHandle[layoutDocumentControl.Model] = e.GotFocusWinHandle; if (layoutDocumentControl.Model == null) { continue; } layoutDocumentControl.Model.IsActive = true; } else { FocusElementManager._modelFocusedWindowHandle[gotFocusWinHandle.Model] = e.GotFocusWinHandle; if (gotFocusWinHandle.Model == null) { continue; } gotFocusWinHandle.Model.IsActive = true; } } }
static void WindowFocusChanging(object sender, FocusChangeEventArgs e) { foreach (var manager in _managers) { var hostContainingFocusedHandle = manager.FindLogicalChildren<HwndHost>().FirstOrDefault(hw => Win32Helper.IsChild(hw.Handle, e.GotFocusWinHandle)); if (hostContainingFocusedHandle != null) { var parentAnchorable = hostContainingFocusedHandle.FindVisualAncestor<LayoutAnchorableControl>(); if (parentAnchorable != null) { _modelFocusedWindowHandle[parentAnchorable.Model] = e.GotFocusWinHandle; if (parentAnchorable.Model != null) parentAnchorable.Model.IsActive = true; } else { var parentDocument = hostContainingFocusedHandle.FindVisualAncestor<LayoutDocumentControl>(); if (parentDocument != null) { _modelFocusedWindowHandle[parentDocument.Model] = e.GotFocusWinHandle; if (parentDocument.Model != null) parentDocument.Model.IsActive = true; } } } } }