// Touch move event handler.
        // Adds a point to the active stroke and draws new stroke segment.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchMoveHandler(object sender, WMTouchEventArgs e)
        {
            // Find the stroke in the collection of the strokes in drawing.
            Stroke stroke = ActiveStrokes.Get(e.Id);

            Debug.Assert(stroke != null);

            // Add contact point to the stroke
            stroke.Add(new Point(e.LocationX, e.LocationY));

            // Partial redraw: only the last line segment
            Graphics g = this.CreateGraphics();

            stroke.DrawLast(g);
        }
        // Touch down event handler.
        // Starts a new stroke and assigns a color to it.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchDownHandler(object sender, WMTouchEventArgs e)
        {
            // We have just started a new stroke, which must have an ID value unique
            // among all the strokes currently being drawn. Check if there is a stroke
            // with the same ID in the collection of the strokes in drawing.
            Debug.Assert(ActiveStrokes.Get(e.Id) == null);

            // Create new stroke, add point and assign a color to it.
            Stroke newStroke = new Stroke();

            newStroke.Color = touchColor.GetColor(e.IsPrimaryContact);
            newStroke.Id    = e.Id;

            // Add new stroke to the collection of strokes in drawing.
            ActiveStrokes.Add(newStroke);
        }
        // Touch move event handler.
        // Adds a point to the active stroke and draws new stroke segment.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchMoveHandler(object sender, WMTouchEventArgs e)
        {
            // Find the stroke in the collection of the strokes in drawing.
            Stroke stroke = ActiveStrokes.Get(e.Id);

            Debug.Assert(stroke != null);

            // Add contact point to the stroke
            stroke.Add(new Point(e.LocationX, e.LocationY));

#if (DEBUG_XY)
            label5.Text = "TOUCH MOVING";
            richTextBox1.AppendText("x: " + e.LocationX.ToString() + " ");
            richTextBox1.AppendText("y: " + e.LocationY.ToString() + "\n");
#endif
            // Partial redraw: only the last line segment
            Graphics g = this.CreateGraphics();
            stroke.DrawLast(g);
        }
        // Touch down event handler.
        // Starts a new stroke and assigns a color to it.
        // in:
        //      sender      object that has sent the event
        //      e           touch event arguments
        private void OnTouchDownHandler(object sender, WMTouchEventArgs e)
        {
            // We have just started a new stroke, which must have an ID value unique
            // among all the strokes currently being drawn. Check if there is a stroke
            // with the same ID in the collection of the strokes in drawing.
            Debug.Assert(ActiveStrokes.Get(e.Id) == null);

            // Create new stroke, add point and assign a color to it.
            Stroke newStroke = new Stroke();

            newStroke.Color = touchColor.GetColor(e.IsPrimaryContact);
            newStroke.Id    = e.Id;

            // Add new stroke to the collection of strokes in drawing.
            ActiveStrokes.Add(newStroke);

//#if (DEBUG_XY)
            label5.Text = "TOUCH DOWN";
            richTextBox1.AppendText("x: " + e.LocationX.ToString() + " ");
            richTextBox1.AppendText("y: " + e.LocationY.ToString() + "\n");
//#endif
            BoundaryCheck(1, e);
        }