Пример #1
0
        protected override void Layout(GwenSkin.Base skin)
        {
            base.Layout(skin);
            if (!mLayoutRequired)
            {
                return;
            }
            mLayoutRequired = false;
            if (LabelColor.HasValue)
            {
                mLabel.AddText(LabelText, LabelColor.Value);
            }
            else
            {
                mLabel.AddText(LabelText, SystemDrawing.Color.Black);
            }
            if (!WordWrapLabel)
            {
                var measure = mLabel.Skin.Renderer.MeasureText(LabelFont, LabelText);
                mLabel.SetSize(measure.X, measure.Y);
                //Function.Log(String.Format("WordWrap disabled {0} {1} {2} {3} {4} {5}", measure.X, measure.Y, LabelColor.HasValue ? LabelColor.Value.ToString() : "none", LabelFont.FaceName, LabelFont.Size, LabelText));
            }
            else
            {
                mLabel.SizeToChildren();
            }
            //if (WordWrapLabel)
            //{
            //    mLabel.SizeWidthWith(this);
            //    mLabel.SizeToChildren(false, true);
            //}
            //else
            //    mLabel.SizeToChildren(true, true);

            switch (LabelPosition)
            {
            case RelationalPosition.LEFT:
                Component.PlaceRightOf(mLabel, mSpaceBetweenLabelAndComponent);
                break;

            case RelationalPosition.RIGHT:
                mLabel.PlaceRightOf(Component, mSpaceBetweenLabelAndComponent);
                break;

            case RelationalPosition.TOP:
                Component.PlaceBelowOf(mLabel, mSpaceBetweenLabelAndComponent);

                break;

            case RelationalPosition.BOTTOM:
                mLabel.PlaceBelowOf(Component, mSpaceBetweenLabelAndComponent);
                break;
            }

            mLabel.LogPositionAndSize();
            Component.LogPositionAndSize();
            this.SizeToChildren();
        }