將原始觸摸點轉換爲MonoTouch或MonoDroid屏幕座標的正確方法是什麼?我的代碼在仿真器上運行良好,但設備上的點不準確。這是我到目前爲止:MonoTouch/MonoDroid - 將原始觸摸座標轉換爲屏幕座標
private void Initialize()
{
this.Touch += TouchView_Touch;
}
void TouchView_Touch(object sender, View.TouchEventArgs e)
{
e.ReturnValue = true;
touchPoints.Add(e.Event.RawX);
touchPoints.Add(e.Event.RawY);
this.Invalidate();
}
protected override void OnDraw(Android.Graphics.Canvas canvas)
{
base.OnDraw(canvas);
canvas.DrawColor(Color.White);
Paint p = new Paint();
p.Color = Color.Black;
Matrix m = new Matrix();
canvas.GetMatrix(m);
float[] destination = touchPoints.ToArray();
Matrix inverse = new Matrix();
bool canInvert = m.Invert(inverse);
inverse.MapPoints(destination);
canvas.DrawPoints(destination, p);
}