internal void Write(Utf8JsonWriter writer, JsonSerializerOptions options)
        {
            SerializableFinalPointList = new List <SerializablePoint>(FinalPointList.Count);
            foreach (var point in FinalPointList)
            {
                var serializablePoint = new SerializablePoint();
                serializablePoint.Position = point.Position;
                serializablePoint.Pressure = point.Pressure;
                serializablePoint.TiltX    = point.TiltX;
                serializablePoint.TiltY    = point.TiltY;
                serializablePoint.Pressure = point.Pressure;
                SerializableFinalPointList.Add(serializablePoint);
            }

            if (DrawingAttributesIgnored != null)
            {
                SerializableDrawingAttributesKind             = (short)DrawingAttributesIgnored.Kind;
                SerializableDrawingAttributesPencilProperties = DrawingAttributesIgnored.PencilProperties?.Opacity;
                DrawingAttributes = new CustomInkDrawingAttribute
                {
                    Color             = DrawingAttributesIgnored.Color,
                    FitToCurve        = DrawingAttributesIgnored.FitToCurve,
                    IgnorePressure    = DrawingAttributesIgnored.IgnorePressure,
                    IgnoreTilt        = DrawingAttributesIgnored.IgnoreTilt,
                    Size              = DrawingAttributesIgnored.Size,
                    PenTip            = DrawingAttributesIgnored.PenTip,
                    PenTipTransform   = DrawingAttributesIgnored.PenTipTransform,
                    DrawAsHighlighter = DrawingAttributesIgnored.DrawAsHighlighter
                };
            }

            JsonSerializer.Serialize(writer, this, options);

            SerializableFinalPointList = null;
        }
        internal void OnSerializingMethod(StreamingContext context)
        {
            SerializableFinalPointList = new List <SerializablePoint>(FinalPointList.Count);
            foreach (var point in FinalPointList)
            {
                var serializablePoint = new SerializablePoint();
                serializablePoint.Position = point.Position;
                serializablePoint.Pressure = point.Pressure;
                serializablePoint.TiltX    = point.TiltX;
                serializablePoint.TiltY    = point.TiltY;
                serializablePoint.Pressure = point.Pressure;
                SerializableFinalPointList.Add(serializablePoint);
            }

            if (DrawingAttributesIgnored != null)
            {
                SerializableDrawingAttributesKind             = (short)DrawingAttributesIgnored.Kind;
                SerializableDrawingAttributesPencilProperties = DrawingAttributesIgnored.PencilProperties?.Opacity;
                DrawingAttributes = new CustomInkDrawingAttribute
                {
                    Color             = DrawingAttributesIgnored.Color,
                    FitToCurve        = DrawingAttributesIgnored.FitToCurve,
                    IgnorePressure    = DrawingAttributesIgnored.IgnorePressure,
                    IgnoreTilt        = DrawingAttributesIgnored.IgnoreTilt,
                    Size              = DrawingAttributesIgnored.Size,
                    PenTip            = DrawingAttributesIgnored.PenTip,
                    PenTipTransform   = DrawingAttributesIgnored.PenTipTransform,
                    DrawAsHighlighter = DrawingAttributesIgnored.DrawAsHighlighter
                };
            }
        }
Exemple #3
0
        internal void OnSerializingMethod(StreamingContext context)
        {
            SerializableFinalPointList = new List <SerializablePoint>(FinalPointList.Count);
            foreach (var point in FinalPointList)
            {
                var serializablePoint = new SerializablePoint();
                serializablePoint.Position = point.Position;
                serializablePoint.Pressure = point.Pressure;
                serializablePoint.TiltX    = point.TiltX;
                serializablePoint.TiltY    = point.TiltY;
                serializablePoint.Pressure = point.Pressure;
                SerializableFinalPointList.Add(serializablePoint);
            }

            if (DrawingAttributes != null)
            {
                SerializableDrawingAttributesKind             = (short)DrawingAttributes.Kind;
                SerializableDrawingAttributesPencilProperties = DrawingAttributes.PencilProperties?.Opacity;
            }
        }