GetValue() public method

public GetValue ( float containerSize ) : float
containerSize float
return float
コード例 #1
0
ファイル: UIElement.cs プロジェクト: egshels/Sources
        private CalculatedStyle GetDimensionsBasedOnParentDimensions(CalculatedStyle parentDimensions)
        {
            CalculatedStyle result = default(CalculatedStyle);

            result.X = Left.GetValue(parentDimensions.Width) + parentDimensions.X;
            result.Y = Top.GetValue(parentDimensions.Height) + parentDimensions.Y;
            float value  = MinWidth.GetValue(parentDimensions.Width);
            float value2 = MaxWidth.GetValue(parentDimensions.Width);
            float value3 = MinHeight.GetValue(parentDimensions.Height);
            float value4 = MaxHeight.GetValue(parentDimensions.Height);

            result.Width   = MathHelper.Clamp(Width.GetValue(parentDimensions.Width), value, value2);
            result.Height  = MathHelper.Clamp(Height.GetValue(parentDimensions.Height), value3, value4);
            result.Width  += MarginLeft + MarginRight;
            result.Height += MarginTop + MarginBottom;
            result.X      += parentDimensions.Width * HAlign - result.Width * HAlign;
            result.Y      += parentDimensions.Height * VAlign - result.Height * VAlign;
            return(result);
        }
コード例 #2
0
        public virtual void Recalculate()
        {
            CalculatedStyle calculatedStyle  = (Parent == null) ? UserInterface.ActiveInstance.GetDimensions() : Parent.GetInnerDimensions();
            CalculatedStyle calculatedStyle2 = default(CalculatedStyle);

            calculatedStyle2.X = Left.GetValue(calculatedStyle.Width) + calculatedStyle.X;
            calculatedStyle2.Y = Top.GetValue(calculatedStyle.Height) + calculatedStyle.Y;
            float value  = MinWidth.GetValue(calculatedStyle.Width);
            float value2 = MaxWidth.GetValue(calculatedStyle.Width);
            float value3 = MinHeight.GetValue(calculatedStyle.Height);
            float value4 = MaxHeight.GetValue(calculatedStyle.Height);

            calculatedStyle2.Width   = MathHelper.Clamp(Width.GetValue(calculatedStyle.Width), value, value2);
            calculatedStyle2.Height  = MathHelper.Clamp(Height.GetValue(calculatedStyle.Height), value3, value4);
            calculatedStyle2.X      += calculatedStyle.Width * HAlign - calculatedStyle2.Width * HAlign;
            calculatedStyle2.Y      += calculatedStyle.Height * VAlign - calculatedStyle2.Height * VAlign;
            _dimensions              = calculatedStyle2;
            calculatedStyle2.X      += PaddingLeft;
            calculatedStyle2.Y      += PaddingTop;
            calculatedStyle2.Width  -= PaddingLeft + PaddingRight;
            calculatedStyle2.Height -= PaddingTop + PaddingBottom;
            _innerDimensions         = calculatedStyle2;
            RecalculateChildren();
        }