Exemplo n.º 1
0
        /// <include file='doc\ToolStripControlHost.uex' path='docs/doc[@for="ToolStripControlHost.OnBoundsChanged"]/*' />
        /// <devdoc>
        /// Called when the items bounds are changed.  Here, we update the Control's bounds.
        /// </devdoc>
        protected override void OnBoundsChanged()
        {
            if (control != null)
            {
                SuspendSizeSync();
                IArrangedElement element = control as IArrangedElement;
                if (element == null)
                {
                    Debug.Fail("why are we here? control should not be null");
                    return;
                }

                Size      size   = LayoutUtils.DeflateRect(this.Bounds, this.Padding).Size;
                Rectangle bounds = LayoutUtils.Align(size, this.Bounds, ControlAlign);

                // use BoundsSpecified.None so we dont deal w/specified bounds - this way we can tell what someone has set the size to.
                element.SetBounds(bounds, BoundsSpecified.None);

                // sometimes a control can ignore the size passed in, use the adjustment
                // to re-align.
                if (bounds != control.Bounds)
                {
                    bounds = LayoutUtils.Align(control.Size, this.Bounds, ControlAlign);
                    element.SetBounds(bounds, BoundsSpecified.None);
                }
                ResumeSizeSync();
            }
        }
Exemplo n.º 2
0
        private Rectangle GetTextRectangle(Size szText)
        {
            Size      sz  = new Size(szText.Width + _TextPadding * 2, szText.Height + _TextPadding * 2);
            Rectangle ret = LayoutUtils.Align(sz, GetTextContainerRectangle(), _TextAlign);

            ret.X += _TextPadding;
            ret.Y += _TextPadding;
            return(ret);
        }
Exemplo n.º 3
0
        private void DrawTextNormal(Size szText, Rectangle rect, PaintEventArgs e)
        {
            Rectangle rectText = LayoutUtils.Align(szText + new Size(_TextPadding * 2, _TextPadding * 2), rect, _TextAlign);

            rectText.X += _TextPadding;
            rectText.Y += _TextPadding;
            using (SolidBrush brush = new SolidBrush(this.ForeColor)) {
                e.Graphics.DrawString(_Text, this.Font, brush, rectText.Location);
            }
        }
Exemplo n.º 4
0
        protected virtual void PaintImage(Graphics g, RectangleF rect)
        {
            if (this.image == null || rect.Size == (SizeF)Size.Empty)
            {
                return;
            }
            ContentAlignment imageAlignment = this.ImageAlignment;

            switch (this.ImageLayout)
            {
            case ImageLayout.None:
                Graphics   graphics   = g;
                RectangleF rectangleF = LayoutUtils.Align(new SizeF(Math.Min(rect.Width, (float)this.image.Size.Width), Math.Min(rect.Height, (float)this.image.Size.Height)), rect, imageAlignment);
                graphics.DrawImageUnscaledAndClipped(this.image, new Rectangle(new Point((int)rectangleF.Location.X, (int)rectangleF.Location.Y), rectangleF.Size.ToSize()));
                break;

            case ImageLayout.Tile:
                for (float x = rect.X; (double)x <= (double)rect.Height - (double)this.image.Height; x += (float)this.image.Height)
                {
                    for (float y = rect.Y; (double)y < (double)rect.Width - (double)this.image.Width; y += (float)this.image.Width)
                    {
                        g.DrawImage(this.image, (int)y, (int)x);
                    }
                }
                break;

            case ImageLayout.Center:
                PointF pointF = new PointF(Math.Max(0.0f, rect.X + Math.Max(0.0f, (float)(((double)rect.Width - (double)this.image.Width) / 2.0))), Math.Max(0.0f, rect.Y + Math.Max(0.0f, (float)(((double)rect.Height - (double)this.image.Height) / 2.0))));
                SizeF  sizeF  = new SizeF(Math.Min(rect.Width, (float)this.image.Size.Width), Math.Min(rect.Height, (float)this.image.Size.Height));
                g.DrawImageUnscaledAndClipped(this.image, new Rectangle(new Point((int)pointF.X, (int)pointF.Y), sizeF.ToSize()));
                break;

            case ImageLayout.Stretch:
                g.DrawImage(this.image, rect.X, rect.Y, rect.Width, rect.Height);
                break;

            case ImageLayout.Zoom:
                if (this.image.Width == 0 || this.image.Height == 0)
                {
                    break;
                }
                float num = Math.Min(rect.Width / (float)this.image.Width, rect.Height / (float)this.image.Height);
                if ((double)num <= 0.0)
                {
                    break;
                }
                int width  = (int)Math.Round((double)this.image.Width * (double)num);
                int height = (int)Math.Round((double)this.image.Height * (double)num);
                int x1     = (int)rect.X + ((int)rect.Width - width) / 2;
                int y1     = (int)rect.Y + ((int)rect.Height - height) / 2;
                g.DrawImage(this.image, x1, y1, width, height);
                break;
            }
        }
Exemplo n.º 5
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            RectangleF            clientRect = GetClientRectangle(finalSize);
            RadDropDownMenuLayout menuLayout = this.Parent as RadDropDownMenuLayout;
            float leftColumn  = 0;
            float rightColumn = 0;

            if (menuLayout != null)
            {
                leftColumn  = menuLayout.LeftColumnMaxPadding + menuLayout.LeftColumnWidth;
                rightColumn = menuLayout.LeftColumnMaxPadding + menuLayout.RightColumnWidth;
            }

            foreach (RadElement element in this.Children)
            {
                if (element == this.imagePrimitive)
                {
                    float      leftColumnWidth = menuLayout != null ? menuLayout.LeftColumnWidth : 0;
                    RectangleF finalRect       = new RectangleF(clientRect.Left, clientRect.Top, leftColumnWidth, clientRect.Height);
                    if (this.RightToLeft)
                    {
                        finalRect = LayoutUtils.RTLTranslateNonRelative(finalRect, clientRect);
                    }

                    element.Arrange(finalRect);
                }
                else if (element == this.textPrimitive)
                {
                    RectangleF cr = new RectangleF(clientRect.Left + leftColumn, clientRect.Top, clientRect.Width - rightColumn, clientRect.Height);
                    RectangleF r  = LayoutUtils.Align(this.textPrimitive.DesiredSize, cr, this.textPrimitive.Alignment);
                    if (this.RightToLeft)
                    {
                        r = LayoutUtils.RTLTranslateNonRelative(r, clientRect);
                    }

                    element.Arrange(r);
                }
                else if (element.FitToSizeMode == RadFitToSizeMode.FitToParentBounds)
                {
                    element.Arrange(new RectangleF(Point.Empty, finalSize));
                }
                else if (element.FitToSizeMode == RadFitToSizeMode.FitToParentPadding)
                {
                    element.Arrange(new RectangleF(this.BorderThickness.Left, this.BorderThickness.Top, finalSize.Width - this.BorderThickness.Horizontal, finalSize.Height - this.BorderThickness.Vertical));
                }
                else
                {
                    element.Arrange(clientRect);
                }
            }

            return(finalSize);
        }
