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