Paint.NET Learning Notes--four, form sticky

Source: Internet
Author: User
Tags abstract

This section describes the implementation of the control glue effect that appears in Windows applications.

has been playing music with Winamp until now using thousands of listening and cool dog, these audio playback software interface in the same vein, and have "control sticky" effect, now let's see how the PDN in this effect is achieved.

In PDN, the effect is implemented by the Snapmanager class and snapobstacle (hereinafter called obstacles) abstract classes, of course, there are auxiliary classes, such as Snapdescription (hereinafter called the definition of glue) class.

Snapmanager as the name implies is the management of adhesion effect, responsible for the positioning of the obstacles, to determine whether the need to adhere to, save the load effect, the formation of sticky objects such as the definition of work.

Snapobstacle is an abstract class that defines the necessary properties of a "sticky" control, including the outline of the obstacle, the distance to stick, the sticky event, and so on.

Then let's see how they work together.

The glue effect is primarily applied to floating windows (toolbars, history, colors, and layers). From the previous article, we've learned about the inheritance relationships of these forms and the interfaces they implement, and here's a quick review:

Pdnbaseform for all forms of the parent class, the implementation of the Isnapmanagerhost interface, all floating windows inherit from the Floatingtoolform, the implementation of the Isnapobstaclehost interface. All "sticky" effects are provided by these two interfaces.

The two interfaces are fairly simple, each of which provides only one property, the Snapmanager and snapobstacle respectively.

Let's take a look at the Snapmanager class, which has explained the main role of the class, no longer verbose, and then look at the code in detail:

Snapmanager Field

 1private Dictionary<SnapObstacle, SnapDescription> obstacles =new Dictionary<SnapObstacle, SnapDescription>();
  2private const string isSnappedValueName = "IsSnapped";
  3private const string leftValueName = "Left";
  4private const string topValueName = "Top";
  5private const string widthValueName = "Width";
  6private const string heightValueName = "Height";
  7private const string nullName = "";
  8
  9private const string snappedToValueName = "SnappedTo";
10private const string horizontalEdgeValueName = "HorizontalEdge";
11private const string verticalEdgeValueName = "VerticalEdge";
12private const string xOffsetValueName = "XOffset";
13private const string yOffsetValueName = "YOffset";

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.