Exemplo n.º 6
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            RectangleF            clientRectangle = this.GetClientRectangle(finalSize);
            RadDropDownMenuLayout parent          = this.Parent as RadDropDownMenuLayout;
            float num1 = 0.0f;
            float num2 = 0.0f;

            if (parent != null)
            {
                num1 = parent.LeftColumnMaxPadding + parent.LeftColumnWidth;
                num2 = parent.LeftColumnMaxPadding + parent.RightColumnWidth;
            }
            foreach (RadElement child in this.Children)
            {
                if (child == this.imagePrimitive)
                {
                    float      width      = parent != null ? parent.LeftColumnWidth : 0.0f;
                    RectangleF rectangleF = new RectangleF(clientRectangle.Left, clientRectangle.Top, width, clientRectangle.Height);
                    if (this.RightToLeft)
                    {
                        rectangleF = LayoutUtils.RTLTranslateNonRelative(rectangleF, clientRectangle);
                    }
                    child.Arrange(rectangleF);
                }
                else if (child == this.textPrimitive)
                {
                    RectangleF rectangleF = LayoutUtils.Align(this.textPrimitive.DesiredSize, new RectangleF(clientRectangle.Left + num1, clientRectangle.Top, clientRectangle.Width - num2, clientRectangle.Height), this.textPrimitive.Alignment);
                    if (this.RightToLeft)
                    {
                        rectangleF = LayoutUtils.RTLTranslateNonRelative(rectangleF, clientRectangle);
                    }
                    child.Arrange(rectangleF);
                }
                else if (child.FitToSizeMode == RadFitToSizeMode.FitToParentBounds)
                {
                    child.Arrange(new RectangleF((PointF)Point.Empty, finalSize));
                }
                else if (child.FitToSizeMode == RadFitToSizeMode.FitToParentPadding)
                {
                    child.Arrange(new RectangleF((float)this.BorderThickness.Left, (float)this.BorderThickness.Top, finalSize.Width - (float)this.BorderThickness.Horizontal, finalSize.Height - (float)this.BorderThickness.Vertical));
                }
                else
                {
                    child.Arrange(clientRectangle);
                }
            }
            return(finalSize);
        }
 protected override void OnBoundsChanged()
 {
     if (this.control != null)
     {
         this.SuspendSizeSync();
         IArrangedElement control = this.control;
         if (control != null)
         {
             Rectangle bounds = LayoutUtils.Align(LayoutUtils.DeflateRect(this.Bounds, this.Padding).Size, this.Bounds, this.ControlAlign);
             control.SetBounds(bounds, BoundsSpecified.None);
             if (bounds != this.control.Bounds)
             {
                 bounds = LayoutUtils.Align(this.control.Size, this.Bounds, this.ControlAlign);
                 control.SetBounds(bounds, BoundsSpecified.None);
             }
             this.ResumeSizeSync();
         }
     }
 }
