public DockPaneLayoutEngine(DockPaneBase target)
     : base(target)
 {
     _ownNodes.Add(this);
     Align = DockDirection.None;
     SplitterVisible = true;
 }
        /// <summary>DockingHelperを表示し、マウスのイテレータへの当たり判定を行います。</summary>
        /// <param name="bay">DockingHelperを重ねるDockBayBase</param>
        /// <param name="pane">PaneHelperを重ねるDockPaneBase</param>
        /// <returns>マウスオーバーされてるイテレータ</returns>
        public DragDropEffects GetDragDropEffect(DockBayBase bay, DockPaneBase pane)
        {
            //引数bayへDockingHelperを重ねる
            var rect = new Rect(bay.PointToScreen(new Point(0, 0)), bay.RenderSize);
            Left = rect.X;
            Top = rect.Y;
            Width = rect.Width;
            Height = rect.Height;
            Visibility = Visibility.Visible;

            if (pane != null)
            {
                //引数paneの中央へ重なるようにPaneHelperを移動させる
                var p = pane.TranslatePoint(new Point(pane.ContentLeft, pane.ContentTop), this);
                PaneHelper.Margin = new Thickness(
                    ((pane.ContentWidth - PaneHelper.RenderSize.Width) / 2) + p.X,
                    ((pane.ContentHeight - PaneHelper.RenderSize.Height) / 2) + p.Y,
                    0, 0);
            }

            //マウスポインタ座標からDragDropEffectsを求める
            var pt = Mouse.GetPosition(this);
            var res = (new[]
            {
                new {Ind = (FrameworkElement)InTopIndicator, Eff = DragDropEffects.Top},
                new {Ind = (FrameworkElement)InBottomIndicator, Eff = DragDropEffects.Bottom},
                new {Ind = (FrameworkElement)InLeftIndicator, Eff = DragDropEffects.Left},
                new {Ind = (FrameworkElement)InRightIndicator, Eff = DragDropEffects.Right},
                new {Ind = (FrameworkElement)OutTopIndicator, Eff = DragDropEffects.OuterTop},
                new {Ind = (FrameworkElement)OutBottomIndicator, Eff = DragDropEffects.OuterBottom},
                new {Ind = (FrameworkElement)OutLeftIndicator, Eff = DragDropEffects.OuterLeft},
                new {Ind = (FrameworkElement)OutRightIndicator, Eff = DragDropEffects.OuterRight},
                new {Ind = (FrameworkElement)InCenterIndicator, Eff = DragDropEffects.Fill},
                new {Ind = (FrameworkElement)bay, Eff = DragDropEffects.Enter},
            })
            .Where(pair =>
                pair.Ind.Visibility == System.Windows.Visibility.Visible &&
                new Rect(pair.Ind.TranslatePoint(new Point(), this), pair.Ind.RenderSize).Contains(pt))
            .Select(pair => pair.Eff)
            .Concat(new[] { DragDropEffects.None })
            .First();

            return res;
        }
        void wnd_WindowDraged(object sender, EventArgs e)
        {
            //Helperを表示するBayがあるかどうかを調べる
            var mvForm = (DockFloatingWindow)sender;
            var hoverBay = _baysOrder.Concat(new[] { this }).Where(bay =>
                {
                    var mp = Mouse.GetPosition(bay);
                    return bay != mvForm.DockBay &&
                        (mp.X >= 0 && mp.X < bay.RenderSize.Width && mp.Y >= 0 && mp.Y < bay.RenderSize.Height);
                }).FirstOrDefault();
            _dragingBay = mvForm.DockBay;
            _hoverBay = hoverBay;

            //Helperを表示する必要がある場合は表示とマウスが乗ってる座標下の
            //Paneも探す。無い場合は非表示にし、各一時保存用変数をクリアする
            if (hoverBay != null)
            {
                var mPos = Mouse.GetPosition(hoverBay);
                var childAtPoint = hoverBay.GetChildAtPoint(mPos);
                _dragEffect = DockingHelper.GetDragDropEffect(hoverBay, childAtPoint);
                _hoverPane = childAtPoint;
                DockingHelper.ActiveIndicator = _dragEffect;
            }
            else
            {
                DockingHelper.Visibility = System.Windows.Visibility.Hidden;
                _dragEffect = DragDropEffects.None;
                _hoverPane = null;
                DockingHelper.ActiveIndicator = _dragEffect;
            }
            OnFloatingWindowMoved(new FloatFormEventArgs((DockFloatingWindow)sender));
        }
        void wnd_EndWindowDrag(object sender, EventArgs e)
        {
            if (_dragingBay == null)
                return;

            var len = _dragingBay.Items.Count == 1 && ((DockPaneBase)_dragingBay.Items[0]).Items.Count == 0
                ? ((DockPaneBase)_dragingBay.Items[0]).Length : new DockLength();
            switch (_dragEffect)
            {
                case DragDropEffects.Top:
                    _hoverPane.AddPanesOf(_dragingBay, DockDirection.Top, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.Bottom:
                    _hoverPane.AddPanesOf(_dragingBay, DockDirection.Bottom, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.Left:
                    _hoverPane.AddPanesOf(_dragingBay, DockDirection.Left, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.Right:
                    _hoverPane.AddPanesOf(_dragingBay, DockDirection.Right, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.Fill:
                    break;
                case DragDropEffects.OuterTop:
                    _hoverBay.AddPanesOf(_dragingBay, DockDirection.Top, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.OuterBottom:
                    _hoverBay.AddPanesOf(_dragingBay, DockDirection.Bottom, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.OuterLeft:
                    _hoverBay.AddPanesOf(_dragingBay, DockDirection.Left, len);
                    Window.GetWindow(this).Activate();
                    break;
                case DragDropEffects.OuterRight:
                    _hoverBay.AddPanesOf(_dragingBay, DockDirection.Right, len);
                    Window.GetWindow(this).Activate();
                    break;
                default:
                    break;
            }

            DockingHelper.Visibility = System.Windows.Visibility.Hidden;
            _hoverPane = null;
            _hoverBay = null;
            _dragingBay = null;
            _dragEffect = DragDropEffects.None;

            OnFloatingWindowEndMove(new FloatFormEventArgs((DockFloatingWindow)sender));
        }