// OnPaint event handler.
 // in:
 //      sender      object that has sent the event
 //      e           paint event arguments
 private void OnPaintHandler(object sender, PaintEventArgs e)
 {
     // Full redraw: draw complete collection of finished strokes and
     // also all the strokes that are currently in drawing.
     FinishedStrokes.Draw(e.Graphics);
     //ActiveStrokes.Draw(e.Graphics);
 }
        // Touch up event handler.
        // Finishes the stroke and moves it to the collection of finished strokes.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchUpHandler(object sender, WMTouchEventArgs e)
        {
            // Find the stroke in the collection of the strokes in drawing
            // and remove it from this collection.
            Stroke stroke = ActiveStrokes.Remove(e.Id);

            Debug.Assert(stroke != null);

            // Add this stroke to the collection of finished strokes.
            FinishedStrokes.Add(stroke);

            // Request full redraw.
            Invalidate();
        }
        // Touch up event handler.
        // Finishes the stroke and moves it to the collection of finished strokes.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchUpHandler(object sender, WMTouchEventArgs e)
        {
            // Find the stroke in the collection of the strokes in drawing
            // and remove it from this collection.
            Stroke stroke = ActiveStrokes.Remove(e.Id);

            Debug.Assert(stroke != null);

            // Add this stroke to the collection of finished strokes.
            FinishedStrokes.Add(stroke);
//#if (DEBUG_XY)
            label5.Text = "TOUCH UP";
            richTextBox1.AppendText("x: " + e.LocationX.ToString() + " ");
            richTextBox1.AppendText("y: " + e.LocationY.ToString() + "\n");
//#endif
            BoundaryCheck(0, e);

            // Request full redraw.
            Invalidate();
        }