public override bool OnTouchEvent (MotionEvent e) { Point point = new Point(); point.X = (int)e.GetX (); point.Y = (int)e.GetY (); int count = 0; foreach (PieSlice slice in slices) { Region r = new Region(); r.SetPath(slice.getPath(), slice.getRegion()); if (r.Contains(point.X, point.Y) && e.Action == MotionEventActions.Down) { indexSelected = count; } else if (e.Action == MotionEventActions.Up){ if (r.Contains(point.X, point.Y) && listener != null) { if (indexSelected > -1){ listener.onClick(indexSelected); } indexSelected = -1; } } count++; } if (e.Action == MotionEventActions.Down || e.Action == MotionEventActions.Up){ Invalidate(); } return base.OnTouchEvent (e); }
public override bool OnTouchEvent (MotionEvent e) { Point point = new Point(); point.X = (int)e.GetX (); point.Y = (int) e.GetY(); int count = 0; int lineCount = 0; int pointCount; Region r = new Region(); foreach (Line line in lines) { pointCount = 0; foreach (LinePoint p in line.getPoints()) { if (p.getPath() != null && p.getRegion() != null){ r.SetPath(p.getPath(), p.getRegion()); if (r.Contains(point.X, point.Y) && e.Action == MotionEventActions.Down) { indexSelected = count; } else if (e.Action == MotionEventActions.Up){ if (r.Contains(point.X, point.Y) && listener != null) { listener.onClick(lineCount, pointCount); } indexSelected = -1; } } pointCount++; count++; } lineCount++; } if (e.Action == MotionEventActions.Down || e.Action ==MotionEventActions.Up){ shouldUpdate = true; Invalidate(); } return base.OnTouchEvent (e); }