Design and development based on Silverlight smart forms (2)

Source: Internet
Author: User

Continue with the previous section "Silverlight-based smart form design and development (I)", from which class design will be performed on the system, I use simple ideographic diagrams and key code snippets to describe them and express my design ideas. Next I will start from the design of the Form Design anchor class, and gradually expand and analyze it from the bottom up.

The anchor is a small rectangular box around the control when the control is selected. You can drag a small rectangular box (Anchor) to change the height and width of the control, meanwhile, you can set the visibility of the control anchor to indicate whether the control is selected. As shown in:

I. auchor)

The anchor class mainly contains the anchor location attribute to determine the position of the anchor on the control, such as the top left, top middle, and top right.

1. Class Diagram

2. code snippets

First, let's take a look at the XML code of the auchor Anchor anchor interface. The function of the XML code is to draw a small square through rectangle. The width of the square border is 1px, the border color is black, and fill it with a light blue brush:

 <Grid x:Name="LayoutRoot" >
<Rectangle x:Name="rtg" Stroke="Black" StrokeThickness="1" Cursor="Hand" Fill="#FFCBC8DD"></Rectangle>
</Grid>

The implementation code of the auchor Anchor anchor class. The Anchor class mainly sets the anchor's position based on the location attribute and the cursor corresponding to the position:

 

Code

 /// <Summary>
/// Position of the anchor
/// </Summary>
Public Enum auchorlocation {top left, top middle, top right, right middle, left middle, bottom left, bottom middle, bottom right}
/// <Summary>
/// The control class of the anchor.
/// </Summary>
Public partial class auchor: usercontrol
{
Auchorlocation location;
/// <Summary>
/// Obtain or set the position of the anchor.
/// </Summary>
Public auchorlocation location
{
Get {return location ;}
Set
{
Location = value;
If (value = auchorlocation. Upper right | value = auchorlocation. Lower Left) RTG. cursor = cursors. sizenesw;
If (value = auchorlocation. Upper Left | value = auchorlocation. Lower right) RTG. cursor = cursors. sizenwse;
If (value = auchorlocation. Medium | value = auchorlocation. Medium) RTG. cursor = cursors. sizens;
If (value = auchorlocation. middle right | value = auchorlocation. middle left) RTG. cursor = cursors. sizewe;
}
}


}

 

The above is the design and implementation method of the anchor. Anchor is the basic element of smart form design. First, it is ready for subsequent work, in the next section, we will cover another basic element design container class (designrectangle )......

 

 

 

 

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.