示例#1
0
        public override void Layout()
        {
            if (_drawable == null)
            {
                return;
            }

            float regionWidth  = _drawable.MinWidth;
            float regionHeight = _drawable.MinHeight;
            float width        = Width;
            float height       = Height;

            Vector2 size = Scaling.Apply(regionWidth, regionHeight, width, height);

            ImageWidth  = size.X;
            ImageHeight = size.Y;

            if ((Align & Alignment.Left) != 0)
            {
                ImageX = 0;
            }
            else if ((Align & Alignment.Right) != 0)
            {
                ImageX = (int)(width - ImageWidth);
            }
            else
            {
                ImageX = (int)(width / 2 - ImageWidth / 2);
            }

            if ((Align & Alignment.Top) != 0)
            {
                ImageY = (int)(height - ImageHeight);
            }
            else if ((Align & Alignment.Bottom) != 0)
            {
                ImageY = 0;
            }
            else
            {
                ImageY = (int)(height / 2 - ImageHeight / 2);
            }
        }
示例#2
0
        public override void Layout()
        {
            if (_drawable == null)
            {
                return;
            }

            var regionWidth  = _drawable.MinWidth;
            var regionHeight = _drawable.MinHeight;

            var size = _scaling.Apply(regionWidth, regionHeight, width, height);

            imageWidth  = size.X;
            imageHeight = size.Y;

            if ((_align & AlignInternal.Left) != 0)
            {
                imageX = 0;
            }
            else if ((_align & AlignInternal.Right) != 0)
            {
                imageX = (int)(width - imageWidth);
            }
            else
            {
                imageX = (int)(width / 2 - imageWidth / 2);
            }

            if ((_align & AlignInternal.Top) != 0)
            {
                imageY = (int)(height - imageHeight);
            }
            else if ((_align & AlignInternal.Bottom) != 0)
            {
                imageY = 0;
            }
            else
            {
                imageY = (int)(height / 2 - imageHeight / 2);
            }
        }