private Control FindNearestLeftControl(
                List <Control> row,
                Control.ControlCollection controls)
            {
                int     num1     = 10000000;
                Control control1 = (Control)null;

                foreach (object obj in row)
                {
                    RadThemeComponentBase.ThemeContext.ControlInfo info1 = this.GetInfo(obj.GetHashCode());
                    if (info1 != null)
                    {
                        foreach (Control control2 in (ArrangedElementCollection)controls)
                        {
                            if (!row.Contains(control2))
                            {
                                RadThemeComponentBase.ThemeContext.ControlInfo info2 = this.GetInfo(control2.GetHashCode());
                                if (info2 != null && info2.Bounds.Right < info1.Bounds.Left)
                                {
                                    int num2 = info1.Bounds.Left - info2.Bounds.Right;
                                    if (num2 < num1 || info1.Bounds.Top > info2.Bounds.Bottom && info2.Bounds.Bottom > control1.Bounds.Bottom)
                                    {
                                        num1     = num2;
                                        control1 = control2;
                                    }
                                }
                            }
                        }
                    }
                }
                return(control1);
            }
 private void CorrectOwnerWidth(Control.ControlCollection controls, AnchorStyles[] styles)
 {
     RadThemeComponentBase.ThemeContext.ControlInfo controlInfo = (RadThemeComponentBase.ThemeContext.ControlInfo)null;
     foreach (Control control in (ArrangedElementCollection)controls)
     {
         if (controlInfo == null || controlInfo.Control.Bounds.Right < control.Bounds.Right)
         {
             controlInfo = this.GetInfo(control.GetHashCode());
         }
     }
     if (controlInfo == null || controlInfo.ParentSpaceAfter.X == controls.Owner.ClientSize.Width - controlInfo.Control.Right)
     {
         return;
     }
     controls.Owner.ClientSize = new Size(controlInfo.Control.Right + controlInfo.ParentSpaceAfter.X, controls.Owner.ClientSize.Height);
     for (int index = 0; index < controls.Count; ++index)
     {
         if ((styles[index] & AnchorStyles.Right) != AnchorStyles.None)
         {
             Control control1 = controls[index];
             Control control2 = (Control)null;
             int     num1     = 10000000;
             foreach (Control control3 in (ArrangedElementCollection)controls)
             {
                 if (control3.Left > control1.Right)
                 {
                     int num2 = control3.Left - control1.Right;
                     if (num2 < num1)
                     {
                         num1     = num2;
                         control2 = control3;
                     }
                 }
             }
             if (control2 == null)
             {
                 int x    = this.infos[control1.GetHashCode()].ParentSpaceAfter.X;
                 int num2 = controls.Owner.ClientRectangle.Width - control1.Bounds.Right;
                 if (num2 != x)
                 {
                     control1.Width += num2 - x;
                 }
             }
         }
     }
 }
            private void CorrectOwnerWidthRTL(Control.ControlCollection controls, AnchorStyles[] styles)
            {
                RadThemeComponentBase.ThemeContext.ControlInfo controlInfo = (RadThemeComponentBase.ThemeContext.ControlInfo)null;
                foreach (Control control in (ArrangedElementCollection)controls)
                {
                    if (controlInfo == null || control.Bounds.Left < controlInfo.Control.Bounds.Left)
                    {
                        controlInfo = this.GetInfo(control.GetHashCode());
                    }
                }
                if (controlInfo == null || controlInfo.ParentSpaceAfter.X == controlInfo.Control.Left)
                {
                    return;
                }
                int num = controlInfo.ParentSpaceAfter.X - controlInfo.Control.Left;

                controls.Owner.ClientSize = new Size(controls.Owner.ClientSize.Width + num, controls.Owner.ClientSize.Height);
                foreach (Control control in (ArrangedElementCollection)controls)
                {
                    control.Left += num;
                }
            }
            private void CorrectPositionsByY(Control.ControlCollection controls)
            {
                List <List <Control> > controlListList = this.OrderInRows(controls);

                AnchorStyles[] styles = this.PersistAnchorStyles(controls);
                for (int index = 0; index < controlListList.Count; ++index)
                {
                    List <Control> row = controlListList[index];
                    foreach (Control control in row)
                    {
                        this.CorrectPositionsByY(control.Controls);
                    }
                    if (index != 0)
                    {
                        Control nearestTopControl = this.FindNearestTopControl(row, controls);
                        if (nearestTopControl != null)
                        {
                            int num1 = this.infos[row[0].GetHashCode()].Bounds.Top - this.infos[nearestTopControl.GetHashCode()].Bounds.Bottom;
                            int num2 = nearestTopControl.Bounds.Bottom + num1;
                            foreach (Control control in row)
                            {
                                if (control.Dock == DockStyle.None)
                                {
                                    control.Top = num2;
                                }
                            }
                        }
                    }
                }
                if (controls.Count == 1 && controls[0].GetType().Name == "HostedTextBoxBase")
                {
                    return;
                }
                RadThemeComponentBase.ThemeContext.ControlInfo controlInfo = (RadThemeComponentBase.ThemeContext.ControlInfo)null;
                foreach (Control control in (ArrangedElementCollection)controls)
                {
                    if (controlInfo == null || controlInfo.Control.Bounds.Bottom < control.Bounds.Bottom)
                    {
                        controlInfo = this.GetInfo(control.GetHashCode());
                    }
                }
                if (controlInfo != null && controlInfo.ParentSpaceAfter.Y != controls.Owner.ClientSize.Height - controlInfo.Control.Bottom)
                {
                    controls.Owner.ClientSize = new Size(controls.Owner.ClientSize.Width, controlInfo.Control.Bottom + controlInfo.ParentSpaceAfter.Y);
                    for (int index = 0; index < controls.Count; ++index)
                    {
                        if ((styles[index] & AnchorStyles.Bottom) != AnchorStyles.None)
                        {
                            Control control1 = controls[index];
                            Control control2 = (Control)null;
                            int     num1     = 10000000;
                            foreach (Control control3 in (ArrangedElementCollection)controls)
                            {
                                if (control3.Top > control1.Bottom)
                                {
                                    int num2 = control3.Top - control1.Bottom;
                                    if (num2 < num1)
                                    {
                                        num1     = num2;
                                        control2 = control3;
                                    }
                                }
                            }
                            if (control2 == null)
                            {
                                int y    = this.infos[control1.GetHashCode()].ParentSpaceAfter.Y;
                                int num2 = controls.Owner.ClientRectangle.Height - control1.Bounds.Bottom;
                                if (num2 != y)
                                {
                                    control1.Height += num2 - y;
                                }
                            }
                        }
                    }
                }
                this.RestoreAnchorStyles(controls, styles);
            }