我正在尝试检索SignaturePad的点以重新显示签名。
public static void GetPoints(string airid, SignaturePadView padView)
{
List<Strokes> DBStrokes = SqLiteHelper.conn.Query<Strokes>("select * from Strokes where airid = ? order by PointSequence", airid);
List<Point> points = new List<Point>();
foreach (Strokes stroke in DBStrokes)
points.Add(new Point { X = stroke.pointx, Y = stroke.pointy });
padView.Points = points.AsEnumerable();
}
数组点已正确填充,但是padView.Points
显示为结果
{Xamarin.Forms.Point [0]}。
答案 0 :(得分:0)
我发现了问题。似乎只有在签名板可见时才能设置Points属性。所以我的新代码如下:
List<Strokes> DBStrokes = SqLiteHelper.conn.Query<Strokes>("select * from Strokes where airid = ? order by PointSequence", formField.pictFile);
Xamarin.Forms.Point[] points = new Point[DBStrokes.Count];
for (int i = 0; i < DBStrokes.Count; i++)
points[i] = new Point(DBStrokes[i].pointx, DBStrokes[i].pointy);
var originalPoints = JsonConvert.SerializeObject(points);
Xamarin.Forms.Point[] points4View = JsonConvert.DeserializeObject<Xamarin.Forms.Point[]>(originalPoints);
signatureView.Points = points4View;
现在我正在使用Handle_MeasureInvalidated-事件来运行此代码。