コード例 #1
0
        // Determine the path between controls, and the drop targets.
        SymPath PathBetweenControls(ControlPosition controlPosition1, ControlPosition controlPosition2, ForkPosition forkStart, out List <DropTarget> dropTargets)
        {
            float xStart = controlPosition1.x;
            float yStart = controlPosition1.y;
            float xEnd   = controlPosition2.x;
            float yEnd   = controlPosition2.y;

            dropTargets = new List <DropTarget>();

            if (forkStart != null)
            {
                if (forkStart.loopFallThru)
                {
                    dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.Normal));
                }
                else if (forkStart.loopStart)
                {
                    dropTargets.Add(new DropTarget(forkStart.x, forkStart.y - 0.5F, LegInsertionLoc.Normal));
                }
                else
                {
                    dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.PreSplit));
                    dropTargets.Add(new DropTarget(forkStart.x, forkStart.y - 0.5F, LegInsertionLoc.Normal));
                    if (forkStart.x != xEnd)
                    {
                        // Empty fork.
                        dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
                    }
                }
            }
            else if (xEnd != xStart)
            {
                // Below start control (use when a join is going)
                dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.Normal));
                if (yEnd > yStart)
                {
                    // Right before join point.
                    dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
                }
            }
            else if (yEnd > yStart + 1.25)
            {
                // Straight down, but must have join at end.
                dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.Normal));
                dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
            }
            else
            {
                // Above end control (other cases).
                dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.Normal));
            }

            bool startHorizontal = false;

            if (forkStart != null)
            {
                startHorizontal = forkStart.loopStart;
            }

            if (forkStart != null && forkStart.x != controlPosition2.x)
            {
                // The fork start in a different horizontal position than it ends. This is probably due to a fork with no controls on it.
                // Create the path in two pieces.
                float   xMiddle = forkStart.x;
                float   yMiddle = forkStart.y;
                SymPath path1   = PathFromStartToEnd(xStart, yStart, xMiddle, yMiddle, startHorizontal, 0);
                SymPath path3   = PathFromStartToEnd(xMiddle, yMiddle, xEnd, yEnd, false, controlPosition2.loopBottom);
                SymPath path2   = new SymPath(new[] { path1.LastPoint, path3.FirstPoint });
                return(SymPath.Join(SymPath.Join(path1, path2, PointKind.Normal), path3, PointKind.Normal));
            }
            else
            {
                return(PathFromStartToEnd(xStart, yStart, xEnd, yEnd, startHorizontal, controlPosition2.loopBottom));
            }
        }