/// <summary> /// Decode object message /// </summary> private void DecodeObjMessage(ref byte[] data) { // Fill-in object message this.touch.filldata(ref data); // Object T9 messge valid id number equal and large 3 if (this.touch.get_id >= 3 && this.touch.get_id < this.touch.skip_id) { bool IsPrimaryContact = ((this.touch.get_id & 0x03) == 1); int id = this.touch.get_id; // Touch pad coordination get back int x = (this.touch.get_t9_x); int y = (this.touch.get_t9_y); int LocationX; int LocationY; // Touch point coordinates and contact size is in of a pixel; convert it to pixels. // Also convert screen to client coordinates. Point pt = PointToClient(new Point(x, y)); LocationX = pt.X; LocationY = pt.Y; switch (this.touch.get_t9_event) { case T9_TOUCH_MOVE: { // Find the stroke in the collection of the strokes in drawing. Stroke stroke = ActiveStrokes.Get(id); // Add contact point to the stroke stroke.Add(new Point(LocationX, LocationY)); // Partial redraw: only the last line segment Graphics g = this.CreateGraphics(); stroke.DrawLast(g); } break; case T9_TOUCH_DOWN: { // Create new stroke, add point and assign a color to it. Stroke newStroke = new Stroke(); newStroke.Color = touchColor.GetColor(IsPrimaryContact); newStroke.Id = id; // Add new stroke to the collection of strokes in drawing. ActiveStrokes.Add(newStroke); DebugLocationXY(id, "d", LocationX, LocationY); BoundaryCheck(id, 1, LocationX, LocationY); } break; case T9_TOUCH_UP: { // Find the stroke in the collection of the strokes in drawing // and remove it from this collection. Stroke stroke = ActiveStrokes.Remove(id); // Add this stroke to the collection of finished strokes. FinishedStrokes.Add(stroke); // Request full redraw. Invalidate(); DebugLocationXY(id, "u", LocationX, LocationY); BoundaryCheck(id, 0, LocationX, LocationY); } break; } } // Object T100 valid id number equal and large 41 // Skip id 39 not used if (this.touch.get_id > this.touch.skip_id) { bool IsPrimaryContact = ((this.touch.get_id & 0x01) == 1); int id = this.touch.get_id; // The minimum and maximun values of the absolutely coordination // define the bounds of the activate area of the device in device-specific surface. int minX = 0; // ABS min x int minY = 0; // ABS min y int maxX = 1365; // ABS max x int maxY = 767; // ABS max y int displayWidth = 1024; // target resolution x int displayHeight = 638; // target resolution y int displayX = ((this.touch.get_x) - minX) * displayWidth / (maxX - minX + 1); int displayY = ((this.touch.get_y) - minY) * displayHeight / (maxY - minY + 1); int LocationX; int LocationY; // touch point coordinates and contact size is in of a pixel; convert it to pixels. // Also convert screen to client coordinates. Point pt = PointToClient(new Point(displayX, displayY)); LocationX = pt.X; LocationY = pt.Y; switch (this.touch.get_event) { case TOUCH_MOVE: { // Find the stroke in the collection of the strokes in drawing. Stroke stroke = ActiveStrokes.Get(id); // Add contact point to the stroke stroke.Add(new Point(LocationX, LocationY)); // Partial redraw: only the last line segment Graphics g = this.CreateGraphics(); stroke.DrawLast(g); } break; case TOUCH_DOWN: { // Create new stroke, add point and assign a color to it. Stroke newStroke = new Stroke(); newStroke.Color = touchColor.GetColor(IsPrimaryContact); newStroke.Id = id; // Add new stroke to the collection of strokes in drawing. ActiveStrokes.Add(newStroke); //DebugLocationXY(id, "d", LocationX, LocationY); BoundaryCheck(id, 1, LocationX, LocationY); } break; case TOUCH_UP: { // Find the stroke in the collection of the strokes in drawing // and remove it from this collection. Stroke stroke = ActiveStrokes.Remove(id); // Add this stroke to the collection of finished strokes. FinishedStrokes.Add(stroke); //DebugLocationXY(id, "u", LocationX, LocationY); if (false == BoundaryCheck(id, 0, LocationX, LocationY)) { // Request full redraw. Invalidate(); } } break; } } }
/// <summary> /// Adds the stroke to the collection. /// in: /// stroke stroke to be added /// </summary> public void Add(Stroke stroke) { strokes.Add(stroke); }