Exemplo n.º 1
0
        private Rectangle PositionBeak(double beakWidth, ElementPositionInfo elementPosition)
        {
            var target          = elementPosition.TargetRectangle;
            var edges           = GetFlankingEdges(elementPosition.TargetEdge);
            var beakTargetPoint = GetCenterValue(target, elementPosition.TargetEdge);
            var elementBounds   = new Rectangle(
                beakWidth / 2,
                elementPosition.ElementRectangle.width - beakWidth / 2,
                beakWidth / 2,
                elementPosition.ElementRectangle.height - beakWidth / 2
                );
            var beakPosition = new Rectangle(0, beakWidth, 0, beakWidth);

            beakPosition = MoveEdge(beakPosition, (RectangleEdge)((int)elementPosition.TargetEdge * -1), -beakWidth / 2);
            beakPosition = CenterEdgeToPoint(
                beakPosition,
                (RectangleEdge)((int)elementPosition.TargetEdge * -1),
                beakTargetPoint - GetRelativeRectEdgeValue(edges.positiveEdge, elementPosition.ElementRectangle)
                );

            if (!IsEdgeInBounds(beakPosition, elementBounds, edges.positiveEdge))
            {
                beakPosition = AlignEdges(beakPosition, elementBounds, edges.positiveEdge);
            }
            else if (!IsEdgeInBounds(beakPosition, elementBounds, edges.negativeEdge))
            {
                beakPosition = AlignEdges(beakPosition, elementBounds, edges.negativeEdge);
            }

            return(beakPosition);
        }
Exemplo n.º 2
0
        private async Task <(PartialRectangle element, RectangleEdge targetEdge, RectangleEdge alignmentEdge)> FinalizePositionDataAsync(ElementPositionInfo positionedElement, Rectangle bounds)
        {
            var finalizedElement = await FinalizeElementPositionAsync(positionedElement.ElementRectangle, /*hostElement,*/ positionedElement.TargetEdge, bounds, positionedElement.AlignmentEdge);

            return(finalizedElement, positionedElement.TargetEdge, positionedElement.AlignmentEdge);
        }