Signatures in Windows Mobile

Source: Internet
Author: User

coordinates of the mouse (PEN) trajectory, draw a lot of short lines.
1. Create a class to represent the two endpoints of a line segment. (the reason why the line segment is used is due to the continuous effect. Otherwise, if the mouse moves too fast, this may occur intermittently.)
public class drawline
{< br> private int _ x1;
private int _ Y1;
private int _ X2;
private int _ Y2;
Public drawline (INT X1, int Y1, int X2, int Y2)
{< br> _ X1 = x1;
_ Y1 = Y1;
_ X2 = x2;
_ y2 = Y2;
}

Public int X1
{
Get
{
Return _ x1;
}

Set
{
_ X1 = value;
}
}

Public int Y1
{
Get
{
Return _ Y1;
}

Set
{
_ Y1 = value;
}
}

Public int X2
{
Get
{
Return _ X2;
}

Set
{
_ X2 = value;
}
}

Public int Y2
{
Get
{
Return _ Y2;
}

Set
{
_ Y2 = value;
}
}
}

2. Define in the signed form

Private int x1;
Private int X2;
Private int Y1;
Private int Y2;
Private system. Drawing. Pen mpen = new pen (system. Drawing. color. Black, 2 );
Private bool bmouse = false;
Public System. Collections. Generic. List <drawline> points;

Private void signature_load (Object sender, eventargs E)
{
Points = new list <drawline> ();
}

You can also perform the following operations in mousedown, mousemove, and mouseup:
Private void signature_mousedown (Object sender, mouseeventargs E)
{
Bmouse = true;
X1 = E. X;
Y1 = E. Y;
}

Private void signature_mousemove (Object sender, mouseeventargs E)
{
If (! Bmouse)
{
Return;
}
Else
{
Graphics g;
X2 = E. X;
Y2 = E. Y;
G = This. creategraphics ();
Drawline point = new drawline (x1, Y1, X2, Y2 );
Points. Add (point );
G. drawline (mpen, X1, Y1, X2, Y2 );
X1 = x2;
Y1 = Y2;
}
}

Private void signature_mouseup (Object sender, mouseeventargs E)
{
Bmouse = false;
}
You can save the content in points and restore it later.

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.