コード例 #1
0
ファイル: LayoutBehaviour.cs プロジェクト: Fedorm/core-master
        public static Bound Screen(StyleSheet.StyleSheet stylesheet
                                   , ILayoutable parent
                                   , ILayoutable control
                                   , Bound screenBound)
        {
            IStyleSheetHelper style = stylesheet.Helper;

            float parentW     = screenBound.Width;
            float parentH     = screenBound.Height;
            float paddingL    = style.Padding <PaddingLeft>(parent, parentW);
            float paddingT    = style.Padding <PaddingTop>(parent, parentH);
            float paddingR    = style.Padding <PaddingRight>(parent, parentW);
            float paddingB    = style.Padding <PaddingBottom>(parent, parentH);
            float borderWidth = style.BorderWidth(parent);

            float w       = style.Width(control, parentW);
            float h       = style.Height(control, parentH);
            float marginL = style.Margin <MarginLeft>(control, parentW);
            float marginT = style.Margin <MarginTop>(control, parentH);
            float marginR = style.Margin <MarginRight>(control, parentW);
            float marginB = style.Margin <MarginBottom>(control, parentH);

            InitializeImageContainer(stylesheet, control, ref w, ref h);

            float maxW = parentW - (marginL + marginR) - (paddingL + paddingR) - 2 * borderWidth;

            if (parentW < paddingL + marginL + w + marginR + paddingR + 2 * borderWidth)
            {
                w = maxW;
            }

            float maxH = parentH - (marginT + marginB) - (paddingT + paddingB) - 2 * borderWidth;

            if (parentH < paddingT + marginT + h + marginB + paddingB + 2 * borderWidth)
            {
                h = maxH;
            }

            float l = borderWidth + paddingL + marginL;
            float t = borderWidth + paddingT + marginT;

            Bound bound = control.Apply(stylesheet, new Bound(w, h), new Bound(maxW, maxH));

            w = bound.Width > maxW ? maxW : bound.Width;
            h = bound.Height > maxH ? maxH : bound.Height;

            control.Frame = new Rectangle(l, t, w, h);
            return(screenBound);
        }
コード例 #2
0
ファイル: LayoutBehaviour.cs プロジェクト: Fedorm/core-master
        public static Bound Screen(StyleSheet.StyleSheet stylesheet
            , ILayoutable parent
            , ILayoutable control
            , Bound screenBound)
        {
            IStyleSheetHelper style = stylesheet.Helper;

            float parentW = screenBound.Width;
            float parentH = screenBound.Height;
            float paddingL = style.Padding<PaddingLeft>(parent, parentW);
            float paddingT = style.Padding<PaddingTop>(parent, parentH);
            float paddingR = style.Padding<PaddingRight>(parent, parentW);
            float paddingB = style.Padding<PaddingBottom>(parent, parentH);
            float borderWidth = style.BorderWidth(parent);

            float w = style.Width(control, parentW);
            float h = style.Height(control, parentH);
            float marginL = style.Margin<MarginLeft>(control, parentW);
            float marginT = style.Margin<MarginTop>(control, parentH);
            float marginR = style.Margin<MarginRight>(control, parentW);
            float marginB = style.Margin<MarginBottom>(control, parentH);

            InitializeImageContainer(stylesheet, control, ref w, ref h);

            float maxW = parentW - (marginL + marginR) - (paddingL + paddingR) - 2 * borderWidth;
            if (parentW < paddingL + marginL + w + marginR + paddingR + 2 * borderWidth)
                w = maxW;

            float maxH = parentH - (marginT + marginB) - (paddingT + paddingB) - 2 * borderWidth;
            if (parentH < paddingT + marginT + h + marginB + paddingB + 2 * borderWidth)
                h = maxH;

            float l = borderWidth + paddingL + marginL;
            float t = borderWidth + paddingT + marginT;

            Bound bound = control.Apply(stylesheet, new Bound(w, h), new Bound(maxW, maxH));
            w = bound.Width > maxW ? maxW : bound.Width;
            h = bound.Height > maxH ? maxH : bound.Height;

            control.Frame = new Rectangle(l, t, w, h);
            return screenBound;
        }