Exemplo n.º 8
0
        [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")]     // using "\t" to figure out the width of tab
        private void  CalculateInternalLayoutMetrics()
        {
            Size maxTextSize        = Size.Empty;
            Size maxImageSize       = Size.Empty;
            Size maxCheckSize       = scaledDefaultImageSize;
            Size maxArrowSize       = Size.Empty;
            Size maxNonMenuItemSize = Size.Empty;

            // determine Text Metrics
            for (int i = 0; i < Items.Count; i++)
            {
                ToolStripItem     item     = Items[i];
                ToolStripMenuItem menuItem = item as ToolStripMenuItem;

                if (menuItem != null)
                {
                    Size menuItemTextSize = menuItem.GetTextSize();

                    if (menuItem.ShowShortcutKeys)
                    {
                        Size shortcutTextSize = menuItem.GetShortcutTextSize();
                        if (tabWidth == -1)
                        {
                            tabWidth = TextRenderer.MeasureText("\t", this.Font).Width;
                        }
                        menuItemTextSize.Width += tabWidth + shortcutTextSize.Width;
                        menuItemTextSize.Height = Math.Max(menuItemTextSize.Height, shortcutTextSize.Height);
                    }

                    // we truly only care about the maximum size we find.
                    maxTextSize.Width  = Math.Max(maxTextSize.Width, menuItemTextSize.Width);
                    maxTextSize.Height = Math.Max(maxTextSize.Height, menuItemTextSize.Height);

                    // determine Image Metrics
                    Size imageSize = Size.Empty;
                    if (menuItem.Image != null)
                    {
                        imageSize = (menuItem.ImageScaling == ToolStripItemImageScaling.SizeToFit) ? ImageScalingSize : menuItem.Image.Size;
                    }

                    maxImageSize.Width  = Math.Max(maxImageSize.Width, imageSize.Width);
                    maxImageSize.Height = Math.Max(maxImageSize.Height, imageSize.Height);

                    if (menuItem.CheckedImage != null)
                    {
                        Size checkedImageSize = menuItem.CheckedImage.Size;
                        maxCheckSize.Width  = Math.Max(checkedImageSize.Width, maxCheckSize.Width);
                        maxCheckSize.Height = Math.Max(checkedImageSize.Height, maxCheckSize.Height);
                    }
                }
                else if (!(item is ToolStripSeparator))
                {
                    maxNonMenuItemSize.Height = Math.Max(item.Bounds.Height, maxNonMenuItemSize.Height);
                    maxNonMenuItemSize.Width  = Math.Max(item.Bounds.Width, maxNonMenuItemSize.Width);
                }
            }

            this.maxItemSize.Height = Math.Max(maxTextSize.Height + scaledTextPadding.Vertical, Math.Max(maxCheckSize.Height + scaledCheckPadding.Vertical, maxArrowSize.Height + scaledArrowPadding.Vertical));

            if (ShowImageMargin)
            {
                // only add in the image into the calculation if we're going to render it.
                this.maxItemSize.Height = Math.Max(maxImageSize.Height + scaledImagePadding.Vertical, maxItemSize.Height);
            }

            bool useDefaultCheckMarginWidth = (ShowCheckMargin && (maxCheckSize.Width == 0));
            bool useDefaultImageMarginWidth = (ShowImageMargin && (maxImageSize.Width == 0));

            // Always save space for an arrow
            maxArrowSize = new Size(scaledArrowSize, maxItemSize.Height);

            maxTextSize.Height  = maxItemSize.Height - scaledTextPadding.Vertical;
            maxImageSize.Height = maxItemSize.Height - scaledImagePadding.Vertical;
            maxCheckSize.Height = maxItemSize.Height - scaledCheckPadding.Vertical;

            // fixup if there are non-menu items that are larger than our normal menu items
            maxTextSize.Width = Math.Max(maxTextSize.Width, maxNonMenuItemSize.Width);

            Point nextPoint = Point.Empty;
            int   checkAndImageMarginWidth = 0;

            int extraImageWidth = Math.Max(0, maxImageSize.Width - scaledDefaultImageSize.Width);

            if (ShowCheckMargin && ShowImageMargin)
            {
                // double column - check margin then image margin
                // default to 46px - grow if necessary.
                checkAndImageMarginWidth = scaledDefaultImageAndCheckMarginWidth;

                // add in the extra space for the image... since the check size is locked down to 16x16.
                checkAndImageMarginWidth += extraImageWidth;

                // align the checkmark
                nextPoint      = new Point(scaledCheckPadding.Left, scaledCheckPadding.Top);
                checkRectangle = LayoutUtils.Align(maxCheckSize, new Rectangle(nextPoint.X, nextPoint.Y, maxCheckSize.Width, maxItemSize.Height), ContentAlignment.MiddleCenter);

                // align the image rectangle
                nextPoint.X    = checkRectangle.Right + scaledCheckPadding.Right + scaledImagePadding.Left;
                nextPoint.Y    = scaledImagePadding.Top;
                imageRectangle = LayoutUtils.Align(maxImageSize, new Rectangle(nextPoint.X, nextPoint.Y, maxImageSize.Width, maxItemSize.Height), ContentAlignment.MiddleCenter);
            }
            else if (ShowCheckMargin)
            {
                // no images should be shown in a ShowCheckMargin only scenario.
                // default to 24px - grow if necessary.
                checkAndImageMarginWidth = scaledDefaultImageMarginWidth;

                // align the checkmark
                nextPoint = new Point(1, scaledCheckPadding.Top);
                //    nextPoint = new Point(scaledCheckPadding.Left, scaledCheckPadding.Top);
                checkRectangle = LayoutUtils.Align(maxCheckSize, new Rectangle(nextPoint.X, nextPoint.Y, checkAndImageMarginWidth, maxItemSize.Height), ContentAlignment.MiddleCenter);

                imageRectangle = Rectangle.Empty;
            }
            else if (ShowImageMargin)
            {
                // checks and images render in the same area.

                // default to 24px - grow if necessary.
                checkAndImageMarginWidth = scaledDefaultImageMarginWidth;

                // add in the extra space for the image... since the check size is locked down to 16x16.
                checkAndImageMarginWidth += extraImageWidth;

                // NOTE due to the Padding property, we're going to have to recalc the vertical alignment in ToolStripMenuItemInternalLayout.
                // Dont fuss here over the Y, X is what's critical.

                // check and image rect are the same - take the max of the image size and the check size and align
                nextPoint      = new Point(1, scaledCheckPadding.Top);
                checkRectangle = LayoutUtils.Align(LayoutUtils.UnionSizes(maxCheckSize, maxImageSize), new Rectangle(nextPoint.X, nextPoint.Y, checkAndImageMarginWidth - 1, maxItemSize.Height), ContentAlignment.MiddleCenter);

                // align the image
                imageRectangle = checkRectangle;
            }
            else
            {
                checkAndImageMarginWidth = 0;
            }
            nextPoint.X = checkAndImageMarginWidth + 1;


            // calculate space for image
            // if we didnt have a check - make sure to ignore check padding

            // consider: should we constrain to a reasonable width?
            //imageMarginBounds = new Rectangle(0, 0, Math.Max(imageMarginWidth,DefaultImageMarginWidth), this.Height);
            imageMarginBounds = new Rectangle(0, 0, checkAndImageMarginWidth, this.Height);

            // calculate space for shortcut and text
            nextPoint.X   = imageMarginBounds.Right + scaledTextPadding.Left;
            nextPoint.Y   = scaledTextPadding.Top;
            textRectangle = new Rectangle(nextPoint, maxTextSize);

            // calculate space for arrow
            nextPoint.X    = textRectangle.Right + scaledTextPadding.Right + scaledArrowPadding.Left;
            nextPoint.Y    = scaledArrowPadding.Top;
            arrowRectangle = new Rectangle(nextPoint, maxArrowSize);

            // calculate space required for all of these pieces
            this.maxItemSize.Width = (arrowRectangle.Right + scaledArrowPadding.Right) - imageMarginBounds.Left;

            this.Padding = DefaultPadding;
            int trimPadding = imageMarginBounds.Width;

            if (RightToLeft == RightToLeft.Yes)
            {
                // reverse the rectangle alignment in RightToLeft.Yes
                trimPadding += scaledTextPadding.Right;
                int width = maxItemSize.Width;
                checkRectangle.X    = width - checkRectangle.Right;
                imageRectangle.X    = width - imageRectangle.Right;
                textRectangle.X     = width - textRectangle.Right;
                arrowRectangle.X    = width - arrowRectangle.Right;
                imageMarginBounds.X = width - imageMarginBounds.Right;
            }
            else
            {
                trimPadding += scaledTextPadding.Left;
            }



            // We need to make sure that the text really appears vertically centered - this can be a problem in
            // systems which force the text rectangle to be odd.

            // force this to be an even height.
            this.maxItemSize.Height += this.maxItemSize.Height % 2;

            textRectangle.Y  = LayoutUtils.VAlign(textRectangle.Size, new Rectangle(Point.Empty, maxItemSize), ContentAlignment.MiddleCenter).Y;
            textRectangle.Y += (textRectangle.Height % 2);    // if the height is odd, push down by one px
            state[stateMaxItemSizeValid] = true;
            this.PaddingToTrim           = trimPadding;
        }
Exemplo n.º 9
0
        public virtual void PaintImage(
            IGraphics graphics,
            Image image,
            RectangleF rect,
            ImageLayout imageLayout,
            ContentAlignment imageAlignment,
            float opacity,
            bool rtl)
        {
            SizeF size = rect.Size;

            if (image == null || size == SizeF.Empty)
            {
                return;
            }
            if (rtl)
            {
                imageAlignment = TelerikAlignHelper.RtlTranslateContent(imageAlignment);
            }
            switch (imageLayout)
            {
            case ImageLayout.None:
                RectangleF rectangleF = LayoutUtils.Align(new SizeF(Math.Min(rect.Width, (float)image.Size.Width), Math.Min(rect.Height, (float)image.Size.Height)), rect, imageAlignment);
                ((Graphics)graphics.UnderlayGraphics).DrawImageUnscaledAndClipped(image, new Rectangle(new Point((int)rectangleF.Location.X, (int)rectangleF.Location.Y), rectangleF.Size.ToSize()));
                break;

            case ImageLayout.Tile:
                float num1 = rect.Y - (float)image.Height;
                do
                {
                    num1 += (float)image.Height;
                    float num2 = rect.X - (float)image.Width;
                    do
                    {
                        num2 += (float)image.Width;
                        if ((double)opacity == 1.0)
                        {
                            graphics.DrawBitmap(image, (int)num2, (int)num1);
                        }
                        else
                        {
                            graphics.DrawBitmap(image, (int)num2, (int)num1, (double)opacity);
                        }
                    }while ((double)num2 < (double)rect.X + (double)rect.Width - (double)image.Width);
                }while ((double)num1 <= (double)rect.Y + (double)rect.Height - (double)image.Height);
                break;

            case ImageLayout.Center:
                PointF pointF = new PointF(Math.Max(0.0f, rect.X + Math.Max(0.0f, (float)(((double)size.Width - (double)image.Width) / 2.0))), Math.Max(0.0f, rect.Y + Math.Max(0.0f, (float)(((double)size.Height - (double)image.Height) / 2.0))));
                pointF.X = Math.Min(pointF.X, rect.Right);
                pointF.Y = Math.Min(pointF.Y, rect.Bottom);
                SizeF sizeF = new SizeF(Math.Min(rect.Width, (float)image.Size.Width), Math.Min(rect.Height, (float)image.Size.Height));
                if ((double)opacity == 1.0)
                {
                    ((Graphics)graphics.UnderlayGraphics).DrawImageUnscaledAndClipped(image, new Rectangle(new Point((int)pointF.X, (int)pointF.Y), sizeF.ToSize()));
                    break;
                }
                graphics.DrawBitmap(image, (int)pointF.X, (int)pointF.Y, (double)opacity);
                break;

            case ImageLayout.Stretch:
                if ((double)opacity == 1.0)
                {
                    graphics.DrawBitmap(image, (int)rect.X, (int)rect.Y, (int)size.Width, (int)size.Height);
                    break;
                }
                graphics.DrawBitmap(image, 0, 0, (int)size.Width, (int)size.Height, (double)opacity);
                break;

            case ImageLayout.Zoom:
                if (image.Width == 0 || image.Height == 0)
                {
                    break;
                }
                float num3 = Math.Min(size.Width / (float)image.Width, size.Height / (float)image.Height);
                if ((double)num3 <= 0.0)
                {
                    break;
                }
                int width  = (int)Math.Round((double)image.Width * (double)num3);
                int height = (int)Math.Round((double)image.Height * (double)num3);
                int x      = (int)rect.X + (int)(((double)size.Width - (double)width) / 2.0);
                int y      = (int)rect.Y + (int)(((double)size.Height - (double)height) / 2.0);
                if ((double)opacity == 1.0)
                {
                    graphics.DrawBitmap(image, x, y, width, height);
                    break;
                }
                graphics.DrawBitmap(image, x, y, width, height, (double)opacity);
                break;
            }
        }
Exemplo n.º 10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (bsState == FlatButtonState.Down)
            {
                e.Graphics.Clear(_BackColorDown.Lerp(_BackShadeColor, _BackShadeRatio));
            }
            else if (bsState == FlatButtonState.Over)
            {
                e.Graphics.Clear(_BackColorOver.Lerp(_BackShadeColor, _BackShadeRatio));
            }
            else
            {
                e.Graphics.Clear(this.BackColor.Lerp(_BackShadeColor, _BackShadeRatio));
            }

            Rectangle rect   = new Rectangle(0, 0, this.Width, this.Height);
            Size      szText = e.Graphics.MeasureString(_Text, this.Font).ToSize();

            if (_Image != null)
            {
                Rectangle rectImage = LayoutUtils.Align(_Image.Size + new Size(_ImagePadding * 2, _ImagePadding * 2), rect, _ImageAlign);
                rectImage.X += _ImagePadding;
                rectImage.Y += _ImagePadding;
                e.Graphics.DrawImage(_Image, new Rectangle(rectImage.Location, _Image.Size));
                if (_TextImageRelation == FlatTextImageRelation.After)
                {
                    using (SolidBrush brush = new SolidBrush(this.ForeColor)) {
                        e.Graphics.DrawString(_Text, this.Font, brush, new Point(
                                                  rectImage.X + _Image.Width + _ImagePadding,
                                                  rectImage.Y + _Image.Height / 2 - szText.Height / 2
                                                  ));
                    }
                }
                else if (_TextImageRelation == FlatTextImageRelation.Before)
                {
                    using (SolidBrush brush = new SolidBrush(this.ForeColor)) {
                        e.Graphics.DrawString(_Text, this.Font, brush, new Point(
                                                  rectImage.X - szText.Width - _ImagePadding,
                                                  rectImage.Y + _Image.Height / 2 - szText.Height / 2
                                                  ));
                    }
                }
                else
                {
                    DrawTextNormal(szText, rect, e);
                }
            }
            else
            {
                DrawTextNormal(szText, rect, e);
            }

            if (_HasBorder)
            {
                using (Pen pen = new Pen(_BorderColor)) {
                    e.Graphics.DrawRectangle(pen, new Rectangle(0, 0, this.Width - 1, this.Height - 1));
                }
            }

            base.OnPaint(e);
        }
