Esempio n. 1
0
    void CalculateArrangeRectHorizontally(RPNode node, out double x, out double width)
    {
        Rect   measureRect  = node.m_measureRect;
        double desiredWidth = Math.Min(measureRect.Width, node.GetDesiredWidth());

        MUX_ASSERT(node.IsMeasured() && (measureRect.Width != double.PositiveInfinity));

        // The initial values correspond to the left corner, using the
        // desired size of element. If no attached properties were set,
        // this means that the element will default to the left corner of
        // the panel.
        x     = measureRect.X;
        width = desiredWidth;

        if (node.IsLeftAnchored())
        {
            if (node.IsRightAnchored())
            {
                x     = measureRect.X;
                width = measureRect.Width;
            }
            else
            {
                x     = measureRect.X;
                width = desiredWidth;
            }
        }
        else if (node.IsRightAnchored())
        {
            x     = measureRect.X + measureRect.Width - desiredWidth;
            width = desiredWidth;
        }
        else if (node.IsHorizontalCenterAnchored())
        {
            x     = measureRect.X + (measureRect.Width / 2.0f) - (desiredWidth / 2.0f);
            width = desiredWidth;
        }
    }