Learn how to add connector functionality to a designer from WPF Diagram Designer Part 3

Source: Internet
Author: User

Learn about control templates, move, resize, and rotate from WPF Diagram Designer Part 1, and from the WPF Diagram Designer Part 2 Learning panel, thumbnails, border selection, and toolbox, we learned how to build basic movement of the graphics designer. , selection, size, rotation, thumbnail, box selection and other basic functions. For modeling support, flowcharts are an essential form of graphics, so how do we get the graphics designer to support drawing arrows between design objects? This article describes the connections in the graphics designer.

WPF Diagram Designer-part 3

There are several ways to do this, one is to provide a connection element in the toolbox, it is then dragged by the designer in two components, and one that provides the connection point by the component itself, and the user clicks on the connection point and drags it over to the other component's connection point, which is the second option. Because there may be many different relationships in modeling, the graphical designer in Openexpressapp's Metamodelengine takes the first approach, but provides a shortcut to the second way.

How to connect

With the following connection instructions, we can know that there are two concepts of connection connection and connection point connector, which are respectively supported by two decorative objects to display and manipulate.

If the mouse is released at the connection point, a Connection object is generated, which acts as a Designercanvas child object.

Connection, like Desingeritem, also implements the Iselectable selection interface, when a connection is selected, the Connectionadorner above connection displays two rectangles each rectangle is a thumb control, You can drag to change a connection point

Move the mouse over an element, and there will be four connector around the element, which is defined in Connectordecoratortemplate, where the Designeritem template also defines part of the content.
When the mouse is moved to one of the connector, the mouse pointer becomes a cross shape
When the left mouse button is clicked on the connector, connector generates a connectoradorner that shows the current mouse position connected to the source connection point, and when the mouse moves, Designercanvas will be constantly checking to see if the mouse is on a potential target connection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.