Exemplo n.º 11
0
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadCommandBarBaseItemCollection children = this.items;
            int count = children.Count;

            // Get desired children size if EqualChildrenHeight or EqualChildrenWidth is used
            // ********************************************************* //
            SizeF maxDesiredChildrenSize = SizeF.Empty;
            bool  equalChildrenHeight    = false; // this.EqualChildrenHeight;
            bool  equalChildrenWidth     = false; // this.EqualChildrenWidth;

            if (equalChildrenHeight || equalChildrenWidth)
            {
                for (int i = 0; i < count; i++)
                {
                    RadElement element = children[i];
                    if (equalChildrenHeight)
                    {
                        maxDesiredChildrenSize.Height = Math.Max(element.DesiredSize.Height, maxDesiredChildrenSize.Height);
                    }
                    if (equalChildrenWidth)
                    {
                        maxDesiredChildrenSize.Width = Math.Max(element.DesiredSize.Width, maxDesiredChildrenSize.Width);
                    }
                }
            }

            // Parameters
            // ********************************************************* //
            bool isHorizontal  = this.Orientation == Orientation.Horizontal;
            bool isRightToLeft = this.RightToLeft;

            float      length    = 0;
            RectangleF finalRect = new RectangleF(PointF.Empty, arrangeSize);

            if (isHorizontal && isRightToLeft)
            {
                finalRect.X = arrangeSize.Width;
            }

            float stretchedItemArrangedSpace = ArrangeStretchedItems(arrangeSize);

            // Main loop that does the actual arrangement of the children
            // ********************************************************* //
            for (int i = 0; i < count; i++)
            {
                RadElement element = children[i];

                SizeF childArea = element.DesiredSize;
                if (element.Visibility == ElementVisibility.Collapsed)
                {
                    element.Arrange(new RectangleF(PointF.Empty, childArea));
                    continue;
                }

                // ** 1. Calculate the ChildArea
                if (equalChildrenHeight)
                {
                    if (isHorizontal)
                    {
                        childArea.Height = Math.Max(arrangeSize.Height, maxDesiredChildrenSize.Height);
                    }
                    else
                    {
                        childArea.Height = maxDesiredChildrenSize.Height;
                    }
                }
                if (equalChildrenWidth)
                {
                    if (isHorizontal)
                    {
                        childArea.Width = maxDesiredChildrenSize.Width;
                    }
                    else
                    {
                        childArea.Width = Math.Max(arrangeSize.Width, maxDesiredChildrenSize.Width);
                    }
                }
                if (element.StretchHorizontally && isHorizontal && !float.IsInfinity(stretchedItemArrangedSpace))
                {
                    childArea.Width = stretchedItemArrangedSpace;
                }
                if (element.StretchVertically && !isHorizontal && !float.IsInfinity(stretchedItemArrangedSpace))
                {
                    childArea.Height = stretchedItemArrangedSpace;
                }
                // ** 2. Calculate the location and size (finalRect) that will be passed to the child's Arrange
                if (isHorizontal)
                {
                    if (isRightToLeft)
                    {
                        length       = childArea.Width;
                        finalRect.X -= length;
                    }
                    else
                    {
                        finalRect.X += length;
                        length       = childArea.Width;
                    }

                    finalRect.Width = length;

                    if (equalChildrenHeight)
                    {
                        SizeF arrangeArea = finalRect.Size;
                        finalRect.Height = childArea.Height;

                        // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed
                        // by the size forcing
                        // Note that the vertical alignment is not affected by RightToLeft...
                        RectangleF alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), this.Alignment);
                        finalRect.Y += alignedRect.Y;
                    }
                    else
                    {
                        finalRect.Height = arrangeSize.Height;// Math.Max(arrangeSize.Height, childArea.Height);
                    }
                }
                else
                {
                    finalRect.Y     += length;
                    length           = childArea.Height;
                    finalRect.Height = length;
                    if (equalChildrenWidth)
                    {
                        SizeF arrangeArea = finalRect.Size;
                        finalRect.Width = childArea.Width;

                        // Compensate the alignment for EqualChildrenHeight because the basic logic will be bypassed
                        // by the size forcing
                        // Note that the horizontal alignment is translated if RightToLeft is true.
                        ContentAlignment alignment   = isRightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment;
                        RectangleF       alignedRect = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, arrangeArea), alignment);
                        finalRect.X += alignedRect.X;
                    }
                    else
                    {
                        finalRect.Width = arrangeSize.Width;// Math.Max(arrangeSize.Width, childArea.Width);
                    }
                }

                // ** 3. Arrange the child
                if (element.StretchVertically && isHorizontal)
                {
                    finalRect.Height = arrangeSize.Height;
                }
                else if (element.StretchHorizontally && !isHorizontal)
                {
                    finalRect.Width = arrangeSize.Width;
                }
                element.Arrange(finalRect);
            }

            return(arrangeSize);
        }
