2

我正在尝试检索 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]}。

4

1 回答 1

0

我发现了问题。似乎只有在 Signaturepad 可见时才能设置 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 - 事件来运行此代码。

于 2018-09-04T07:12:16.867 回答