/// <summary> /// Puts gn sibling in parent split of this, in place of this. /// Makes this invalid and removes from _aSplit. /// Does not update layout. /// </summary> /// <param name="gn">One of children. The caller is removing it from this.</param> internal void OnChildRemoved(_Node gn) { _AssertIsChild(gn); Debug.Assert(!gn.IsDocked); var gnOther = gn == Child1 ? Child2 : Child1; if (this == _manager._firstSplit) { var gs = gnOther as _Split; if (gs == null) { //gnOther is _Tab, because the user moved all panels to a single _Tab. We cannot delete this (root) _Split. var gd = new _DummyNode(_manager, this); if (gn == Child1) { Child1 = gd; } else { Child2 = gd; } //never mind: when saving layout to XML, should remove this dummy node if can. Not necessary, because impossible to create multiple dummy nodes. return; } gs.ParentSplit = null; _manager._firstSplit = gs; } else { this.ParentSplit.ReplaceChild(this, gnOther); } #if DEBUG this.Child1 = this.Child2 = null; //to catch invalid usage of this after calling this function #endif _manager._aSplit.Remove(this); }
int _width; //used if !_isFraction; if _isWidth1, it is Child1 width, else Child2 with /// <summary> /// This ctor is used at startup, when adding from XML. /// </summary> internal _Split(AuDockPanel manager, _Split parentSplit, XElement x) : base(manager, parentSplit) { manager._aSplit.Add(this); if (!x.HasAttr("hor")) { IsVerticalSplit = true; } int k = x.Attr("splitter", -1); if (k < 0 || k > 20) { k = _splitterWidth; } this.SplitterWidth = k; //SHOULDDO: use DPI-dependent units, not pixels. Especially if form size depends on DPI. if (!(_isFraction = x.Attr(out _fraction, "f")) && !(_isWidth1 = x.Attr(out _width, "w1"))) { _width = x.Attr("w2", 1); } foreach (var xe in x.Elements()) { _Node gn = null; switch (xe.Name.LocalName) { case "panel": gn = new _Panel(manager, this, xe); break; case "split": gn = new _Split(manager, this, xe); break; case "tab": gn = new _Tab(manager, this, xe); break; case "dummy": gn = new _DummyNode(_manager, this); break; default: continue; } if (gn.IsDocked) { _dockedChildCount++; } if (Child1 == null) { Child1 = gn; } else { Child2 = gn; break; } } if (Child2 == null) { throw new Exception(); } if (_dockedChildCount == 0) { this.DockState = _DockState.Hidden; } }