//ペインを閉じて結合する。outの引数は次にフォーカスを与えるべきペイン public SplitResult UnifyPane(IPane target, out IPane nextfocus) { nextfocus = null; //失敗時にはクリアできるように Debug.Assert(_rootList != null); DivisionNode node = _rootList.FirstNode.FindNode(target); bool unifying_root = node.ParentList == _rootList && _rootList.NodeCount == 2; //結合の結果RootListが入れ替わる予定のとき Control parent = _rootList.HostingControl.Parent; if (unifying_root && _rootList.FirstNode.IsLast) { return(SplitResult.F_UnifySingle); } DivisionList list = node.ParentList; DivisionNode active = list.Remove(node); if (list.NodeCount == 1) //こうなったときに面倒が発生 { if (active.IsLeaf) // (1) ペインであるとき { IPane newpane = active.Pane; Debug.Assert(newpane != null); if (list.ParentNode == null) //1-1 { UIUtil.ReplaceControl(parent, list.HostingControl, newpane.AsDotNet()); _rootList = null; } else //1-2 { list.ParentNode.ReplaceChildListByPane(newpane); } } else // (2) ノードであるとき { DivisionList newlist = active.ChildList; if (list.ParentNode == null) //2-1 { _rootList = newlist; newlist.ClearParentNode(); UIUtil.ReplaceControl(parent, list.HostingControl, newlist.HostingControl); } else //2-2 { DivisionList pp = list.ParentNode.ParentList; //長くなる方のリスト Debug.Assert(pp.Direction == newlist.Direction); pp.ReplaceNodeByList(list.ParentNode, newlist); } } } if (_rootList != null) { Rebuild(); DoLayout(); FindForm().MinimumSize = _rootList.FirstNode.RequiredMinimumSize; //!!TODO Splitterだけで構成されていないフォームでアウト } _count--; nextfocus = active.IsLeaf ? active.Pane : active.ChildList.FirstPane; return(SplitResult.Success); }