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