ComponentFactory.Krypton.Ribbon.ViewDrawRibbonGroupDomainUpDown.UpdateParent C# (CSharp) Method

UpdateParent() private method

private UpdateParent ( Control parentControl ) : void
parentControl System.Windows.Forms.Control
return void
        private void UpdateParent(Control parentControl)
        {
            // Is there a change in the domain up-down or a change in
            // the parent control that is hosting the control...
            if ((parentControl != LastParentControl) ||
                (LastDomainUpDown != _ribbonDomainUpDown.DomainUpDown))
            {
                // We only modify the parent and visible state if processing for correct container
                if ((_ribbonDomainUpDown.RibbonContainer.RibbonGroup.ShowingAsPopup && (parentControl is VisualPopupGroup)) ||
                    (!_ribbonDomainUpDown.RibbonContainer.RibbonGroup.ShowingAsPopup && !(parentControl is VisualPopupGroup)))
                {
                    // If we have added the custrom control to a parent before
                    if ((LastDomainUpDown != null) && (LastParentControl != null))
                    {
                        // If that control is still a child of the old parent
                        if (LastParentControl.Controls.Contains(LastDomainUpDown))
                        {
                            // Check for a collection that is based on the read only class
                            LastParentControl.Controls.Remove(LastDomainUpDown);
                        }
                    }

                    // Remember the current control and new parent
                    LastDomainUpDown = _ribbonDomainUpDown.DomainUpDown;
                    LastParentControl = parentControl;

                    // If we have a new domain up-down and parent
                    if ((LastDomainUpDown != null) && (LastParentControl != null))
                    {
                        // Ensure the control is not in the display area when first added
                        LastDomainUpDown.Location = new Point(-LastDomainUpDown.Width, -LastDomainUpDown.Height);

                        // Check for the correct visible state of the domain up-down
                        UpdateVisible(LastDomainUpDown);

                        // Check for a collection that is based on the read only class
                        LastParentControl.Controls.Add(LastDomainUpDown);
                    }
                }
            }
        }