Exemplo n.º 12
0
        private void CalculateInternalLayoutMetrics()
        {
            Size empty            = Size.Empty;
            Size alignThis        = Size.Empty;
            Size defaultImageSize = ToolStripDropDownMenu.defaultImageSize;
            Size size             = Size.Empty;
            Size size5            = Size.Empty;

            for (int i = 0; i < this.Items.Count; i++)
            {
                ToolStripItem     item  = this.Items[i];
                ToolStripMenuItem item2 = item as ToolStripMenuItem;
                if (item2 != null)
                {
                    Size textSize = item2.GetTextSize();
                    if (item2.ShowShortcutKeys)
                    {
                        Size shortcutTextSize = item2.GetShortcutTextSize();
                        if (this.tabWidth == -1)
                        {
                            this.tabWidth = TextRenderer.MeasureText("\t", this.Font).Width;
                        }
                        textSize.Width += this.tabWidth + shortcutTextSize.Width;
                        textSize.Height = Math.Max(textSize.Height, shortcutTextSize.Height);
                    }
                    empty.Width  = Math.Max(empty.Width, textSize.Width);
                    empty.Height = Math.Max(empty.Height, textSize.Height);
                    Size size8 = Size.Empty;
                    if (item2.Image != null)
                    {
                        size8 = (item2.ImageScaling == ToolStripItemImageScaling.SizeToFit) ? base.ImageScalingSize : item2.Image.Size;
                    }
                    alignThis.Width  = Math.Max(alignThis.Width, size8.Width);
                    alignThis.Height = Math.Max(alignThis.Height, size8.Height);
                    if (item2.CheckedImage != null)
                    {
                        Size size9 = item2.CheckedImage.Size;
                        defaultImageSize.Width  = Math.Max(size9.Width, defaultImageSize.Width);
                        defaultImageSize.Height = Math.Max(size9.Height, defaultImageSize.Height);
                    }
                }
                else if (!(item is ToolStripSeparator))
                {
                    size5.Height = Math.Max(item.Bounds.Height, size5.Height);
                    size5.Width  = Math.Max(item.Bounds.Width, size5.Width);
                }
            }
            this.maxItemSize.Height = Math.Max(empty.Height + TextPadding.Vertical, Math.Max((int)(defaultImageSize.Height + CheckPadding.Vertical), (int)(size.Height + ArrowPadding.Vertical)));
            if (this.ShowImageMargin)
            {
                this.maxItemSize.Height = Math.Max(alignThis.Height + ImagePadding.Vertical, this.maxItemSize.Height);
            }
            if (this.ShowCheckMargin)
            {
                int num1 = defaultImageSize.Width;
            }
            if (this.ShowImageMargin)
            {
                int num6 = alignThis.Width;
            }
            size                    = new Size(10, this.maxItemSize.Height);
            empty.Height            = this.maxItemSize.Height - TextPadding.Vertical;
            alignThis.Height        = this.maxItemSize.Height - ImagePadding.Vertical;
            defaultImageSize.Height = this.maxItemSize.Height - CheckPadding.Vertical;
            empty.Width             = Math.Max(empty.Width, size5.Width);
            Point location = Point.Empty;
            int   width    = 0;
            int   num3     = Math.Max(0, alignThis.Width - ToolStripDropDownMenu.defaultImageSize.Width);

            if (this.ShowCheckMargin && this.ShowImageMargin)
            {
                width               = DefaultImageAndCheckMarginWidth + num3;
                location            = new Point(CheckPadding.Left, CheckPadding.Top);
                this.checkRectangle = LayoutUtils.Align(defaultImageSize, new Rectangle(location.X, location.Y, defaultImageSize.Width, this.maxItemSize.Height), ContentAlignment.MiddleCenter);
                location.X          = (this.checkRectangle.Right + CheckPadding.Right) + ImagePadding.Left;
                location.Y          = ImagePadding.Top;
                this.imageRectangle = LayoutUtils.Align(alignThis, new Rectangle(location.X, location.Y, alignThis.Width, this.maxItemSize.Height), ContentAlignment.MiddleCenter);
            }
            else if (this.ShowCheckMargin)
            {
                width               = DefaultImageMarginWidth;
                location            = new Point(1, CheckPadding.Top);
                this.checkRectangle = LayoutUtils.Align(defaultImageSize, new Rectangle(location.X, location.Y, width, this.maxItemSize.Height), ContentAlignment.MiddleCenter);
                this.imageRectangle = Rectangle.Empty;
            }
            else if (this.ShowImageMargin)
            {
                width               = DefaultImageMarginWidth + num3;
                location            = new Point(1, CheckPadding.Top);
                this.checkRectangle = LayoutUtils.Align(LayoutUtils.UnionSizes(defaultImageSize, alignThis), new Rectangle(location.X, location.Y, width - 1, this.maxItemSize.Height), ContentAlignment.MiddleCenter);
                this.imageRectangle = this.checkRectangle;
            }
            else
            {
                width = 0;
            }
            location.X             = width + 1;
            this.imageMarginBounds = new Rectangle(0, 0, width, base.Height);
            location.X             = this.imageMarginBounds.Right + TextPadding.Left;
            location.Y             = TextPadding.Top;
            this.textRectangle     = new Rectangle(location, empty);
            location.X             = (this.textRectangle.Right + TextPadding.Right) + ArrowPadding.Left;
            location.Y             = ArrowPadding.Top;
            this.arrowRectangle    = new Rectangle(location, size);
            this.maxItemSize.Width = (this.arrowRectangle.Right + ArrowPadding.Right) - this.imageMarginBounds.Left;
            base.Padding           = this.DefaultPadding;
            int num4 = this.imageMarginBounds.Width;

            if (this.RightToLeft == RightToLeft.Yes)
            {
                num4 += TextPadding.Right;
                int num5 = this.maxItemSize.Width;
                this.checkRectangle.X    = num5 - this.checkRectangle.Right;
                this.imageRectangle.X    = num5 - this.imageRectangle.Right;
                this.textRectangle.X     = num5 - this.textRectangle.Right;
                this.arrowRectangle.X    = num5 - this.arrowRectangle.Right;
                this.imageMarginBounds.X = num5 - this.imageMarginBounds.Right;
            }
            else
            {
                num4 += TextPadding.Left;
            }
            this.maxItemSize.Height          += this.maxItemSize.Height % 2;
            this.textRectangle.Y              = LayoutUtils.VAlign(this.textRectangle.Size, new Rectangle(Point.Empty, this.maxItemSize), ContentAlignment.MiddleCenter).Y;
            this.textRectangle.Y             += this.textRectangle.Height % 2;
            this.state[stateMaxItemSizeValid] = true;
            this.PaddingToTrim = num4;
        }
