Arrow in WPF code

Source: Internet
Author: User

There is nothing in this article, mainly someCode;

 

1: The background code in WPF draws a line similar to an arrow line;

 

Arrow line

// Fields
Private   Double Marrowangle =   0.17453292519943295 ;
Private   Double Marrowlengh =   30.0 ;

// Methods
Public   Override Geometry create ( Double X1, Double Y1, Double X2, Double Y2)
{
Point point =   New Point (x1, Y1 );
Point point2 =   New Point (X2, Y2 );
Double Num = Math. atan (Y2 - Y1) / (X2 - X1 ));
Double D = Num -   This . Arrowangle;
Double Num3 = Num +   This . Arrowangle;
Int Num4 = (X2 > X1) ?   - 1 : 1 ;
Double X = X2 + (Num4 *   This . Arrowlengh) * Math. Cos (d ));
Double Y = Y2 + (Num4 *   This . Arrowlengh) * Math. Sin (d ));
Double Num7 = X2 + (Num4 *   This . Arrowlengh) * Math. Cos (num3 ));
Double Num8 = Y2 + (Num4 *   This . Arrowlengh) * Math. Sin (num3 ));
Point point3 =   New Point (x, y );
Point point4 =   New Point (num7, num8 );
Pathgeometry Geometry =   New Pathgeometry ();
Pathfigure figure =   New Pathfigure ();
Figure. isfilled =   True ;
Figure. startpoint = Point2;
Point [] points =   New Point [] {point, point2, point3, point4, point2}; // from point2 to point, return to point2, and draw an arrow. And from point2 to point3 to point4 to point2 .....
Polylinesegment segment =   New Polylinesegment (points, True );
Figure. segments. Add (segment );
Geometry. Figures. Add (figure );
Geometry. Freeze ();
Return Geometry;
}

// Properties
Public   Double Arrowangle
{
Get
{
Return   This . Marrowangle;
}
Set
{
This . Marrowangle = Value;
}
}

Public   Double Arrowlengh
{
Get
{
Return   This . Marrowlengh;
}
Set
{
This . Marrowlengh = Value;
}
}

 

 

 

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.