. NET component Control instance programming series--4. Multi-column dropdown box and mouse-related components (ii)

Source: Internet
Author: User

Size components can be changed resizablecomponent

Implementation principle

1, here the control is divided into 9 areas, upper left, Ober Chong, top right, middle left, center, middle right, lower left, lower middle, lower right. The central area is surrounded by 8 other areas to form a virtual border. The width of the border can be customized, the central area does not respond, and the other 8 regions can optionally respond to the action.

2, mouse movement during the detection of mouse coordinates. If you are at the edge, you can set different mouse styles for different sizes depending on the location.

3, in the mouse down event record the current mouse coordinates

4, the mouse movement process, if the left mouse button pressed, according to the current position and the position of the previous record to calculate the displacement

5, according to mouse displacement and the area of the mouse, adjust the size and position of the control

6. Restores the default mouse style when the mouse moves away

Implementation Essentials

1. Internal controls may overwrite edges, and internal controls also need to handle mouse events. The same as a removable component indicates whether the internal control allows a response operation through an extended property.

2, can respond to change the size of the location can be customized to achieve custom UITypeEditor, visual settings.

3. Changing the size up or to the right requires you to change the position of the control at the same time, ignoring the displacement perpendicular to the current move direction when changing the size in a non diagonal direction.

The detailed implementation process is described below.

Enumeration:

Directionenum: Direction enumeration, all-all directions, horizontal-horizontal direction, vertical-vertical direction. This enumeration can be used in both move and resize operations.

Resizehandleareaenum: Change the size to handle the area enumeration, the need to handle the size of the control to divide into 3*3 areas, in addition to the center area, other areas are allowed to respond to mouse operations. This enumeration variable is edited with a custom UITypeEditor, which is described in detail later.

Class diagrams and class details for movablecomponent components

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.