Exemplo n.º 13
0
        public override SizeF Arrange(RectangleF bounds)
        {
            SizeF size = bounds.Size;

            if (this.lastFinalSize != size || this.isDirty)
            {
                this.lastFinalSize = size;
                this.Measure(size);
            }
            SizeF             sizeF1           = size;
            RectangleF        rectangleF1      = new RectangleF(bounds.Location, size);
            RectangleF        empty1           = RectangleF.Empty;
            RectangleF        region2          = RectangleF.Empty;
            SizeF             empty2           = SizeF.Empty;
            SizeF             empty3           = SizeF.Empty;
            ContentAlignment  contentAlignment = this.Owner.ImageAlignment;
            TextImageRelation relation         = this.Owner.TextImageRelation;

            if (this.Owner.RightToLeft)
            {
                contentAlignment = TelerikAlignHelper.RtlTranslateContent(contentAlignment);
                relation         = TelerikAlignHelper.RtlTranslateRelation(relation);
            }
            if (this.left != null && this.Owner.Image == null)
            {
                this.left.Arrange(rectangleF1);
                if (this.right != null)
                {
                    this.right.Arrange(rectangleF1);
                }
                return(size);
            }
            if (this.right != null && (string.IsNullOrEmpty(this.Owner.Text) || !this.Owner.DrawText))
            {
                this.right.Arrange(rectangleF1);
                if (this.left != null)
                {
                    this.left.Arrange(rectangleF1);
                }
                return(size);
            }
            SizeF invariantLength1 = (SizeF)this.GetInvariantLength(Size.Ceiling(this.left.DesiredSize), this.left.Margin);
            SizeF invariantLength2 = (SizeF)this.GetInvariantLength(Size.Ceiling(this.right.DesiredSize), this.right.Margin);

            LayoutUtils.SubAlignedRegion(sizeF1, invariantLength1, relation);
            SizeF      sizeF2 = LayoutUtils.AddAlignedRegion(invariantLength2, invariantLength1, relation);
            RectangleF empty4 = (RectangleF)Rectangle.Empty;

            empty4.Size = LayoutUtils.UnionSizes(sizeF1, sizeF2);
            empty4.X   += rectangleF1.X;
            empty4.Y   += rectangleF1.Y;
            bool flag1 = (TelerikAlignHelper.ImageAlignToRelation(contentAlignment) & relation) != TextImageRelation.Overlay;
            bool flag2 = (TelerikAlignHelper.TextAlignToRelation(this.Owner.TextAlignment) & relation) != TextImageRelation.Overlay;

            if (flag1)
            {
                LayoutUtils.SplitRegion(empty4, invariantLength1, (AnchorStyles)relation, out empty1, out region2);
            }
            else if (flag2)
            {
                LayoutUtils.SplitRegion(empty4, invariantLength2, (AnchorStyles)LayoutUtils.GetOppositeTextImageRelation(relation), out region2, out empty1);
            }
            else if (relation == TextImageRelation.Overlay)
            {
                LayoutUtils.SplitRegion(empty4, invariantLength1, (AnchorStyles)relation, out empty1, out region2);
            }
            else
            {
                LayoutUtils.SplitRegion(LayoutUtils.Align(sizeF2, empty4, ContentAlignment.MiddleCenter), invariantLength1, (AnchorStyles)relation, out empty1, out region2);
                LayoutUtils.ExpandRegionsToFillBounds(empty4, (AnchorStyles)relation, ref empty1, ref region2);
            }
            if (relation == TextImageRelation.TextBeforeImage || relation == TextImageRelation.ImageBeforeText)
            {
                float num = Math.Min(region2.Bottom, rectangleF1.Bottom);
                region2.Y      = Math.Max(Math.Min(region2.Y, rectangleF1.Y + (float)(((double)rectangleF1.Height - (double)region2.Height) / 2.0)), rectangleF1.Y);
                region2.Height = num - region2.Y;
            }
            if (relation == TextImageRelation.TextAboveImage || relation == TextImageRelation.ImageAboveText)
            {
                float num = Math.Min(region2.Right, rectangleF1.Right);
                region2.X     = Math.Max(Math.Min(region2.X, rectangleF1.X + (float)(((double)rectangleF1.Width - (double)region2.Width) / 2.0)), rectangleF1.X);
                region2.Width = num - region2.X;
            }
            if (relation == TextImageRelation.ImageBeforeText && (double)empty1.Size.Width != 0.0)
            {
                empty1.Width = Math.Max(0.0f, Math.Min(sizeF1.Width - region2.Width, empty1.Width));
                region2.X    = empty1.X + empty1.Width;
            }
            if (relation == TextImageRelation.ImageAboveText && (double)empty1.Size.Height != 0.0)
            {
                empty1.Height = Math.Max(0.0f, Math.Min(sizeF1.Height - region2.Height, empty1.Height));
                region2.Y     = empty1.Y + empty1.Height;
            }
            region2 = RectangleF.Intersect(region2, rectangleF1);
            RectangleF rectangleF2 = LayoutUtils.Align(invariantLength1, empty1, contentAlignment);

            if ((double)rectangleF2.Width > (double)empty1.Width)
            {
                rectangleF2.X = empty1.Width - invariantLength1.Width;
            }
            if ((double)rectangleF2.Height > (double)empty1.Height)
            {
                rectangleF2.Y = empty1.Height - invariantLength1.Height;
            }
            region2.Size = SizeF.Subtract(region2.Size, (SizeF)this.left.Margin.Size);
            empty1.Size  = SizeF.Subtract(empty1.Size, (SizeF)this.right.Margin.Size);
            this.left.Arrange(empty1);
            this.right.Arrange(region2);
            return(size);
        }
