Пример #1
0
        public bool handleConnection(Box b)
        {
            if (this == b)
            {
                return(false);
            }

            ConnectionLine line = new ConnectionLine(TLCorner, b.TLCorner, ref surface);

            surface.Shapes.Add(line);

            Connect(ref line);

            b.Connect(ref line);

            FinishConnection();
            b.FinishConnection();

            return(true);
        }
Пример #2
0
        public void Connect(ref ConnectionLine line)
        {
            default_anchor = line;

            line.Connect(this);

            /*	How connecting works
             *
             *	1.) The user right-clicks on a box and clicks "Connect To..."
             *
             *	2.) A line is created, and immediately connected to the box the user right-clicked on.
             *		2a.) The Drawing Surface calls the line's Connect() function, passing the box.
             *		2b.) The Drawing Surface then calls the box's Connect() function, passing the line.
             *			2ba.) The box must choose which anchor point to connect the line to. It could ask for the location of the connected endpoint.
             *			OR
             *			the line could ask the box to pick an anchor point, passing a point (e.g. the current position of the cursor), so it can find the closest anchor point.
             *
             *			OR OR
             *			The box could just pick a default anchor point (e.g. bottom), and then once both boxes have been connected, call a method to choose which anchor point
             *			to move the endpoint to.
             *
             *	3.) The user then clicks on a second box to finish the connection.
             *		3a.) The Drawing Surface calls the line's Connect() function, passing the box.
             *		3b.) The Drawing Surface then calls the box's Connect() function, passing the line.
             *			3ba.) The box stores the line in a default anchor
             *
             *	4.) The Drawing surface, knowing that the connection has been made, calls the second box's FinishConnection() function.
             *		4a.) The function asks the line in it's default anchor for the position of the far endpoint
             *			4aa.) the box could pass it's default_anchor position to the line, which will then compare to the locations of it's endpoints.
             *				The line will then return the position of the endpoint connected to the other box.
             *		4b.) The box then chooses which anchor point is closest to that far endpoint, moving the line into the appropriate List, and telling the line to move
             *			the endpoint to the new position.
             *
             *	5.) repeat step 4 but with the first box.
             *
             */
        }