void ShowResizerOverlayWindow(Resizer splitter) { Point ptTopLeftScreen = this.PointToScreenDPI(new Point()); _resizerGhost = new Border() { Background = Brushes.Black, Opacity = 0.7 }; Size actualSize = this.TransformedActualSize(); if (Orientation == System.Windows.Controls.Orientation.Horizontal) { _resizerGhost.Width = 5.0; _resizerGhost.Height = actualSize.Height; } else { _resizerGhost.Height = 5.0; _resizerGhost.Width = actualSize.Width; } _initialStartPoint = splitter.PointToScreenDPI(new Point()) - this.PointToScreenDPI(new Point()); if (Orientation == System.Windows.Controls.Orientation.Horizontal) { Canvas.SetLeft(_resizerGhost, _initialStartPoint.X); } else { Canvas.SetTop(_resizerGhost, _initialStartPoint.Y); } Canvas panelHostResizer = new Canvas() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = System.Windows.VerticalAlignment.Stretch }; panelHostResizer.Children.Add(_resizerGhost); _resizerWindowHost = new Window() { ResizeMode = ResizeMode.NoResize, WindowStyle = System.Windows.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 //, //LayoutTransform = (MatrixTransform)this.TansformToAncestor() }; _resizerWindowHost.Show(); }
void SetupSplitters() { if (!splitterListIsDirty) return; if (setupSplitters) return; setupSplitters = true; while (_splitterList.Count > 0) { Resizer splitter = _splitterList[0]; splitter.DragStarted -= new DragStartedEventHandler(splitter_DragStarted); splitter.DragDelta -= new DragDeltaEventHandler(splitter_DragDelta); splitter.DragCompleted -= new DragCompletedEventHandler(splitter_DragCompleted); _splitterList.Remove(splitter); Children.Remove(splitter); } int i = 0;//child index int j = 0;//splitter index while (i < Children.Count - 1) { if (j == _splitterList.Count) { Resizer splitter = new Resizer(); splitter.Cursor = this.Orientation == Orientation.Horizontal ? Cursors.SizeWE : Cursors.SizeNS; _splitterList.Add(splitter); splitter.DragStarted += new DragStartedEventHandler(splitter_DragStarted); splitter.DragDelta += new DragDeltaEventHandler(splitter_DragDelta); splitter.DragCompleted += new DragCompletedEventHandler(splitter_DragCompleted); Children.Insert(i + 1, splitter); } i += 2; j++; } for (j = 0; j < _splitterList.Count; j++) { _splitterList[j].Width = (Orientation == Orientation.Horizontal) ? 6 : double.NaN; _splitterList[j].Height = (Orientation == Orientation.Vertical) ? 6 : double.NaN; } #if DEBUG Debug.Assert(_splitterList.Count == Children.Count / 2); i = 0; while (Children.Count > 0) { Debug.Assert(Children[i] != null); Debug.Assert(!(Children[i] is Resizer)); i++; if (i >= Children.Count) break; Debug.Assert((Children[i] is Resizer)); i++; } #endif splitterListIsDirty = false; setupSplitters = false; }