Exemplo n.º 14
0
        public override SizeF Arrange(RectangleF bounds)
        {
            SizeF finalSize = bounds.Size;

            if (this.lastFinalSize != finalSize || this.isDirty)
            {
                this.lastFinalSize = finalSize;
                this.Measure(finalSize);
            }

            SizeF      fieldSize   = finalSize;
            RectangleF layoutField = new RectangleF(bounds.Location, finalSize);

            RectangleF imageBounds = RectangleF.Empty;
            RectangleF textBounds  = RectangleF.Empty;
            SizeF      textSize    = SizeF.Empty;
            SizeF      imageSize   = SizeF.Empty;

            ContentAlignment  imageAlign        = this.owner.ImageAlignment;
            ContentAlignment  textAlign         = this.owner.TextAlignment;
            TextImageRelation textImageRelation = this.owner.TextImageRelation;

            if (this.owner.RightToLeft)
            {
                imageAlign        = TelerikAlignHelper.RtlTranslateContent(imageAlign);
                textAlign         = TelerikAlignHelper.RtlTranslateContent(textAlign);
                textImageRelation = TelerikAlignHelper.RtlTranslateRelation(textImageRelation);
            }

            if ((this.left != null) && (this.owner.Image == null))
            {
                this.left.Arrange(layoutField);
                if (this.right != null)
                {
                    this.right.Arrange(layoutField);
                }
                return(finalSize);
            }
            if (this.right != null && (string.IsNullOrEmpty(this.owner.Text) || !this.owner.DrawText))
            {
                this.right.Arrange(layoutField);
                if (this.left != null)
                {
                    this.left.Arrange(layoutField);
                }
                return(finalSize);
            }

            imageSize = this.GetInvariantLength(Size.Ceiling(this.left.DesiredSize), this.left.Margin);
            textSize  = this.GetInvariantLength(Size.Ceiling(this.right.DesiredSize), this.right.Margin);

            // Subtract the image size from the whole field size
            SizeF textSizeLeft = LayoutUtils.SubAlignedRegion(fieldSize, imageSize, textImageRelation);
            // Create a new size based on the text size and the image size
            SizeF newSize = LayoutUtils.AddAlignedRegion(textSize, imageSize, textImageRelation);

            // The new field which is a union of the new sizes
            RectangleF maxFieldRectangle = Rectangle.Empty;

            maxFieldRectangle.Size = LayoutUtils.UnionSizes(fieldSize, newSize);
            maxFieldRectangle.X   += layoutField.X;
            maxFieldRectangle.Y   += layoutField.Y;
            // Image doesn't overlay text
            bool imageAlignNoOverlay = (TelerikAlignHelper.ImageAlignToRelation(imageAlign) & textImageRelation) != TextImageRelation.Overlay;
            // Text doesn't overlay image
            bool textAlignNoOverlay = (TelerikAlignHelper.TextAlignToRelation(textAlign) & textImageRelation) != TextImageRelation.Overlay;

            if (imageAlignNoOverlay)
            {
                LayoutUtils.SplitRegion(maxFieldRectangle, imageSize, (AnchorStyles)textImageRelation, out imageBounds, out textBounds);
            }
            else if (textAlignNoOverlay)
            {
                LayoutUtils.SplitRegion(maxFieldRectangle, textSize, (AnchorStyles)LayoutUtils.GetOppositeTextImageRelation(textImageRelation), out textBounds, out imageBounds);
            }
            else
            {
                // Both image overlays text and text overlays image
                if (textImageRelation == TextImageRelation.Overlay)
                {
                    LayoutUtils.SplitRegion(maxFieldRectangle, imageSize, (AnchorStyles)textImageRelation, out imageBounds, out textBounds);
                }
                else
                {
                    RectangleF alignedField = LayoutUtils.Align(newSize, maxFieldRectangle, ContentAlignment.MiddleCenter);
                    LayoutUtils.SplitRegion(alignedField, imageSize, (AnchorStyles)textImageRelation, out imageBounds, out textBounds);
                    LayoutUtils.ExpandRegionsToFillBounds(maxFieldRectangle, (AnchorStyles)textImageRelation, ref imageBounds, ref textBounds);
                }
            }
            ///////////////////////////////////////////////////////////////////////////

            //set image and text bounds according the size of the field
            if ((textImageRelation == TextImageRelation.TextBeforeImage) || (textImageRelation == TextImageRelation.ImageBeforeText))
            {
                float num1 = Math.Min(textBounds.Bottom, layoutField.Bottom);
                textBounds.Y      = Math.Max(Math.Min(textBounds.Y, layoutField.Y + ((layoutField.Height - textBounds.Height) / 2)), layoutField.Y);
                textBounds.Height = num1 - textBounds.Y;
            }
            if ((textImageRelation == TextImageRelation.TextAboveImage) || (textImageRelation == TextImageRelation.ImageAboveText))
            {
                float num2 = Math.Min(textBounds.Right, layoutField.Right);
                textBounds.X     = Math.Max(Math.Min(textBounds.X, layoutField.X + ((layoutField.Width - textBounds.Width) / 2)), layoutField.X);
                textBounds.Width = num2 - textBounds.X;
            }
            if ((textImageRelation == TextImageRelation.ImageBeforeText) && (imageBounds.Size.Width != 0))
            {
                imageBounds.Width = Math.Max(0, Math.Min(fieldSize.Width - textBounds.Width, imageBounds.Width));
                textBounds.X      = imageBounds.X + imageBounds.Width;
            }
            if ((textImageRelation == TextImageRelation.ImageAboveText) && (imageBounds.Size.Height != 0))
            {
                imageBounds.Height = Math.Max(0, Math.Min(fieldSize.Height - textBounds.Height, imageBounds.Height));
                textBounds.Y       = imageBounds.Y + imageBounds.Height;
            }
            textBounds = RectangleF.Intersect(textBounds, layoutField);

            //align image and if its size is greater than the field's size it is become offseted as much as the difference
            RectangleF newImageBounds = LayoutUtils.Align(imageSize, imageBounds, imageAlign);

            if (newImageBounds.Width > imageBounds.Width)
            {
                newImageBounds.X = imageBounds.Width - imageSize.Width;
            }
            if (newImageBounds.Height > imageBounds.Height)
            {
                newImageBounds.Y = imageBounds.Height - imageSize.Height;
            }

            textBounds = LayoutUtils.Align(textSize, textBounds, textAlign);
            //textBounds.Offset(layoutField.Location);
            //imageBounds.Offset(layoutField.Location);

            /////////////////////////////////////////////////////////////////////////
            textBounds.Size  = SizeF.Subtract(textBounds.Size, this.left.Margin.Size);
            imageBounds.Size = SizeF.Subtract(imageBounds.Size, this.right.Margin.Size);

            this.left.Arrange(imageBounds);
            this.right.Arrange(textBounds);

            return(finalSize);
        }
