ComponentFactory.Krypton.Ribbon.ViewDrawRibbonGroupRichTextBox.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 richtextbox or a change in
            // the parent control that is hosting the control...
            if ((parentControl != LastParentControl) ||
                (LastRichTextBox != _ribbonRichTextBox.RichTextBox))
            {
                // We only modify the parent and visible state if processing for correct container
                if ((_ribbonRichTextBox.RibbonContainer.RibbonGroup.ShowingAsPopup && (parentControl is VisualPopupGroup)) ||
                    (!_ribbonRichTextBox.RibbonContainer.RibbonGroup.ShowingAsPopup && !(parentControl is VisualPopupGroup)))
                {
                    // If we have added the custrom control to a parent before
                    if ((LastRichTextBox != null) && (LastParentControl != null))
                    {
                        // If that control is still a child of the old parent
                        if (LastParentControl.Controls.Contains(LastRichTextBox))
                        {
                            // Check for a collection that is based on the read only class
                            LastParentControl.Controls.Remove(LastRichTextBox);
                        }
                    }

                    // Remember the current control and new parent
                    LastRichTextBox = _ribbonRichTextBox.RichTextBox;
                    LastParentControl = parentControl;

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

                        // Check for the correct visible state of the richtextbox
                        UpdateVisible(LastRichTextBox);
                        UpdateEnabled(LastRichTextBox);

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