public Signature GetSignature()
        {
            var points = inkPresenter.GetStrokes().SelectMany(stroke => stroke.GetPoints()).ToList();

            if (points.Count == 0)
            {
                return(null);
            }

            var features = Signature.SignatureFeatures.None;

            if (points.Min(point => point.Pressure) != points.Max(point => point.Pressure))
            {
                features |= Signature.SignatureFeatures.Pressure;
            }
            if (points.Min(point => point.TiltOrieantation?.X ?? 0) != points.Max(point => point.TiltOrieantation?.X))
            {
                features |= Signature.SignatureFeatures.TiltOrientationX;
            }
            if (points.Min(point => point.TiltOrieantation?.Y ?? 0) != points.Max(point => point.TiltOrieantation?.Y))
            {
                features |= Signature.SignatureFeatures.TiltOrientationY;
            }

            var signature = new Signature(
                features,
#if __ANDROID__
                new Signature.SignatureFrame(Width, Height),
#elif __IOS__
                new Signature.SignatureFrame((float)Frame.Width, (float)Frame.Height),
#endif
                inkPresenter.GetStrokes()
                ?.Select(inkStroke =>
            {
                var tsOrigin = inkStroke.GetPoints().Count > 0 ? inkStroke.GetPoints()[0].Timestamp : TimeSpan.Zero;
                var stroke   = new Signature.SignatureStroke(
                    Signature.SignatureStrokeSource.Touch,
                    inkStroke.GetPoints()
                    .Select(inkPoint => new Signature.SignaturePoint(
                                new Signature.SignaturePointPosition((float)inkPoint.Position.X, (float)inkPoint.Position.Y),
                                inkPoint.Pressure,
                                inkPoint.TiltOrieantation != null ? new Signature.SignatureTiltOrieantation(inkPoint.TiltOrieantation.X, inkPoint.TiltOrieantation.Y) : null,
                                inkPoint.Timestamp - tsOrigin)),
                    inkStroke.Timestamp);
                return(stroke);
            })
                .ToList(),
                inkPresenter.GetStrokes()[0].Timestamp);

            return(signature);
        }
Esempio n. 2
0
        public Signature GetSignature()
        {
            if (lStroke.Count == 0)
            {
                return(null);
            }

            var features = Signature.SignatureFeatures.None;
            var points   = lStroke.SelectMany(stroke => stroke.Points).ToList();

            if (points.Min(point => point.Pressure) != points.Max(point => point.Pressure))
            {
                features |= Signature.SignatureFeatures.Pressure;
            }
            if (points.Min(point => point.TiltOrieantation?.X ?? 0) != points.Max(point => point.TiltOrieantation?.X ?? 0))
            {
                features |= Signature.SignatureFeatures.TiltOrientationX;
            }
            if (points.Min(point => point.TiltOrieantation?.Y ?? 0) != points.Max(point => point.TiltOrieantation?.Y ?? 0))
            {
                features |= Signature.SignatureFeatures.TiltOrientationY;
            }

            var signature = new Signature(
                features,
                new Signature.SignatureFrame((float)Width, (float)Height),
                lStroke
                ?.Select(inkStroke =>
            {
                var tsOrigin = inkStroke.Points.Count > 0 ? inkStroke.Points[0].Timestamp : TimeSpan.Zero;
                var stroke   = new Signature.SignatureStroke(
                    (Signature.SignatureStrokeSource)inkStroke.Source,
                    inkStroke.Points
                    .Select(inkPoint => new Signature.SignaturePoint(
                                new Signature.SignaturePointPosition((float)inkPoint.Position.X, (float)inkPoint.Position.Y),
                                inkPoint.Pressure,
                                inkPoint.TiltOrieantation != null ? new Signature.SignatureTiltOrieantation(inkPoint.TiltOrieantation.X, inkPoint.TiltOrieantation.Y) : null,
                                inkPoint.Timestamp - tsOrigin)),
                    inkStroke.Timestamp);
                return(stroke);
            }),
                lStroke[0].Timestamp);

            return(signature);
        }