//occurs when user moves mouse //will record most recent location of mouse, and call drawing function private void SignaturePanel_MouseMove(object sender, MouseEventArgs e) { if (isDown) { Point point = SignaturePanel.PointToClient(Cursor.Position); newX = point.X; newY = point.Y; DrawLine(); } }
//draws a line on user's screen between most recent mouse position, and second most recent //then updates second most recent position public void DrawLine() { if (oldX != -1 && oldY != -1) { Graphics g = SignaturePanel.CreateGraphics(); Pen pen = new Pen(Color.Black); g.DrawLine(pen, newX, newY, oldX, oldY); } oldX = newX; oldY = newY; }