internal _Float(AuDockPanel manager, _ContentNode gc) { _manager = manager; _gc = gc; var gp = _gc as _Panel; //we'll use this to prevent window activation on click, for toolbar and menubar classes that support it _hasToolbar = (gp != null && gp.HasToolbar && (gp.Content is Util.AToolStrip || gp.Content is Util.AMenuStrip)); this.SuspendLayout(); this.Font = _manager.Font; this.AutoScaleMode = AutoScaleMode.None; this.StartPosition = FormStartPosition.Manual; this.FormBorderStyle = FormBorderStyle.SizableToolWindow; this.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true); this.MinimumSize = new Size(34, 30); this.Text = gc.ToString(); this.ResumeLayout(); var f = _manager.TopLevelControl; f.VisibleChanged += ManagerForm_VisibleChanged; //f.EnabledChanged += ManagerForm_EnabledChanged; //in most cases does not work. Instead the main form on WM_ENABLE calls EnableDisableAllFloatingWindows. }
/// <summary> /// Docks this _Panel or _Tab in an existing or new _Tab or _Split. /// If need, creates new _Tab or _Split in gcTarget place and adds gcTarget and this to it. Else reorders if need. /// This can be a new _Panel, with null ParentSplit and ParentTab, dock state not Docked. /// </summary> /// <param name="gcTarget">New sibling _Panel (side can be any) or sibling _Tab (when side is SplitX) or parent _Tab (when side is TabX).</param> /// <param name="side">Specifies whether to add on a _Tab or _Split, and at which side of gcTarget.</param> internal void DockBy(_ContentNode gcTarget, _DockHow side) { var gpThis = this as _Panel; var gtThisParent = gpThis?.ParentTab; var gsThisParent = this.ParentSplit; var gsTargetParent = gcTarget.ParentSplit; if (side == _DockHow.TabBefore || side == _DockHow.TabAfter) { var gpTarget = gcTarget as _Panel; _Tab gtTargetParent = (gpTarget != null) ? gpTarget.ParentTab : gcTarget as _Tab; bool after = side == _DockHow.TabAfter; bool sameTargetTab = false; if (gtTargetParent != null) { gtTargetParent.AddOrReorderItem(gpThis, gpTarget, after); if (gtThisParent == gtTargetParent) { sameTargetTab = true; } } else { var gtNew = new _Tab(_manager, gsTargetParent, after ? gpTarget : gpThis, after ? gpThis : gpTarget); gsTargetParent.ReplaceChild(gpTarget, gtNew); gtNew.Bounds = gpTarget.Bounds; gtNew.CaptionAt = gpTarget.CaptionAt; } if (!sameTargetTab) { this.ParentSplit = gsTargetParent; if (gtThisParent != null) { gtThisParent.OnItemRemoved(gpThis); } else { gsThisParent?.OnChildRemoved(this); } } } else { if (gcTarget.IsTabbedPanel) { gcTarget = (gcTarget as _Panel).ParentTab; } bool after = side == _DockHow.SplitRight || side == _DockHow.SplitBelow; bool verticalSplit = side == _DockHow.SplitLeft || side == _DockHow.SplitRight; if (gsTargetParent == gsThisParent && gtThisParent == null) { //just change vertical/horizontal or/and swap with sibling gsThisParent.RepositionChild(this, verticalSplit, after); } else { var gsNew = new _Split(_manager, gsTargetParent, after ? gcTarget : this, after ? this : gcTarget, verticalSplit); gsTargetParent.ReplaceChild(gcTarget, gsNew); gsNew.Bounds = gcTarget.Bounds; if (gtThisParent != null) { gpThis.ParentTab = null; gtThisParent.OnItemRemoved(gpThis); } else { gsThisParent?.OnChildRemoved(this); } } } SetDockState(_DockState.Docked, false); }
internal void OnReplacedChild(_ContentNode newChild) { _gc = newChild; }