windows mobile中籤字

來源:互聯網
上載者:User

滑鼠(手寫筆)軌跡座標記錄,然後畫很多短的線
一:建立一個類,代表線段的兩個端點(之所以用線段是由於需要連續的效果,否則如果滑鼠移動的太快的話,會有斷斷續續的現象)
 public class DrawLine
   {
    private int _x1;
    private int _y1;
    private int _x2;
    private int _y2;
    public DrawLine(int X1, int Y1, int X2, int Y2)
    {
        _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;
        }
    }
   }

二 在簽字的表單裡定義

        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>();
        }

        並且在MouseDown,MouseMove,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;
        }
       可以將Points中的內容儲存起來,拱日後還原

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.