private void ShowResizerOverlayWindow(LayoutGridResizerControl splitter) { _resizerGhost = new Border() { Background = splitter.BackgroundWhileDragging, Opacity = splitter.OpacityWhileDragging }; var areaElement = _manager.GetAutoHideAreaElement(); _internalHost.TransformActualSizeToAncestor(); Point ptTopLeftScreen = areaElement.PointToScreenDpiWithoutFlowDirection(new Point()); var managerSize = areaElement.TransformActualSizeToAncestor(); Size windowSize; if (_side == AnchorSide.Right || _side == AnchorSide.Left) { windowSize = new Size( managerSize.Width - 25.0 + splitter.ActualWidth, managerSize.Height); _resizerGhost.Width = splitter.ActualWidth; _resizerGhost.Height = windowSize.Height; ptTopLeftScreen.Offset(25, 0.0); } else { windowSize = new Size( managerSize.Width, managerSize.Height - _model.AutoHideMinHeight - 25.0 + splitter.ActualHeight); _resizerGhost.Height = splitter.ActualHeight; _resizerGhost.Width = windowSize.Width; ptTopLeftScreen.Offset(0.0, 25.0); } _initialStartPoint = splitter.PointToScreenDpiWithoutFlowDirection(new Point()) - ptTopLeftScreen; if (_side == AnchorSide.Right || _side == AnchorSide.Left) { Canvas.SetLeft(_resizerGhost, _initialStartPoint.X); } else { Canvas.SetTop(_resizerGhost, _initialStartPoint.Y); } Canvas panelHostResizer = new Canvas() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; panelHostResizer.Children.Add(_resizerGhost); _resizerWindowHost = new Window() { ResizeMode = ResizeMode.NoResize, WindowStyle = WindowStyle.None, ShowInTaskbar = false, AllowsTransparency = true, Background = null, Width = windowSize.Width, Height = windowSize.Height, Left = ptTopLeftScreen.X, Top = ptTopLeftScreen.Y, ShowActivated = false, Owner = Window.GetWindow(this), Content = panelHostResizer }; _resizerWindowHost.Show(); }
private void ShowResizerOverlayWindow(LayoutGridResizerControl splitter) { _resizerGhost = new Border() { Background = splitter.BackgroundWhileDragging, Opacity = splitter.OpacityWhileDragging }; int indexOfResizer = InternalChildren.IndexOf(splitter); var prevChild = InternalChildren[indexOfResizer - 1] as FrameworkElement; var nextChild = GetNextVisibleChild(indexOfResizer); var prevChildActualSize = prevChild.TransformActualSizeToAncestor(); var nextChildActualSize = nextChild.TransformActualSizeToAncestor(); var layoutControl = prevChild as ILayoutControl; if (layoutControl != null) { var prevChildModel = (ILayoutPositionableElement)layoutControl.Model; var control = nextChild as ILayoutControl; if (control != null) { var nextChildModel = (ILayoutPositionableElement)control.Model; Point ptTopLeftScreen = prevChild.PointToScreenDpiWithoutFlowDirection(new Point()); Size actualSize; if (Orientation == Orientation.Horizontal) { actualSize = new Size( prevChildActualSize.Width - prevChildModel.DockMinWidth + splitter.ActualWidth + nextChildActualSize.Width - nextChildModel.DockMinWidth, nextChildActualSize.Height); _resizerGhost.Width = splitter.ActualWidth; _resizerGhost.Height = actualSize.Height; ptTopLeftScreen.Offset(prevChildModel.DockMinWidth, 0.0); } else { actualSize = new Size( prevChildActualSize.Width, prevChildActualSize.Height - prevChildModel.DockMinHeight + splitter.ActualHeight + nextChildActualSize.Height - nextChildModel.DockMinHeight); _resizerGhost.Height = splitter.ActualHeight; _resizerGhost.Width = actualSize.Width; ptTopLeftScreen.Offset(0.0, prevChildModel.DockMinHeight); } _initialStartPoint = splitter.PointToScreenDpiWithoutFlowDirection(new Point()) - ptTopLeftScreen; if (Orientation == Orientation.Horizontal) { Canvas.SetLeft(_resizerGhost, _initialStartPoint.X); } else { Canvas.SetTop(_resizerGhost, _initialStartPoint.Y); } Canvas panelHostResizer = new Canvas() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; panelHostResizer.Children.Add(_resizerGhost); _resizerWindowHost = new Window() { SizeToContent = SizeToContent.Manual, ResizeMode = ResizeMode.NoResize, WindowStyle = WindowStyle.None, ShowInTaskbar = false, AllowsTransparency = true, Background = null, Width = actualSize.Width, Height = actualSize.Height, Left = ptTopLeftScreen.X, Top = ptTopLeftScreen.Y, ShowActivated = false, //Owner = Window.GetWindow(this), Content = panelHostResizer }; } } _resizerWindowHost.Loaded += (s, e) => { _resizerWindowHost.SetParentToMainWindowOf(this); }; _resizerWindowHost.Show(); }