Exemplo n.º 15
0
        protected override SizeF ArrangeOverride(SizeF arrangeSize)
        {
            RadCommandBarBaseItemCollection items = this.items;
            int   count = items.Count;
            SizeF empty = SizeF.Empty;
            bool  flag1 = false;
            bool  flag2 = false;

            if (flag1 || flag2)
            {
                for (int index = 0; index < count; ++index)
                {
                    RadElement radElement = (RadElement)items[index];
                    if (flag1)
                    {
                        empty.Height = Math.Max(radElement.DesiredSize.Height, empty.Height);
                    }
                    if (flag2)
                    {
                        empty.Width = Math.Max(radElement.DesiredSize.Width, empty.Width);
                    }
                }
            }
            bool       flag3       = this.Orientation == Orientation.Horizontal;
            bool       rightToLeft = this.RightToLeft;
            float      num         = 0.0f;
            RectangleF finalRect   = new RectangleF(PointF.Empty, arrangeSize);

            if (flag3 && rightToLeft)
            {
                finalRect.X = arrangeSize.Width;
            }
            float f = this.ArrangeStretchedItems(arrangeSize);

            for (int index = 0; index < count; ++index)
            {
                RadElement radElement  = (RadElement)items[index];
                SizeF      desiredSize = radElement.DesiredSize;
                if (radElement.Visibility == ElementVisibility.Collapsed)
                {
                    radElement.Arrange(new RectangleF(PointF.Empty, desiredSize));
                }
                else
                {
                    if (flag1)
                    {
                        desiredSize.Height = !flag3 ? empty.Height : Math.Max(arrangeSize.Height, empty.Height);
                    }
                    if (flag2)
                    {
                        desiredSize.Width = !flag3?Math.Max(arrangeSize.Width, empty.Width) : empty.Width;
                    }
                    if (radElement.StretchHorizontally && flag3 && !float.IsInfinity(f))
                    {
                        desiredSize.Width = f;
                    }
                    if (radElement.StretchVertically && !flag3 && !float.IsInfinity(f))
                    {
                        desiredSize.Height = f;
                    }
                    if (flag3)
                    {
                        if (rightToLeft)
                        {
                            num          = desiredSize.Width;
                            finalRect.X -= num;
                        }
                        else
                        {
                            finalRect.X += num;
                            num          = desiredSize.Width;
                        }
                        finalRect.Width = num;
                        if (flag1)
                        {
                            SizeF size = finalRect.Size;
                            finalRect.Height = desiredSize.Height;
                            RectangleF rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), this.Alignment);
                            finalRect.Y += rectangleF.Y;
                        }
                        else
                        {
                            finalRect.Height = arrangeSize.Height;
                        }
                    }
                    else
                    {
                        finalRect.Y     += num;
                        num              = desiredSize.Height;
                        finalRect.Height = num;
                        if (flag2)
                        {
                            SizeF size = finalRect.Size;
                            finalRect.Width = desiredSize.Width;
                            ContentAlignment align      = rightToLeft ? TelerikAlignHelper.RtlTranslateContent(this.Alignment) : this.Alignment;
                            RectangleF       rectangleF = LayoutUtils.Align(finalRect.Size, new RectangleF(PointF.Empty, size), align);
                            finalRect.X += rectangleF.X;
                        }
                        else
                        {
                            finalRect.Width = arrangeSize.Width;
                        }
                    }
                    if (radElement.StretchVertically && flag3)
                    {
                        finalRect.Height = arrangeSize.Height;
                    }
                    else if (radElement.StretchHorizontally && !flag3)
                    {
                        finalRect.Width = arrangeSize.Width;
                    }
                    radElement.Arrange(finalRect);
                }
            }
            return(arrangeSize);
        }