Esempio n. 1
0
    void CalculateArrangeRectVertically(RPNode node, out double y, out double height)
    {
        Rect   measureRect   = node.m_measureRect;
        double desiredHeight = Math.Min(measureRect.Height, node.GetDesiredHeight());

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

        // The initial values correspond to the top corner, using the
        // desired size of element. If no attached properties were set,
        // this means that the element will default to the top corner of
        // the panel.
        y      = measureRect.Y;
        height = desiredHeight;

        if (node.IsTopAnchored())
        {
            if (node.IsBottomAnchored())
            {
                y      = measureRect.Y;
                height = measureRect.Height;
            }
            else
            {
                y      = measureRect.Y;
                height = desiredHeight;
            }
        }
        else if (node.IsBottomAnchored())
        {
            y      = measureRect.Y + measureRect.Height - desiredHeight;
            height = desiredHeight;
        }
        else if (node.IsVerticalCenterAnchored())
        {
            y      = measureRect.Y + (measureRect.Height / 2.0f) - (desiredHeight / 2.0f);
            height = desiredHeight;
        }
    }