public virtual void Remove(DockPaneLayoutEngine pane)
        {
            if (pane.Children.Count > 0)
            {
                var newParent = pane.Children.Last();
                pane._children.Remove(newParent);
                ChildReplace(pane, newParent);
                newParent._children.InsertRange(0, pane.Children);
                newParent.Initialize(this, pane.Owner, pane.Align);
            }
            else
                _children.Remove(pane);

            RemoveEngine(pane);
            pane._ownNodes.Clear();
            pane._ownNodes.Add(pane);
            pane.Top = null;
            pane.Bottom = null;
            pane.Left = null;
            pane.Right = null;
            pane._children.Clear();
            //Initializeは実行前にChildrenをClearしないと子要素が巻き添え食らう
            pane.Initialize(null, null, DockDirection.None);
            pane.OnRemoved(new EventArgs());
            OnPaneRemoved(new LayoutEngineEventArgs(pane));
        }
        /// <summary>子ノード郡の間に新しいPaneを挿入します</summary>
        /// <param name="idx">後輩ノードになるPaneのインデックス</param>
        public override void Add(DockPaneLayoutEngine pane, DockDirection align, int idx)
        {
            if (pane == null)
                throw new ArgumentNullException("第1引数のneighをnullにする事はできません。");
            if (pane.Owner != null)
                throw new ArgumentException("第1引数のneighは使用中です。");
            if (align == DockDirection.None)
                throw new ArgumentException("第2引数のalignをDockDirection.Noneにすることはできません。");
            if (idx < 0 || idx > Children.Count)
                throw new ArgumentOutOfRangeException("第3引数のinsertIndexが有効範囲外です。");

            if (align != DockDirection.Top)
            {
                var btm = GetChildrenOf(DockDirection.Bottom, idx).FirstOrDefault();
                if (btm != null)
                    foreach (var e in pane.GetChildrenOf(DockDirection.Bottom))
                        e.Bottom = btm.Bottom;
            }
            if (align != DockDirection.Bottom)
            {
                var top = GetChildrenOf(DockDirection.Top, idx).FirstOrDefault();
                if (top != null)
                    foreach (var e in pane.GetChildrenOf(DockDirection.Top))
                        e.Top = top.Top;
            }
            if (align != DockDirection.Left)
            {
                var rgh = GetChildrenOf(DockDirection.Right, idx).FirstOrDefault();
                if (rgh != null)
                    foreach (var e in pane.GetChildrenOf(DockDirection.Right))
                        e.Right = rgh.Right;
            }
            if (align != DockDirection.Right)
            {
                var lft = GetChildrenOf(DockDirection.Left, idx).FirstOrDefault();
                if (lft != null)
                    foreach (var e in pane.GetChildrenOf(DockDirection.Left))
                        e.Left = lft.Left;
            }
            switch (align)
            {
                case DockDirection.Top:
                    foreach (var paneInner in pane.GetChildrenOf(~align))
                        paneInner.Bottom = pane;
                    foreach (var thisInner in GetChildrenOf(align, idx))
                        thisInner.Top = pane;
                    break;
                case DockDirection.Bottom:
                    foreach (var paneInner in pane.GetChildrenOf(~align))
                        paneInner.Top = pane;
                    foreach (var thisInner in GetChildrenOf(align, idx))
                        thisInner.Bottom = pane;
                    break;
                case DockDirection.Left:
                    foreach (var paneInner in pane.GetChildrenOf(~align))
                        paneInner.Right = pane;
                    foreach (var thisInner in GetChildrenOf(align, idx))
                        thisInner.Left = pane;
                    break;
                case DockDirection.Right:
                    foreach (var paneInner in pane.GetChildrenOf(~align))
                        paneInner.Left = pane;
                    foreach (var thisInner in GetChildrenOf(align, idx))
                        thisInner.Right = pane;
                    break;
            }
            pane.Initialize(this, Owner, align);

            //base.Addを初めに呼びだしてしまうと、Childrenが更新されるために
            //GetChildrenOfの挙動に以上が生じる。そのため、base.Addは最後に呼ぶ
            base.Add(pane, align, idx);
        }
        public void InitializeTest()
        {
            var target = new DockPaneLayoutEngine(new DockPaneBase());
            var parent = new DockPaneLayoutEngine(new DockPaneBase());
            var owner = new DockBayLayoutEngine(new DockBayBase());
            var align = DockDirection.Top;

            target.Initialize(parent, owner, align);
            Assert.AreEqual(target.Parent, parent);
            Assert.AreEqual(target.Owner, owner);
        }